Class Utils
java.lang.Object
com.github.rjeschke.txtmark.Utils
Utilities.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final voidappendCode(StringBuilder out, String in, int start, int end) Appends the given string encoding special HTML characters.static final voidappendDecEntity(StringBuilder out, char value) Append the given char as a decimal HTML entity.static final voidappendHexEntity(StringBuilder out, char value) Append the given char as a hexadecimal HTML entity.static final voidappendMailto(StringBuilder out, String in, int start, int end) Appends the given mailto link using obfuscation.static final voidappendValue(StringBuilder out, String in, int start, int end) Appends the given string encoding special HTML characters (used in HTML attribute values).static final voidcodeEncode(StringBuilder out, String value, int offset) Appends the given string to the given StringBuilder, replacing '&', '<' and '>' by their respective HTML entities.static final intescape(StringBuilder out, char ch, int pos) Processed the given escape sequence.static final StringgetMetaFromFence(String fenceLine) Removes trailing`or~and trims spaces.static final voidgetXMLTag(StringBuilder out, String in) Extracts the tag from an XML element.static final voidgetXMLTag(StringBuilder out, StringBuilder in) Extracts the tag from an XML element.static final intreadMdLink(StringBuilder out, String in, int start) Reads a markdown link.static final intreadMdLinkId(StringBuilder out, String in, int start) Reads a markdown link ID.static final intreadRawUntil(StringBuilder out, String in, int start, char end) Reads characters until the end character is encountered, taking care of HTML/XML strings.static final intreadRawUntil(StringBuilder out, String in, int start, char... end) Reads characters until any 'end' character is encountered, ignoring escape sequences.static final intreadUntil(StringBuilder out, String in, int start, char end) Reads characters until the 'end' character is encountered.static final intreadUntil(StringBuilder out, String in, int start, char... end) Reads characters until any 'end' character is encountered.static final intreadXML(StringBuilder out, String in, int start, boolean safeMode) Reads an XML element.static final intreadXMLUntil(StringBuilder out, String in, int start, char... end) Reads characters until any 'end' character is encountered, ignoring escape sequences.static final intrnd()LCG random number generator.static final intskipSpaces(String in, int start) Skips spaces in the given String.
-
Field Details
-
RND
private static int RNDRandom number generator value.
-
-
Constructor Details
-
Utils
Utils()
-
-
Method Details
-
rnd
public static final int rnd()LCG random number generator.- Returns:
- A pseudo random number between 0 and 1023
-
skipSpaces
Skips spaces in the given String.- Parameters:
in- Input String.start- Starting position.- Returns:
- The new position or -1 if EOL has been reached.
-
escape
Processed the given escape sequence.- Parameters:
out- The StringBuilder to write to.ch- The character.pos- Current parsing position.- Returns:
- The new position.
-
readUntil
Reads characters until any 'end' character is encountered.- Parameters:
out- The StringBuilder to write to.in- The Input String.start- Starting position.end- End characters.- Returns:
- The new position or -1 if no 'end' char was found.
-
readUntil
Reads characters until the 'end' character is encountered.- Parameters:
out- The StringBuilder to write to.in- The Input String.start- Starting position.end- End characters.- Returns:
- The new position or -1 if no 'end' char was found.
-
readMdLink
Reads a markdown link.- Parameters:
out- The StringBuilder to write to.in- Input String.start- Starting position.- Returns:
- The new position or -1 if this is no valid markdown link.
-
readMdLinkId
Reads a markdown link ID.- Parameters:
out- The StringBuilder to write to.in- Input String.start- Starting position.- Returns:
- The new position or -1 if this is no valid markdown link ID.
-
readRawUntil
Reads characters until any 'end' character is encountered, ignoring escape sequences.- Parameters:
out- The StringBuilder to write to.in- The Input String.start- Starting position.end- End characters.- Returns:
- The new position or -1 if no 'end' char was found.
-
readRawUntil
Reads characters until the end character is encountered, taking care of HTML/XML strings.- Parameters:
out- The StringBuilder to write to.in- The Input String.start- Starting position.end- End characters.- Returns:
- The new position or -1 if no 'end' char was found.
-
readXMLUntil
Reads characters until any 'end' character is encountered, ignoring escape sequences.- Parameters:
out- The StringBuilder to write to.in- The Input String.start- Starting position.end- End characters.- Returns:
- The new position or -1 if no 'end' char was found.
-
appendCode
Appends the given string encoding special HTML characters.- Parameters:
out- The StringBuilder to write to.in- Input String.start- Input String starting position.end- Input String end position.
-
appendValue
Appends the given string encoding special HTML characters (used in HTML attribute values).- Parameters:
out- The StringBuilder to write to.in- Input String.start- Input String starting position.end- Input String end position.
-
appendDecEntity
Append the given char as a decimal HTML entity.- Parameters:
out- The StringBuilder to write to.value- The character.
-
appendHexEntity
Append the given char as a hexadecimal HTML entity.- Parameters:
out- The StringBuilder to write to.value- The character.
-
appendMailto
Appends the given mailto link using obfuscation.- Parameters:
out- The StringBuilder to write to.in- Input String.start- Input String starting position.end- Input String end position.
-
getXMLTag
Extracts the tag from an XML element.- Parameters:
out- The StringBuilder to write to.in- Input StringBuilder.
-
getXMLTag
Extracts the tag from an XML element.- Parameters:
out- The StringBuilder to write to.in- Input String.
-
readXML
Reads an XML element.- Parameters:
out- The StringBuilder to write to.in- Input String.start- Starting position.safeMode- Whether to escape unsafe HTML tags or not- Returns:
- The new position or -1 if this is no valid XML element.
-
codeEncode
Appends the given string to the given StringBuilder, replacing '&', '<' and '>' by their respective HTML entities.- Parameters:
out- The StringBuilder to append to.value- The string to append.offset- The character offset into value from where to start
-
getMetaFromFence
-