Markdown Admonitions

Howdy Fellow DT users.

I am a fairly new user to DT and it fits so well into my workflow that I’m mad I didn’t find it sooner. I’m really diving in and trying to get everything working and tweaked how I want it and had a question about Markdown. I am curious if Markdown Admonitions are supported or if there’s a way to add them using a custom CSS?

If anyone knows if this is possible or if there’s a post already discussing this let me know. I couldn’t find one after doing some digging but that doesn’t mean it’s not out there.



Welcome @c0smon4ut

There is no specific support for this. However, it should easy enough to style something.

What are md admonitions?

@chrillek Found this

Thanks. So one could style them, if they are translated into useful HTML, Like a div with a suitable class attribute.

1 Like

“supported” is a bit vague :wink: DT doesn’t choke on them (which you can easily find out for yourself). However, it does not seem to do anything with the markup in this case, it is simply carried over in the preview as is. The same happens with Drafts, iAWriter, Bear and Marked 2. Which begs the question: Which app does support admonitions properly, i.e. by converting them to an HTML block element with an appropriate class attribute?

“Something”? From what I can see, the HTML generated for an admonition like
.. warning:: This is a warning
looks like this:

<p>.. warning:: This is a warning</p>

So it’s a simple paragraph, not discernible from any other paragraph – at least not with a CSS selector, since there’s none for text nodes.
What one could do, but probably not in DT (please correct me if I’m wrong) is to convert these admonitions into HTML elements with a proper class attribute. That would then permit styling with CSS. It should be feasible in Drafts with a handcrafted HTML template and an action step before that.

is to convert these admonitions into HTML elements with a proper class attribute. That would then permit styling with CSS.

Yes, you could add them as a div with a class and style that class (though I don’t know why Drafts would be used).

A div wouldn’t be enough. The admonition can contain other block elements, e.g. lists. Those would have to be converted to html, too.
And you’re right, by accessing plaintext one could do that processing in DT with a script.



So if I understand that correctly, the MD to HTML converter passes HTML through unchanged and just converts the markup, even “inside” the div? I wasn’t aware of that.
In this case, one could actually write a small script to convert .. warning:: into the appropriate div, if need be.

MultiMarkdown allows this behavior, Markdown bookended by HTML tags with an empty line separating them.

Thanks, folks! I knew there was probably a way to do what I wanted and this totally works. So looking forward to continuing to delve into DT.

You’re very welcome. :slight_smile: