Add own classes in markdown/html tags?

Is it possible to add own classes in h1–h6 and p tags with yaml? Example:

# This is main heading to be processed with magic

And I would like to have all h1 tags adapted with custom class “main-heading” -> output in html

<h1 class="main-heading">This is main heading to be processed with magic</h1>

Maybe something like this in yaml:

process:
  content:
    classes:
      h1: main-heading
---

in .md’s header

classes:
   - h1: main-heading
   - h2: secondary-heading

in your TWIG template:

<h1 class="{{ header.classes.h1 }} ">This is main heading to be processed with magic</h1>
<h2 class="{{ header.classes.h2 }} ">This is secondary heading to be processed with magic</h2>
---

So, I can not use {{ content }} in TWIG template and get the classes automatically, if there is headings used?

You can use markdown extra: https://michelf.ca/projects/php-markdown/extra/#spe-attr

Just need to enable it system-wide or per-page via headeres.

Yes, works nicely! Thanks.