A Matter of Style - Markdown

This is a small discourse on Markdown styling in DEVONthink 3, to help people understand the styling methods and the cascading effect of styling.

This is a simple default stylesheet, chosen in Preferences > Media > Markdown > Style Sheet.
defaultStylesheet
Note it’s setting some basic parameters for paragraph elements, much of what we type in Markdown. A little padding and a colored rounded rectangle around the paragraph.

You should notice there is no font information specified in this stylesheet. This means the default font specified in Preferences > Editing > Rich Text & Note Font will be used in the rendered Markdown.
You can see it’s Times Roman 14 here.

Creating a new Markdown document with no stylesheet specified in the Markdown yields this…


We have the colored rectangle around each paragraph and the font is clearly Times.


We can create another stylesheet. This is one I put directly in a DEVONthink database. Here we have specified a different background color and a border.


Notice the new stylesheet has no information about the rounded rectangle, but the rounded rectangles are shown. This is being picked up from the default stylesheet.


Lastly, we can add internal styling in the Markdown document…

Notice this is picking up the color from the stylesheet in step 2 above - not from the default stylesheet as we have linked the stylesheet in the top of the Markdown - but we have overridden the font and modified the border.


And to show the effect of the default stylesheet, I removed the it from the Media preferences. This is the effect on the last file (and yes, it affected the second file too)…

You should see the padding is gone - as it wasn’t specified anywhere else. However, a background color was specified in the second stylesheet, so it’s present here too. But again, the internal styling gave it a blue dashed border instead of the magenta one specified.

There is no requirement to use a default stylesheet. (I personally don’t.) If you’d like to use one, for a generally uniform appearance of your rendered Markdown, go ahead and use one. However, the cascading effect allows you to use override styling on a case-by-case basis.

I hope this helps illustrate the flexibility you have with Markdown styling.

18 Likes

Super useful reference – thanks Bill.

You’re welcome… said Jim :wink:

That’s very helpful. Thanks!

Thanks a lot for this, it’s exactly the info I’ve been looking for as I’m learning about using Markdown in DT.

I have a question about the “CSS: x-devonthink-item” method of linking the stylesheet. I really like this because it allows for moving the stylesheet anywhere I want without breaking the link in the md file.

I played around with this and I’m not sure if this is a bug or intended behavior. I copied a link to the stylesheet and pasted it in the top of the md file then pressed return and it created a clickable link back to the stylesheet as shown below. If I don’t press return, the link is not created.

I can click the link to open the stylesheet (which works), and when I click the back arrow to go back to the md file the link is gone as shown here:

Also just switching between source and preview make the link disappear.

Is this the intended behavior? I really would like the link so I can easily open the stylesheet for editing. I did see that I can highlight the URL, right-click and select “Open URL” to take me there as well but it’s a lot slower.

Glad it’s helpful!
Development would have to comment on the display and behavior of a link in plain text.

A post was split to a new topic: Problems viewing Markdown

Did you enable data detection (see Preferences > Editing or menu Edit > Substitutions)? In that case macOS scans the plain text for links, e.g. after editing or pasting, and highlights it. But on 10.14.5 it’s IMHO not that reliable, just like Edit > Substitutions > Text Replacement - sometimes it works, sometimes not. YMMV.

Just checked and, yes, data detection is enabled. I’m running 10.14.5.