Search code examples
phpmarkdowngithub-flavored-markdowngravcustom-attribute

Adding custom attribute in Grav markdown content breaks it


Grav & markdown question here.

In PHP Markdown Extra, Michel Fortin writes that we can use this kind of syntax:

## The Site ##      {.principal .eclat #le-site lang=en}

to add classes, id & custom attributes to an element (in this example, a heading).

But I can't find a mention of this in Github Flavoured Markdown doc or Grav doc.

And if adding a class or id is totally working in my Grav installation, adding a custom attribute is not. In fact it breaks my heading.

# My title {.my-class1 .my-class2 #my-id}

compiles perfectly to

<h1 class="my-class1 my-class2" id="my-id">My title</h1>

but

# My title {.my-class1 .my-class2 #my-id lang=fr}

compiles to

<h1>My title {.my-class1 .my-class2 #my-id lang=fr}</h1>

as if it was not recognized…

Is someone having the same problem as I?

Note: the Markdown Extra plugin is installed & activated.

Thanks in advance!


Solution

  • The parsedown extra processor was not updated since two years and the proposed fixes aren't committed, so you can only use the class and the id shortcuts. See https://github.com/erusev/parsedown-extra/issues/100.