Tinderbox Forum

Preview Markdown Vs Export Markdown

I have the following situation - I want to export and preview in Markdown mode.

  1. I can setup my environment to preview markdown [1], but when I do so, HTML exports are in HTML
  2. I can setup my environment to export markdown [2], but when I do so, preview is in HTML (or at least not in Markdown)

Common to [1] and [2]:
All notes derive from P_Main which derives from Markdown

It is not that painful to switch the value of HTMLPreviewCommand depending on viewing vs exporting; I am still curious as to whether I am missing something.



HTMLPreviewCommand = CommonMark
HTMLPreviewCommand = none

Template text:

  • ^title
  • ^text(plain)
  • ^value
  • ^include
  • ^children

I do this all the time, write and preview in pure markdown.

Personally, I don’t use the Markdown prototype, as I like my own prototypes. So, I’ve created a stamp that I apply to notes I want to write and preview in markdown:

Marketdown Stamp

//Action code to change note color, use the CommonMark preview, and apply my markdown template, as well as trigger Citation highlighting. 

$HTMLExportTemplate="/Templates/tPageMD page";

I then have a prototype that applies these values and my markdown template.

Markdown Template

Here is a SUPER SIMPLIFIED markdown template. The template I use is much more complex. It has dynamic heading numbering, offsets, is prototype and attribute sensitive (meaning it will do different things based on attribute value and the prototype of a note), and will display or not display titles, text and children based on boolean attribute values. It is tailored to my specific needs. But, the basic template below should point you in the right direction.

REMEMBER: Unlike HTML, spacing matters in markdown. The blank spaces in a markdown template have meaning. Also, note, the blow is not “Pure” markdown as the the ^text^ attribute code will process the text for export code and other formatting. If you want pure markdown then you’d used the tSimpMDPure template in the attached file.

# ^value($Name)^
^children(/Templates/tSimpMD page)^

## ^value($Name)^
^children(/Templates/tSimpMD page)^

### ^value($Name)^
^children(/Templates/tSimpMD page)^

<p><b>^value($Name)^</b>. ^value($Text)^</p>
^children(/Templates/tSimpMD page)^^endif^

Processed Example:

Pure Example:

If you want to tweak the “Pure” example for legibility you can add some <br> tags to the template and you’d get this, but then it is not “pure” markdown any more (but what really is?).

TBX L - Simple Markdown Template with Markdown Preview.tbx (148.2 KB)

1 Like

Thanks Michael,
Will give it a try.

just a little off-topic: how/where do I define the default font for the preview? I set a font in the document settings but still the preview shows a different font. If I use a html element I could add a style to fix this - but there should a way without using styles?!

1 Like

how/where do I define the default font for the preview?

Tinderbox assumes that you’ll set the styles in the template. Now that this is exposed in Hints, you can just add a line or two to set the style.


BTW, just published an explanatory video, inspired by you.

1 Like