Package net.dv8tion.jda.api.utils
Class MarkdownUtil
- java.lang.Object
-
- net.dv8tion.jda.api.utils.MarkdownUtil
-
public final class MarkdownUtil extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
bold(java.lang.String input)
Escapes already existing bold regions in the input and applies bold formatting to the entire string.static java.lang.String
codeblock(java.lang.String input)
Escapes already existing codeblock regions in the input and applies codeblock formatting to the entire string.static java.lang.String
codeblock(java.lang.String language, java.lang.String input)
Escapes already existing codeblock regions in the input and applies codeblock formatting to the entire string.static java.lang.String
italics(java.lang.String input)
Escapes already existing italics (with underscore) regions in the input and applies italics formatting to the entire string.static java.lang.String
maskedLink(java.lang.String text, java.lang.String url)
Creates a masked link with the provided url as target.static java.lang.String
monospace(java.lang.String input)
Escapes already existing monospace (single backtick) regions in the input and applies monospace formatting to the entire string.static java.lang.String
quote(java.lang.String input)
Escapes already existing quote regions in the input and applies quote formatting to the entire string.static java.lang.String
quoteBlock(java.lang.String input)
Applies quote block formatting to the entire string.static java.lang.String
spoiler(java.lang.String input)
Escapes already existing spoiler regions in the input and applies spoiler formatting to the entire string.static java.lang.String
strike(java.lang.String input)
Escapes already existing strike regions in the input and applies strike formatting to the entire string.static java.lang.String
underline(java.lang.String input)
Escapes already existing underline regions in the input and applies underline formatting to the entire string.
-
-
-
Method Detail
-
bold
@Nonnull public static java.lang.String bold(@Nonnull java.lang.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 java.lang.String italics(@Nonnull java.lang.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 java.lang.String underline(@Nonnull java.lang.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 java.lang.String monospace(@Nonnull java.lang.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 java.lang.String codeblock(@Nonnull java.lang.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 java.lang.String codeblock(@Nullable java.lang.String language, @Nonnull java.lang.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 java.lang.String spoiler(@Nonnull java.lang.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 java.lang.String strike(@Nonnull java.lang.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 java.lang.String quote(@Nonnull java.lang.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 java.lang.String quoteBlock(@Nonnull java.lang.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 java.lang.String maskedLink(@Nonnull java.lang.String text, @Nonnull java.lang.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 displayurl
- The target url- Returns:
- The resulting output
-
-