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.

Thanks!

D

Welcome @c0smon4ut

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

What are md admonitions?

@chrillek Found this https://docutils.sourceforge.io/docs/ref/rst/directives.html#specific-admonitions

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.

Actually…

2 Likes

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:

Arriving late to this party but, to answer chrillek’s question (“Which begs the question: Which app does support admonitions properly?”), Obsidian uses the following syntax:

[!note] Note
Note text.

The title is optional, and the following are recognised as types of admonitions (with associated emojis):

  • [!abstract], [!summary], [!tldr]
  • [!bug]
  • [!check], [!done]
  • [!error]
  • [!example]
  • [!fail]
  • [!help], [!question]
  • [!hint], [!tip]
  • [!info]
  • [!note]
  • [!quote]
  • !todo]
  • [!warning], [!attention]

It’s worth mentioning that it’s also possible to configure the corresponding admonition block as collapsible:

[!note]- Collapsed Note
Note text.

[!note]+ Collapsable Note (shown expanded, by default)
Note text.

Personally, I would love to see these natively supported in DEVONthink.

That syntax is proprietary to Obsidian, not any kind of standard. We prefer to work within established guidelines whenever possible.

3 Likes

See the MSDoc Markdown Reference documentation. The syntax has also been adopted by GitHub.

The GitHub stuff is more limited, and MS’s and theirs differ in how they render the MD (blockquote vs div).

And I think that neither blockquote nor div is the correct element for an admonition. aside should be. We’re not talking about a “quote” here, so blockquote is out of the question. And similar to div, it belongs semantically to the normal flow of text, while an admonition does not, I think.

1 Like