Markdown pre-processing?

Are there any current, or future planned features to support markdown pre-processing?

Shortcodes are great, but sometimes you just want things to be smother and more implicit.
e.g. just applying classes to tables or lists. rewriting hrefs in links or whatnot.

Also, being able to hook in extensions into Goldmark itself would be pretty nice.

The easiest approach would likely be to have some way to override the markdownify function.
intercept the content that is passed in there when a .md file is processed.


Currently, you can:

  1. Intercept and rewrite links, images, and headings with render hooks.

  2. Specify attributes for headings (H1-H6) with a kramdown-like syntax. For example:

    # My Heading {#foo .bar class="baz" style="color: red;" data-wibble="wobble"}


    <h1 id="foo" class="bar baz" style="color: red;" data-wibble="wobble">My Heading</h1>

To specify attributes for elements other than headings you will have to use shortcodes. Hugo uses the Goldmark markdown renderer, which adheres to the CommonMark specification. The discussion of attribute syntax as a possible addition to the spec has been going on for six years .

The project maintainer for Goldmark has indicated their intention to extend attribute support to other elements, but will not do so on an ad hoc basis.

1 Like