content icon indicating copy to clipboard operation
content copied to clipboard

Code block markup does not follow recommendations by WHATWG, causes issues with 3rd party plugins

Open testudor opened this issue 1 year ago • 0 comments

Environment


  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.6
  • Package Manager: [email protected]
  • Builder: -
  • User Config: devtools, modules, content
  • Runtime Modules: @nuxt/[email protected]
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-9baaph?file=nuxt.config.ts,content%2Findex.md

Describe the bug

The WHATWG (Web Hypertext Application Technology Working Group) recommends code block markup to be structured as follows:

<pre>
  <code class="language-pascal">
    var i: Integer;
    begin
       i := 1;
    end.
  </code>
</pre>

(taken from https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-code-element)

Nuxt Content uses a different format, where the language-xxx class is placed on the pre element instead. This breaks compatibility with some 3rd party plugins such as https://github.com/remcohaszing/rehype-mermaid. Is there any good reason Nuxt Content does not follow the spec? Please also see the discussion here: https://github.com/remcohaszing/rehype-mermaid/issues/15.

Additional context

No response

Logs

No response

testudor avatar Apr 29 '24 10:04 testudor