HTMLPreviewCommand and templates - can I get HTML preview, and markdown source?

I haven’t quite cracked it (and I don’t even know if it’s possible), but I have come up with something workable for the time being. I would love it if anyone could share a way to have the preview and HTML work the way I want. But here’s my current solution that’s a few more steps.

Basically it involves creating a separate template, which renders the note using the Markdown page template, and passes the result through to the Markdown prototype’s HTMLPreviewCommand. Then I have stamps to switch between Preview and Export modes - Preview mode sets the HTMLExportTemplate to Processed markdown, and Export mode sets it to Markdown page. I have a third stamp that copies the markdown source to the clipboard, regardless of the mode.

Processed markdown template

^value(runCommand($HTMLPreviewCommand("/System/Prototypes/Markdown"), exportedString(current, "/System/Templates/Markdown page")))^

Preview mode

$HTMLExportTemplate("/System/Prototypes/Note") = "/System/Templates/Processed markdown";

Export mode

$HTMLExportTemplate("/System/Prototypes/Note") = "/System/Templates/Markdown page";

Copy markdown

runCommand("pbcopy", exportedString(current, "/System/Templates/Markdown page"))

rich mark.tbx (120.0 KB)