Package: org.codehaus.groovy.tools.groovydoc

## [Java] Class MarkdownRenderer

- org.codehaus.groovy.tools.groovydoc.MarkdownRenderer

-     public final class MarkdownRenderer
      extends Object

  GROOVY-11542: support for JEP 467 Markdown documentation comments (triple-slash `///} runs, captured by {@link org.apache.groovy.antlr.GroovydocVisitor`).

  Two concerns are kept here:

  - Splitting a raw comment body into its Markdown body (the prose) and its Javadoc block-tag trail (`@param`, `@return`, …). Block-tag detection matches Javadoc's JEP 467 rule: a line is a block tag when its first non-blank character is `@`, it is not inside a fenced code block (````` /`~~~`), and the `@` is followed by a tag word (an ASCII letter).
  - Rendering the Markdown body to HTML. Headings are shifted down by two levels (`#` ? `<h3>`, `##` ? `<h4>`, …) so they slot under the class/member page's own `<h1>` and `<h2>` structure, matching Javadoc's layout.

  The renderer is stateless and thread-safe; a single org.commonmark.parser.Parser + org.commonmark.renderer.html.HtmlRenderer pair is cached per class.

  Since:
    6.0.0

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static String` | `render(String markdownBody)` Render a Markdown body to HTML and shift heading levels down so that JEP 467 top-level headings (`#`) become `<h3>`, fitting under the page's existing `<h1>`/`<h2>` structure.
    `` | `public static String[]` | `splitBodyAndTags(String raw)` Split a raw comment body (already stripped of {@code ///} prefixes) into its Markdown body and block-tag trail.
    `` | `public static String` | `unmaskBracesInCode(String html)` Translate the `\u0001` / `\u0002` placeholders left inside code spans / code blocks by render(String) back to literal `{` / `}` numeric HTML entities, so browsers display them as `{} and {@code }` while keeping the content distinguishable from tag syntax.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### public static String render(String markdownBody)

      Render a Markdown body to HTML and shift heading levels down so that JEP 467 top-level headings (`#`) become `<h3>`, fitting under the page's existing `<h1>`/`<h2>` structure.

    - #### public static String[] splitBodyAndTags(String raw)

      Split a raw comment body (already stripped of {@code ///} prefixes) into its Markdown body and block-tag trail. Returns a two-element array `[body, tags]`; either may be empty.

    - #### public static String unmaskBracesInCode(String html)

      Translate the `\u0001` / `\u0002` placeholders left inside code spans / code blocks by render(String) back to literal `{` / `}` numeric HTML entities, so browsers display them as `{} and {@code }` while keeping the content distinguishable from tag syntax. Called after `TagRenderer` has run so inline-tag expansion has already skipped over them.