commonmark-java icon indicating copy to clipboard operation
commonmark-java copied to clipboard

Escaping contents tabs

Open talwgx opened this issue 6 months ago • 0 comments

Steps to reproduce the problem (provide example Markdown if applicable):

Try to load and render an example from: https://squidfunk.github.io/mkdocs-material/reference/content-tabs/

The CoreMarkdownNodeRenderer.visit(Text text) method will escape it and prevent the content tabs from rendering correctly because it suspects them to be Setext Headers, the comment says: "Would be ambiguous with a Setext heading, escape"

https://github.com/commonmark/commonmark-java/blob/7d12b6fa1aa29397cf74299a5c7cced47496ee63/commonmark/src/main/java/org/commonmark/renderer/markdown/CoreMarkdownNodeRenderer.java#L369

Is it possible to allow the content tab headers to render correctly without being escaped?

=== "C"

    ``` c
    #include <stdio.h>

    int main(void) {
      printf("Hello world!\n");
      return 0;
    }
    ```

=== "C++"

    ``` c++
    #include <iostream>

    int main(void) {
      std::cout << "Hello world!" << std::endl;
      return 0;
    }
    ```

Expected behavior:

expected HTML

Actual behavior:

actual HTML

(Also see what the reference implementation does: https://spec.commonmark.org/dingus/)

talwgx avatar Aug 26 '24 22:08 talwgx