Class MarkdownRenderer

java.lang.Object
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 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 Parser + HtmlRenderer pair is cached per class.

  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    static String[]
    Split a raw comment body (already stripped of /// prefixes) into its Markdown body and block-tag trail.
    static String
    Translate the  /  placeholders left inside code spans / code blocks by render(String) back to literal &#123; / &#125; numeric HTML entities, so browsers display them as {} and {@code } while keeping the content distinguishable from tag syntax.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • splitBodyAndTags

      public static String[] splitBodyAndTags(String raw)
      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.
    • render

      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.
    • unmaskBracesInCode

      public static String unmaskBracesInCode(String html)
      Translate the  /  placeholders left inside code spans / code blocks by render(String) back to literal &#123; / &#125; 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.