Class Escaping
java.lang.Object
com.vladsch.flexmark.util.sequence.Escaping
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final @NotNull CharPredicate
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern
private static final Escaping.Replacer
private static final String
private static final Pattern
private static final Pattern
private static final Escaping.Replacer
static final String
static final String
private static final Pattern
private static final Pattern
private static final Pattern
(package private) static final char[]
private static Random
private static final Escaping.Replacer
private static final Escaping.Replacer
private static final Escaping.Replacer
private static final Escaping.Replacer
private static final Escaping.Replacer
private static final Pattern
private static final String
private static final Pattern
private static final Pattern
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull BasedSequence
collapseWhitespace
(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) static @NotNull String
collapseWhitespace
(@NotNull CharSequence s, boolean trim) Collapse regions of multiple white spaces to a single spaceprivate static @Nullable String
encode
(char c) static @NotNull BasedSequence
escapeHtml
(@NotNull BasedSequence s, boolean preserveEntities, @NotNull ReplacedTextMapper textMapper) static String
escapeHtml
(@NotNull CharSequence s, boolean preserveEntities) static @NotNull BasedSequence
normalizeEndWithEOL
(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) Normalize eol: embedded \r and \r\n are converted to \nstatic @NotNull String
normalizeEndWithEOL
(@NotNull CharSequence s) Normalize eol: embedded \r and \r\n are converted to \nstatic @NotNull BasedSequence
normalizeEOL
(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) Normalize eol: embedded \r and \r\n are converted to \nstatic @NotNull BasedSequence
normalizeEOL
(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper, boolean endWithEOL) Normalize eol: embedded \r and \r\n are converted to \nstatic @NotNull String
normalizeEOL
(@NotNull CharSequence s) Normalize eol: embedded \r and \r\n are converted to \nstatic @NotNull String
normalizeEOL
(@NotNull CharSequence s, boolean endWithEOL) Normalize eol: embedded \r and \r\n are converted to \nstatic @NotNull String
normalizeReference
(@NotNull CharSequence s, boolean changeCase) Normalize the link reference idstatic @NotNull String
normalizeReferenceChars
(@NotNull CharSequence s, boolean changeCase) Get a normalized the link reference id from reference charactersstatic @NotNull String
e-mail obfuscation from pegdownstatic @NotNull BasedSequence
percentDecodeUrl
(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) static @NotNull String
percentDecodeUrl
(@NotNull CharSequence s) static @NotNull BasedSequence
percentEncodeUrl
(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) static @NotNull String
percentEncodeUrl
(@NotNull CharSequence s) static @NotNull BasedSequence
removeAll
(@NotNull BasedSequence s, @NotNull CharSequence remove, @NotNull ReplacedTextMapper textMapper) Replace entities and backslash escapes with literal characters.private static @NotNull BasedSequence
replaceAll
(@NotNull Pattern p, @NotNull BasedSequence s, int startOffset, int endOffset, @NotNull Escaping.Replacer replacer, @NotNull ReplacedTextMapper textMapper) private static @NotNull BasedSequence
replaceAll
(@NotNull Pattern p, @NotNull BasedSequence s, @NotNull Escaping.Replacer replacer, @NotNull ReplacedTextMapper textMapper) private static @NotNull BasedSequence
replaceAll
(@NotNull Pattern p, @NotNull BasedSequence s, @NotNull List<Range> ranges, @NotNull Escaping.Replacer replacer, @NotNull ReplacedTextMapper textMapper) private static @NotNull String
replaceAll
(@NotNull Pattern p, @NotNull CharSequence s, @NotNull Escaping.Replacer replacer) static @NotNull BasedSequence
unescape
(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) Replace entities and backslash escapes with literal characters.static @NotNull BasedSequence
unescapeHtml
(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) Replace entities and backslash escapes with literal characters.static @NotNull BasedSequence
unescapeHtml
(@NotNull BasedSequence s, @NotNull List<Range> ranges, @NotNull ReplacedTextMapper textMapper) Replace entities and backslash escapes with literal characters.static @NotNull String
unescapeHtml
(@NotNull CharSequence s) Replace entities and backslash escapes with literal characters.static @NotNull String
unescapeString
(@NotNull CharSequence s) Replace entities and backslash escapes with literal characters.static @NotNull String
unescapeString
(@NotNull CharSequence s, boolean unescapeEntities) Replace entities and backslash escapes with literal characters.
-
Field Details
-
ESCAPABLE_CHARS
- See Also:
-
ESCAPABLE
-
ENTITY
- See Also:
-
BACKSLASH_ONLY
-
ESCAPED_CHAR
-
BACKSLASH_OR_AMP
-
AMP_ONLY
-
ENTITY_OR_ESCAPED_CHAR
-
ENTITY_ONLY
-
XML_SPECIAL
- See Also:
-
XML_SPECIAL_RE
-
XML_SPECIAL_OR_ENTITY
-
ESCAPE_IN_URI
-
ESCAPE_URI_DECODE
-
HEX_DIGITS
static final char[] HEX_DIGITS -
WHITESPACE
-
COLLAPSE_WHITESPACE
-
UNSAFE_CHAR_REPLACER
-
COLLAPSE_WHITESPACE_REPLACER
-
UNESCAPE_REPLACER
-
REMOVE_REPLACER
-
ENTITY_REPLACER
-
URL_ENCODE_REPLACER
-
URL_DECODE_REPLACER
-
AMP_BACKSLASH_SET
-
random
-
-
Constructor Details
-
Escaping
public Escaping()
-
-
Method Details
-
escapeHtml
-
escapeHtml
@NotNull public static @NotNull BasedSequence escapeHtml(@NotNull @NotNull BasedSequence s, boolean preserveEntities, @NotNull @NotNull ReplacedTextMapper textMapper) -
unescapeString
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
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
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
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
- 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
- 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
-
encode
-
obfuscate
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) -
replaceAll
@NotNull private static @NotNull String replaceAll(@NotNull @NotNull Pattern p, @NotNull @NotNull CharSequence s, @NotNull @NotNull Escaping.Replacer replacer) -
replaceAll
@NotNull private static @NotNull BasedSequence replaceAll(@NotNull @NotNull Pattern p, @NotNull @NotNull BasedSequence s, @NotNull @NotNull Escaping.Replacer replacer, @NotNull @NotNull ReplacedTextMapper textMapper) -
replaceAll
@NotNull private static @NotNull BasedSequence replaceAll(@NotNull @NotNull Pattern p, @NotNull @NotNull BasedSequence s, int startOffset, int endOffset, @NotNull @NotNull Escaping.Replacer replacer, @NotNull @NotNull ReplacedTextMapper textMapper) -
replaceAll
@NotNull private static @NotNull BasedSequence replaceAll(@NotNull @NotNull Pattern p, @NotNull @NotNull BasedSequence s, @NotNull @NotNull List<Range> ranges, @NotNull @NotNull Escaping.Replacer replacer, @NotNull @NotNull ReplacedTextMapper textMapper)
-