Templater icon indicating copy to clipboard operation
Templater copied to clipboard

Allow dynamic command output be interpreted as markdown

Open pdxrlk opened this issue 3 years ago • 5 comments

I have a dynamic command which generates markdown. When I preview the note, the command is run properly, but (of course?) the outputs is displayed as raw text, rather than being interpreted as markdown. I'm using dynamic commands because the output will vary from time to time, and should not be fixed when the note is created.

Is there any way to have the output be interpreted as markdown?

Example

User function "echo header"

/bin/echo "# Header"

Contents of a note file:

<%+ tp.user.echoheader() %>

Outputs:

# Header1

Hoped-for output:

Header 1

pdxrlk avatar Jun 06 '21 02:06 pdxrlk

+1, would like this as well. I run a dynamic command that pulls in tasks related to the note's title from an external command, and I'd like to format it as a bullet list.

thomasvs avatar Apr 22 '22 15:04 thomasvs

I also checked https://silentvoid13.github.io/Templater/commands/whitespace-control.html in case I was missing something; I don't think this page applies to dynamic template output currently. The page specifically says that newlines aren't stripped from output, but the multi-line output of my dynamic template command in preview mode strips all newlines and puts all output on a single line. Even keeping newlines as is (without full markdown support) would already be a help for me.

thomasvs avatar Apr 22 '22 16:04 thomasvs

@thomasvs your use case sounds doable with DVJS but can you demonstrate with an example?

AB1908 avatar Apr 22 '22 17:04 AB1908

What's DVJS? Google isn't helping me with that acronym.

I think a simple shell command that outputs markdown or newlines is the easiest example to demonstrate this. The code that I'm running queries a local server so not as helpful to debug.

thomasvs avatar Apr 22 '22 18:04 thomasvs

Sorry, I meant dataviewjs. It's from another Obsidian plugin.

AB1908 avatar Apr 22 '22 20:04 AB1908