public final class MarkdownRenderer
extends Object
GROOVY-11542: support for JEP 467 Markdown documentation comments
(triple-slash /// runs, captured by GroovydocVisitor).
Two concerns are kept here:
@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).# → <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.
| 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 /// 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 } while keeping the content
distinguishable from tag syntax. |
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.
Split a raw comment body (already stripped of /// prefixes)
into its Markdown body and block-tag trail. Returns a two-element
array [body, tags]; either may be empty.
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 } while keeping the content
distinguishable from tag syntax. Called after TagRenderer has
run so inline-tag expansion has already skipped over them.