Is it possible to use a goldmark extension or other approach to render admonition blocks without shortcodes?

I want to either write or handle admonition blocks without shortcodes, so that I can use an editor like Typora a little more easily for preview. I’ve found some topics and read the docs but not clear on process.

Is there any quick guide to what I’d need to do or if it’s even possible without doing a custom hugo build?

No. You cannot use a goldmark extension. There is no API for that.

You would need to fork Hugo and incorporate the extension in your fork.

You can add attributes to blockquotes:

>Able was I ere I Elba.
{class="admonition admonition-warning"}

To enable this capability in your site configuration:

[markup.goldmark.parser.attribute]
block = true

You could also use JS to change the structure (e.g., wrap in a <div>, add a title, etc.) by targeting the class, and pass additional data (e.g., title, label) in the blockquote’s data attributes.

>Able was I ere I Elba.
{class="admonition admonition-warning" data-title="This is a Warning" data-label="My Label"}
1 Like

Hi !

I’m very very very new to Go.
I found this repo about Goldmark and admonitions.

Am I right if I write that this “module” (?) could be loaded by hugo with this : Hugo Modules | Hugo ?

I I’m right, and so I could use this module, does it mean I have to compile Hugo ?

Sorry for these (maybe) stupid or silly questions
and thanks in advance for your explanations.

No.

Use markdown attributes. Some examples here.

1 Like