Package com.yetnt.utils.builders
Class MarkDownLiteral
java.lang.Object
com.yetnt.utils.builders.MarkDownLiteral
Another builder bloody class specifically for the purposes of building markdown strings
Example usage:
MarkDownLiteral md = new MarkDownLiteral("MARK")
.inlineCode()
.title(MarkDownLiteral.Title.SUBSECTION);
Parses as:
MARK
From Jaiva!
- Author:
- Lehlogonolo Poole
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum representing different types of GitHub-style blockquote alerts.static enumEnum representing different levels of Markdown headings (titles). -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasBlockQuote(ArrayList<String> str) Converts a list of strings into a Markdown blockquote.asCodeBlock(ArrayList<String> input, String languageIdentifier) Wraps the input list of strings in a Markdown code block with the specified language.Converts a list of strings into a Markdown unordered list.Converts headers and rows into a Markdown table format.Applies blockquote formatting to the literal.bold()Applies bold formatting to the literal.comment()Wraps the literal in an HTML comment.Creates a GitHub-style blockquote with a specific alert type.Applies inline code formatting to the literal.italics()Applies italics formatting to the literal.Converts the literal into a Markdown link.title(int amt) Applies a title (heading) formatting based on a numerical level.title(MarkDownLiteral.Title title) Applies a title (heading) formatting based on aMarkDownLiteral.Titleenum.toString()Returns the complete Markdown literal as a single string.
-
Field Details
-
literal
A Deque to store the parts of the Markdown literal, allowing for easy addition of formatting. -
CHECKBOX
- See Also:
-
XCHECKBOX
- See Also:
-
BQUOTE
- See Also:
-
-
Constructor Details
-
MarkDownLiteral
-
-
Method Details
-
bold
Applies bold formatting to the literal.- Returns:
- The current MarkDownLiteral instance for chaining.
-
italics
Applies italics formatting to the literal.- Returns:
- The current MarkDownLiteral instance for chaining.
-
inlineCode
Applies inline code formatting to the literal.- Returns:
- The current MarkDownLiteral instance for chaining.
-
blockQuote
Applies blockquote formatting to the literal.- Returns:
- The current MarkDownLiteral instance for chaining.
-
linkTo
Converts the literal into a Markdown link.- Parameters:
URL- The URL to link to.- Returns:
- The current MarkDownLiteral instance for chaining.
-
title
Applies a title (heading) formatting based on a numerical level.- Parameters:
amt- The heading level (1-6).- Returns:
- The current MarkDownLiteral instance for chaining.
-
title
Applies a title (heading) formatting based on aMarkDownLiteral.Titleenum.- Parameters:
title- TheMarkDownLiteral.Titleenum representing the heading level.- Returns:
- The current MarkDownLiteral instance for chaining.
-
comment
Wraps the literal in an HTML comment.- Returns:
- The current MarkDownLiteral instance for chaining.
-
asCodeBlock
Wraps the input list of strings in a Markdown code block with the specified language.- Parameters:
input- The list of strings to be wrapped.languageIdentifier- The language identifier for the code block.- Returns:
- An ArrayList of strings representing the formatted code block.
-
asTable
public static ArrayList<String> asTable(ArrayList<String> headers, ArrayList<ArrayList<String>> rows) Converts headers and rows into a Markdown table format.- Parameters:
headers- The list of header strings.rows- The list of rows, where each row is a list of strings.- Returns:
- An ArrayList of strings representing the formatted Markdown table.
-
GithubBlockQuote
Creates a GitHub-style blockquote with a specific alert type.- Parameters:
top- The type of GitHub blockquote (e.g., WARNING, NOTE).str- The content of the blockquote.- Returns:
- An ArrayList of strings representing the formatted GitHub blockquote.
-
asList
Converts a list of strings into a Markdown unordered list.- Parameters:
str- The ArrayList of strings to convert.- Returns:
- An ArrayList of strings, where each string is prefixed with "- ".
-
asBlockQuote
Converts a list of strings into a Markdown blockquote.- Parameters:
str- The ArrayList of strings to convert.- Returns:
- An ArrayList of strings, where each string is prefixed with "> ".
-
toString
Returns the complete Markdown literal as a single string.
-