Class MarkdownUtil

java.lang.Object
net.dv8tion.jda.api.utils.MarkdownUtil

public final class MarkdownUtil extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    bold(String input)
    Escapes already existing bold regions in the input and applies bold formatting to the entire string.
    static String
    Escapes already existing codeblock regions in the input and applies codeblock formatting to the entire string.
    static String
    codeblock(String language, String input)
    Escapes already existing codeblock regions in the input and applies codeblock formatting to the entire string.
    static String
    italics(String input)
    Escapes already existing italics (with underscore) regions in the input and applies italics formatting to the entire string.
    static String
    maskedLink(String text, String url)
    Creates a masked link with the provided url as target.
    static String
    Escapes already existing monospace (single backtick) regions in the input and applies monospace formatting to the entire string.
    static String
    quote(String input)
    Escapes already existing quote regions in the input and applies quote formatting to the entire string.
    static String
    Applies quote block formatting to the entire string.
    static String
    spoiler(String input)
    Escapes already existing spoiler regions in the input and applies spoiler formatting to the entire string.
    static String
    strike(String input)
    Escapes already existing strike regions in the input and applies strike formatting to the entire string.
    static String
    Escapes already existing underline regions in the input and applies underline formatting to the entire string.

    Methods inherited from class java.lang.Object

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

    • bold

      @Nonnull public static String bold(@Nonnull String input)
      Escapes already existing bold regions in the input and applies bold formatting to the entire string.
      The resulting string will be "**" + escaped(input) + "**".
      Parameters:
      input - The input to bold
      Returns:
      The resulting output
    • italics

      @Nonnull public static String italics(@Nonnull String input)
      Escapes already existing italics (with underscore) regions in the input and applies italics formatting to the entire string.
      The resulting string will be "_" + escaped(input) + "_".
      Parameters:
      input - The input to italics
      Returns:
      The resulting output
    • underline

      @Nonnull public static String underline(@Nonnull String input)
      Escapes already existing underline regions in the input and applies underline formatting to the entire string.
      The resulting string will be "__" + escaped(input) + "__".
      Parameters:
      input - The input to underline
      Returns:
      The resulting output
    • monospace

      @Nonnull public static String monospace(@Nonnull String input)
      Escapes already existing monospace (single backtick) regions in the input and applies monospace formatting to the entire string.
      The resulting string will be "`" + escaped(input) + "`".
      Parameters:
      input - The input to monospace
      Returns:
      The resulting output
    • codeblock

      @Nonnull public static String codeblock(@Nonnull String input)
      Escapes already existing codeblock regions in the input and applies codeblock formatting to the entire string.
      The resulting string will be "```" + escaped(input) + "```".
      Parameters:
      input - The input to codeblock
      Returns:
      The resulting output
    • codeblock

      @Nonnull public static String codeblock(@Nullable String language, @Nonnull String input)
      Escapes already existing codeblock regions in the input and applies codeblock formatting to the entire string.
      The resulting string will be "```" + language + "\n" + escaped(input) + "```".
      Parameters:
      language - The language to use for syntax highlighting (null to use no language)
      input - The input to codeblock
      Returns:
      The resulting output
    • spoiler

      @Nonnull public static String spoiler(@Nonnull String input)
      Escapes already existing spoiler regions in the input and applies spoiler formatting to the entire string.
      The resulting string will be "||" + escaped(input) + "||".
      Parameters:
      input - The input to spoiler
      Returns:
      The resulting output
    • strike

      @Nonnull public static String strike(@Nonnull String input)
      Escapes already existing strike regions in the input and applies strike formatting to the entire string.
      The resulting string will be "~~" + escaped(input) + "~~".
      Parameters:
      input - The input to strike
      Returns:
      The resulting output
    • quote

      @Nonnull public static String quote(@Nonnull String input)
      Escapes already existing quote regions in the input and applies quote formatting to the entire string.
      The resulting string will be "> " + escaped(input).replace("\n", "\n> ").
      Parameters:
      input - The input to quote
      Returns:
      The resulting output
    • quoteBlock

      @Nonnull public static String quoteBlock(@Nonnull String input)
      Applies quote block formatting to the entire string.
      The resulting string will be ">>> " + input.
      Parameters:
      input - The input to quote block
      Returns:
      The resulting output
    • maskedLink

      @Nonnull public static String maskedLink(@Nonnull String text, @Nonnull String url)
      Creates a masked link with the provided url as target.
      This will replace any closing parentheses (in the url) with the url encoded equivalent and replace closing square brackets with their escaped equivalent.
      Parameters:
      text - The text to display
      url - The target url
      Returns:
      The resulting output