- java.lang.Object
-
- io.fixprotocol.md.event.MarkdownUtil
-
public final class MarkdownUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static charBACKTICK_CHARACTERstatic charESCAPE_CHARACTERstatic charLINEFEED_CHARACTERstatic StringMARKDOWN_MEDIA_TYPEstatic StringMARKDOWN_PARAGRAPH_BREAKstatic charPIPE_CHARACTER
-
Constructor Summary
Constructors Constructor Description MarkdownUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringmarkdownLiteralToPlainText(String literal)Translates a markdown literal surrounded by single backtick characters to plain text.static StringplainTextToMarkdown(String text)Translates plaintext to markdown A standard markdown paragraph break is used.static StringplainTextToMarkdown(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 referencesstatic StringplainTextToMarkdownLiteral(String text)Text is surrounded by backtick characters Special characters within the literal are not escaped.static StringstripCell(String str)Trims leading and trailing whitespace or pipe characters, leaving just the text within a markdown table cell.
-
-
-
Field Detail
-
BACKTICK_CHARACTER
public static final char BACKTICK_CHARACTER
- See Also:
- Constant Field Values
-
ESCAPE_CHARACTER
public static final char ESCAPE_CHARACTER
- See Also:
- Constant Field Values
-
LINEFEED_CHARACTER
public static final char LINEFEED_CHARACTER
- See Also:
- Constant Field Values
-
MARKDOWN_MEDIA_TYPE
public static final String MARKDOWN_MEDIA_TYPE
- See Also:
- Constant Field Values
-
MARKDOWN_PARAGRAPH_BREAK
public static final String MARKDOWN_PARAGRAPH_BREAK
- See Also:
- Constant Field Values
-
PIPE_CHARACTER
public static final char PIPE_CHARACTER
- See Also:
- Constant Field Values
-
-
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- ifliteralis 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- plaintextmarkdownParagraphBreak- 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
-
-