Style parts of Markdown documents with CSS

In the forum thread Rendering of Markdown document is corrupt in DEVONthinkthe question arose how to style individual paragraphs in Markdown documents. I found an easy way to do this with DIV tags.

Let’s say, in a Markdown document you want to center a paragraphs with line breaks and bold decorated text and you want to right-align another paragraph. For this wrap the centered paragraph in a DIV with the attributes markdown=1 style=‘text-align:center’ and the right-aligned paragraph with markdown=1 style=‘text-align:right’.

Here a full example:

A first line without style

<div markdown=1 style='text-align:center'>

Here two lines  
*decorated* and **centered**.


<div markdown=1 style='text-align:right'>

And one, just **one** line right-aligned.


And let's finish off in normal left-aligned style again.

The important bit is the markdown=1 attribute. It makes sure that the Markdown renderer in DEVONthink (Multimarkdown Version 5) parses as Markdown what’s wrapped inside the DIV.

As an aside: This works in the mentioned way only in Multimarkdown Version 5 (see this docu). If you use outside DEVONthink on your system Multimarkdown Version 6 (which is now the default version of Multimarkdown) you have to use empty lines to separate the paragraphs from the DIV tags (see this docu), but the markdown attribute should not hurt. So providing both (in my example) is the safest, I guess.

While this works as a temporary fix, we will not be staying with MultiMarkdown 5 forever.

Good to hear, Jim! :slight_smile: What’s the ETA for moving to the current version 6?

BTW, in v6 it is enough to separate the line containing the HTML tag (the DIV tag) with empty lines from the text to indicate markdown parsing in the text.This is certainly more natural, then the markdown=1 attribute in V5.

Sorry, but we don’t comment on development timeframes. But it’s not anytime soon, so I caution you about using the “fix” as it will leave you with more documents to backwards maintenance.

PS: Though I’m no Markdown snob, adding markup to a Markdown file is often considered bad form, crossing the line of content and presentation. For personal use, go for it. If you have professional hopes with Markdown, it’s likely not a good habit to be in. Just a thought.

Is there now a better way of centering text in Markdown document?

It’s done in a stylesheet or internal styling.
Markdown is about plain text content.
CSS is about presentation.

OK, but how do I actually do this one simple thing?

I cannot find anything helpful in either DEVONthink’s built-in Help, or Joe Kissel’s TCo searching for either css or stylesheet.

That depends on what you’re trying to center. As a simple example, you could use…

h1, h2, h3, h4, h5, p {
text-align: center;

Note: CSS is beyond the scope of our documentation.

I want to center an occasional isolated paragraph, which may or may not be a header. I don’t want to do any global centering.

I’m not concerned about portability, just ease of typing. I don’t expect to share my notes.

I would suggest you just hack the blockquote then.

Here’s an example with a lovely scotch rule I coded in :slight_smile:

Just type away until you want to do a centered paragraph, then precede that one with >.

Thank you, @BLUEFROG! Your example gives me enough to work with.

You’re welcome :blush: