Class Escaping
- java.lang.Object
-
- com.vladsch.flexmark.util.sequence.Escaping
-
public class Escaping extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static @NotNull com.vladsch.flexmark.util.misc.CharPredicateAMP_BACKSLASH_SETstatic StringESCAPABLEstatic StringESCAPABLE_CHARS
-
Constructor Summary
Constructors Constructor Description Escaping()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @NotNull BasedSequencecollapseWhitespace(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper)static @NotNull StringcollapseWhitespace(@NotNull CharSequence s, boolean trim)Collapse regions of multiple white spaces to a single spacestatic @NotNull BasedSequenceescapeHtml(@NotNull BasedSequence s, boolean preserveEntities, @NotNull ReplacedTextMapper textMapper)static StringescapeHtml(@NotNull CharSequence s, boolean preserveEntities)static @NotNull BasedSequencenormalizeEndWithEOL(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper)Normalize eol: embedded \r and \r\n are converted to \nstatic @NotNull StringnormalizeEndWithEOL(@NotNull CharSequence s)Normalize eol: embedded \r and \r\n are converted to \nstatic @NotNull BasedSequencenormalizeEOL(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper)Normalize eol: embedded \r and \r\n are converted to \nstatic @NotNull BasedSequencenormalizeEOL(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper, boolean endWithEOL)Normalize eol: embedded \r and \r\n are converted to \nstatic @NotNull StringnormalizeEOL(@NotNull CharSequence s)Normalize eol: embedded \r and \r\n are converted to \nstatic @NotNull StringnormalizeEOL(@NotNull CharSequence s, boolean endWithEOL)Normalize eol: embedded \r and \r\n are converted to \nstatic @NotNull StringnormalizeReference(@NotNull CharSequence s, boolean changeCase)Normalize the link reference idstatic @NotNull StringnormalizeReferenceChars(@NotNull CharSequence s, boolean changeCase)Get a normalized the link reference id from reference charactersstatic @NotNull Stringobfuscate(@NotNull String email, boolean randomize)e-mail obfuscation from pegdownstatic @NotNull BasedSequencepercentDecodeUrl(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper)static @NotNull StringpercentDecodeUrl(@NotNull CharSequence s)static @NotNull BasedSequencepercentEncodeUrl(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper)static @NotNull StringpercentEncodeUrl(@NotNull CharSequence s)static @NotNull BasedSequenceremoveAll(@NotNull BasedSequence s, @NotNull CharSequence remove, @NotNull ReplacedTextMapper textMapper)Replace entities and backslash escapes with literal characters.static @NotNull BasedSequenceunescape(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper)Replace entities and backslash escapes with literal characters.static @NotNull BasedSequenceunescapeHtml(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper)Replace entities and backslash escapes with literal characters.static @NotNull BasedSequenceunescapeHtml(@NotNull BasedSequence s, @NotNull List<Range> ranges, @NotNull ReplacedTextMapper textMapper)Replace entities and backslash escapes with literal characters.static @NotNull StringunescapeHtml(@NotNull CharSequence s)Replace entities and backslash escapes with literal characters.static @NotNull StringunescapeString(@NotNull CharSequence s)Replace entities and backslash escapes with literal characters.static @NotNull StringunescapeString(@NotNull CharSequence s, boolean unescapeEntities)Replace entities and backslash escapes with literal characters.
-
-
-
Field Detail
-
ESCAPABLE_CHARS
public static final String ESCAPABLE_CHARS
- See Also:
- Constant Field Values
-
ESCAPABLE
public static final String ESCAPABLE
-
AMP_BACKSLASH_SET
@NotNull public static final @NotNull com.vladsch.flexmark.util.misc.CharPredicate AMP_BACKSLASH_SET
-
-
Method Detail
-
escapeHtml
public static String escapeHtml(@NotNull @NotNull CharSequence s, boolean preserveEntities)
-
escapeHtml
@NotNull public static @NotNull BasedSequence escapeHtml(@NotNull @NotNull BasedSequence s, boolean preserveEntities, @NotNull @NotNull ReplacedTextMapper textMapper)
-
unescapeString
@NotNull public static @NotNull String unescapeString(@NotNull @NotNull CharSequence s)
Replace entities and backslash escapes with literal characters.- Parameters:
s- string to un-escape- Returns:
- un-escaped string
-
unescapeString
@NotNull public static @NotNull String unescapeString(@NotNull @NotNull CharSequence s, boolean unescapeEntities)
Replace entities and backslash escapes with literal characters.- Parameters:
s- string to un-escapeunescapeEntities- true if HTML entities are to be unescaped- Returns:
- un-escaped string
-
unescape
@NotNull public static @NotNull BasedSequence unescape(@NotNull @NotNull BasedSequence s, @NotNull @NotNull ReplacedTextMapper textMapper)
Replace entities and backslash escapes with literal characters.- Parameters:
s- based sequence to un-escapetextMapper- replaced text mapper to update for the changed text- Returns:
- un-escaped sequence
-
removeAll
@NotNull public static @NotNull BasedSequence removeAll(@NotNull @NotNull BasedSequence s, @NotNull @NotNull CharSequence remove, @NotNull @NotNull ReplacedTextMapper textMapper)
Replace entities and backslash escapes with literal characters.- Parameters:
s- sequence being changedremove- string to removetextMapper- replaced text mapper to update for the changed text- Returns:
- un-escaped sequence
-
unescapeHtml
@NotNull public static @NotNull String unescapeHtml(@NotNull @NotNull CharSequence s)
Replace entities and backslash escapes with literal characters.- Parameters:
s- string to un-escape- Returns:
- un-escaped string
-
unescapeHtml
@NotNull public static @NotNull BasedSequence unescapeHtml(@NotNull @NotNull BasedSequence s, @NotNull @NotNull ReplacedTextMapper textMapper)
Replace entities and backslash escapes with literal characters.- Parameters:
s- based sequence to un-escapetextMapper- replaced text mapper to update for the changed text- Returns:
- un-escaped sequence
-
unescapeHtml
@NotNull public static @NotNull BasedSequence unescapeHtml(@NotNull @NotNull BasedSequence s, @NotNull @NotNull List<Range> ranges, @NotNull @NotNull ReplacedTextMapper textMapper)
Replace entities and backslash escapes with literal characters.- Parameters:
s- based sequence to un-escapetextMapper- replaced text mapper to update for the changed text- Returns:
- un-escaped sequence
-
normalizeEndWithEOL
@NotNull public static @NotNull String normalizeEndWithEOL(@NotNull @NotNull CharSequence s)
Normalize eol: embedded \r and \r\n are converted to \nAppend EOL sequence if sequence does not already end in EOL
- Parameters:
s- sequence to convert- Returns:
- converted sequence
-
normalizeEOL
@NotNull public static @NotNull String normalizeEOL(@NotNull @NotNull CharSequence s)
Normalize eol: embedded \r and \r\n are converted to \n- Parameters:
s- sequence to convert- Returns:
- converted sequence
-
normalizeEOL
@NotNull public static @NotNull String normalizeEOL(@NotNull @NotNull CharSequence s, boolean endWithEOL)
Normalize eol: embedded \r and \r\n are converted to \n- Parameters:
s- sequence to convertendWithEOL- true if an EOL is to be appended to the end of the sequence if not already ending with one.- Returns:
- converted sequence
-
normalizeEndWithEOL
@NotNull public static @NotNull BasedSequence normalizeEndWithEOL(@NotNull @NotNull BasedSequence s, @NotNull @NotNull ReplacedTextMapper textMapper)
Normalize eol: embedded \r and \r\n are converted to \nAppend EOL sequence if sequence does not already end in EOL
- Parameters:
s- sequence to converttextMapper- text mapper to update for the replaced text- Returns:
- converted sequence
-
normalizeEOL
@NotNull public static @NotNull BasedSequence normalizeEOL(@NotNull @NotNull BasedSequence s, @NotNull @NotNull ReplacedTextMapper textMapper)
Normalize eol: embedded \r and \r\n are converted to \n- Parameters:
s- sequence to converttextMapper- text mapper to update for the replaced text- Returns:
- converted sequence
-
normalizeEOL
@NotNull public static @NotNull BasedSequence normalizeEOL(@NotNull @NotNull BasedSequence s, @NotNull @NotNull ReplacedTextMapper textMapper, boolean endWithEOL)
Normalize eol: embedded \r and \r\n are converted to \nAppend EOL sequence if sequence does not already end in EOL
- Parameters:
s- sequence to converttextMapper- text mapper to update for the replaced textendWithEOL- whether an EOL is to be appended to the end of the sequence if it does not already end with one.- Returns:
- converted sequence
-
percentEncodeUrl
@NotNull public static @NotNull String percentEncodeUrl(@NotNull @NotNull CharSequence s)
- Parameters:
s- string to encode- Returns:
- encoded string
-
percentEncodeUrl
@NotNull public static @NotNull BasedSequence percentEncodeUrl(@NotNull @NotNull BasedSequence s, @NotNull @NotNull ReplacedTextMapper textMapper)
- Parameters:
s- string to encodetextMapper- text mapper to update for the replaced text- Returns:
- encoded string
-
percentDecodeUrl
@NotNull public static @NotNull String percentDecodeUrl(@NotNull @NotNull CharSequence s)
- Parameters:
s- string to encode- Returns:
- encoded string
-
percentDecodeUrl
@NotNull public static @NotNull BasedSequence percentDecodeUrl(@NotNull @NotNull BasedSequence s, @NotNull @NotNull ReplacedTextMapper textMapper)
- Parameters:
s- string to encodetextMapper- text mapper to update for the replaced text- Returns:
- encoded string
-
normalizeReference
@NotNull public static @NotNull String normalizeReference(@NotNull @NotNull CharSequence s, boolean changeCase)
Normalize the link reference id- Parameters:
s- sequence containing the link reference idchangeCase- if true then reference will be converted to lowercase- Returns:
- normalized link reference id
-
obfuscate
@NotNull public static @NotNull String obfuscate(@NotNull @NotNull String email, boolean randomize)
e-mail obfuscation from pegdown- Parameters:
email- e-mail urlrandomize- true to randomize, false for testing- Returns:
- obfuscated e-mail url
-
normalizeReferenceChars
@NotNull public static @NotNull String normalizeReferenceChars(@NotNull @NotNull CharSequence s, boolean changeCase)
Get a normalized the link reference id from reference charactersWill remove leading ![ or [ and trailing ], collapse multiple whitespaces to a space and optionally convert the id to lowercase.
- Parameters:
s- sequence containing the link reference idchangeCase- if true then reference will be converted to lowercase- Returns:
- normalized link reference id
-
collapseWhitespace
@NotNull public static @NotNull String collapseWhitespace(@NotNull @NotNull CharSequence s, boolean trim)
Collapse regions of multiple white spaces to a single space- Parameters:
s- sequence to processtrim- true if the sequence should also be trimmed- Returns:
- processed sequence
-
collapseWhitespace
@NotNull public static @NotNull BasedSequence collapseWhitespace(@NotNull @NotNull BasedSequence s, @NotNull @NotNull ReplacedTextMapper textMapper)
-
-