Class MarkDownLiteral

java.lang.Object
com.yetnt.utils.builders.MarkDownLiteral

public final class MarkDownLiteral extends Object
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
  • Field Details

  • Constructor Details

    • MarkDownLiteral

      public MarkDownLiteral(String input)
  • Method Details

    • bold

      public MarkDownLiteral bold()
      Applies bold formatting to the literal.
      Returns:
      The current MarkDownLiteral instance for chaining.
    • italics

      public MarkDownLiteral italics()
      Applies italics formatting to the literal.
      Returns:
      The current MarkDownLiteral instance for chaining.
    • inlineCode

      public MarkDownLiteral inlineCode()
      Applies inline code formatting to the literal.
      Returns:
      The current MarkDownLiteral instance for chaining.
    • blockQuote

      public MarkDownLiteral blockQuote()
      Applies blockquote formatting to the literal.
      Returns:
      The current MarkDownLiteral instance for chaining.
    • linkTo

      public MarkDownLiteral linkTo(String URL)
      Converts the literal into a Markdown link.
      Parameters:
      URL - The URL to link to.
      Returns:
      The current MarkDownLiteral instance for chaining.
    • title

      public MarkDownLiteral title(int amt)
      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

      public MarkDownLiteral title(MarkDownLiteral.Title title)
      Applies a title (heading) formatting based on a MarkDownLiteral.Title enum.
      Parameters:
      title - The MarkDownLiteral.Title enum representing the heading level.
      Returns:
      The current MarkDownLiteral instance for chaining.
    • comment

      public MarkDownLiteral comment()
      Wraps the literal in an HTML comment.
      Returns:
      The current MarkDownLiteral instance for chaining.
    • asCodeBlock

      public static ArrayList<String> asCodeBlock(ArrayList<String> input, String languageIdentifier)
      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

      public static ArrayList<String> GithubBlockQuote(MarkDownLiteral.GithubBlockQuote top, String str)
      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

      public static ArrayList<String> asList(ArrayList<String> str)
      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

      public static ArrayList<String> asBlockQuote(ArrayList<String> str)
      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

      public String toString()
      Returns the complete Markdown literal as a single string.
      Overrides:
      toString in class Object