Module md.grammar

Class MarkdownUtil


  • public final class MarkdownUtil
    extends Object
    • Constructor Detail

      • MarkdownUtil

        public MarkdownUtil()
    • Method Detail

      • markdownLiteralToPlainText

        public static String markdownLiteralToPlainText​(String literal)
        Translates a markdown literal surrounded by single backtick characters to plain text. Any characters prior to the first backtick or after the last one are ignored. If backticks are not present, the whole string is passed through.
        Parameters:
        literal - a markdown literal
        Returns:
        unescaped plain text
        Throws:
        NullPointerException - if literal is null
      • plainTextToMarkdown

        public static String plainTextToMarkdown​(String text)
        Translates plaintext to markdown A standard markdown paragraph break is used.
        Parameters:
        text - plaintext
        Returns:
        a markdown string
        See Also:
        plainTextToMarkdown(String, String)
      • plainTextToMarkdown

        public static String plainTextToMarkdown​(String text,
                                                 String markdownParagraphBreak)
        Translates plaintext to markdown
        • Leading and trailing whitespace is removed
        • Escape these characters: pipe '|'
        • Convert linefeed to specified paragraph break token
        • Pass through XML/HTML entity references
        Parameters:
        text - plaintext
        markdownParagraphBreak - token to use for paragraph break in markdown
        Returns:
        a markdown string
      • plainTextToMarkdownLiteral

        public static String plainTextToMarkdownLiteral​(String text)
        Text is surrounded by backtick characters Special characters within the literal are not escaped.
        Parameters:
        text - plain text
        Returns:
        a markdown literal
      • stripCell

        public static String stripCell​(String str)
        Trims leading and trailing whitespace or pipe characters, leaving just the text within a markdown table cell.
        Parameters:
        str - string to strip
        Returns:
        a string without leading or trailing whitespace, or null if the parameter is null