Class Escaping
- java.lang.Object
-
- com.vladsch.flexmark.util.sequence.Escaping
-
public class Escaping extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static CharPredicate
AMP_BACKSLASH_SET
static java.lang.String
ESCAPABLE
static java.lang.String
ESCAPABLE_CHARS
-
Constructor Summary
Constructors Constructor Description Escaping()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BasedSequence
collapseWhitespace(BasedSequence s, ReplacedTextMapper textMapper)
static java.lang.String
collapseWhitespace(java.lang.CharSequence s, boolean trim)
Collapse regions of multiple white spaces to a single spacestatic BasedSequence
escapeHtml(BasedSequence s, boolean preserveEntities, ReplacedTextMapper textMapper)
static java.lang.String
escapeHtml(java.lang.CharSequence s, boolean preserveEntities)
static BasedSequence
normalizeEndWithEOL(BasedSequence s, ReplacedTextMapper textMapper)
Normalize eol: embedded \r and \r\n are converted to \nstatic java.lang.String
normalizeEndWithEOL(java.lang.CharSequence s)
Normalize eol: embedded \r and \r\n are converted to \nstatic BasedSequence
normalizeEOL(BasedSequence s, ReplacedTextMapper textMapper)
Normalize eol: embedded \r and \r\n are converted to \nstatic BasedSequence
normalizeEOL(BasedSequence s, ReplacedTextMapper textMapper, boolean endWithEOL)
Normalize eol: embedded \r and \r\n are converted to \nstatic java.lang.String
normalizeEOL(java.lang.CharSequence s)
Normalize eol: embedded \r and \r\n are converted to \nstatic java.lang.String
normalizeEOL(java.lang.CharSequence s, boolean endWithEOL)
Normalize eol: embedded \r and \r\n are converted to \nstatic java.lang.String
normalizeReference(java.lang.CharSequence s, boolean changeCase)
Normalize the link reference idstatic java.lang.String
normalizeReferenceChars(java.lang.CharSequence s, boolean changeCase)
Get a normalized the link reference id from reference charactersstatic java.lang.String
obfuscate(java.lang.String email, boolean randomize)
e-mail obfuscation from pegdownstatic BasedSequence
percentDecodeUrl(BasedSequence s, ReplacedTextMapper textMapper)
static java.lang.String
percentDecodeUrl(java.lang.CharSequence s)
static BasedSequence
percentEncodeUrl(BasedSequence s, ReplacedTextMapper textMapper)
static java.lang.String
percentEncodeUrl(java.lang.CharSequence s)
static BasedSequence
removeAll(BasedSequence s, java.lang.CharSequence remove, ReplacedTextMapper textMapper)
Replace entities and backslash escapes with literal characters.static BasedSequence
unescape(BasedSequence s, ReplacedTextMapper textMapper)
Replace entities and backslash escapes with literal characters.static BasedSequence
unescapeHtml(BasedSequence s, ReplacedTextMapper textMapper)
Replace entities and backslash escapes with literal characters.static BasedSequence
unescapeHtml(BasedSequence s, java.util.List<Range> ranges, ReplacedTextMapper textMapper)
Replace entities and backslash escapes with literal characters.static java.lang.String
unescapeHtml(java.lang.CharSequence s)
Replace entities and backslash escapes with literal characters.static java.lang.String
unescapeString(java.lang.CharSequence s)
Replace entities and backslash escapes with literal characters.static java.lang.String
unescapeString(java.lang.CharSequence s, boolean unescapeEntities)
Replace entities and backslash escapes with literal characters.
-
-
-
Field Detail
-
ESCAPABLE_CHARS
public static final java.lang.String ESCAPABLE_CHARS
- See Also:
- Constant Field Values
-
ESCAPABLE
public static final java.lang.String ESCAPABLE
-
AMP_BACKSLASH_SET
@NotNull public static final CharPredicate AMP_BACKSLASH_SET
-
-
Method Detail
-
escapeHtml
public static java.lang.String escapeHtml(@NotNull java.lang.CharSequence s, boolean preserveEntities)
-
escapeHtml
@NotNull public static BasedSequence escapeHtml(@NotNull BasedSequence s, boolean preserveEntities, @NotNull ReplacedTextMapper textMapper)
-
unescapeString
@NotNull public static java.lang.String unescapeString(@NotNull java.lang.CharSequence s)
Replace entities and backslash escapes with literal characters.- Parameters:
s
- string to un-escape- Returns:
- un-escaped string
-
unescapeString
@NotNull public static java.lang.String unescapeString(@NotNull java.lang.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 BasedSequence unescape(@NotNull BasedSequence s, @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 BasedSequence removeAll(@NotNull BasedSequence s, @NotNull java.lang.CharSequence remove, @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 java.lang.String unescapeHtml(@NotNull java.lang.CharSequence s)
Replace entities and backslash escapes with literal characters.- Parameters:
s
- string to un-escape- Returns:
- un-escaped string
-
unescapeHtml
@NotNull public static BasedSequence unescapeHtml(@NotNull BasedSequence s, @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 BasedSequence unescapeHtml(@NotNull BasedSequence s, @NotNull java.util.List<Range> ranges, @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 java.lang.String normalizeEndWithEOL(@NotNull java.lang.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 java.lang.String normalizeEOL(@NotNull java.lang.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 java.lang.String normalizeEOL(@NotNull java.lang.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 BasedSequence normalizeEndWithEOL(@NotNull BasedSequence s, @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 BasedSequence normalizeEOL(@NotNull BasedSequence s, @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 BasedSequence normalizeEOL(@NotNull BasedSequence s, @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 java.lang.String percentEncodeUrl(@NotNull java.lang.CharSequence s)
- Parameters:
s
- string to encode- Returns:
- encoded string
-
percentEncodeUrl
@NotNull public static BasedSequence percentEncodeUrl(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper)
- Parameters:
s
- string to encodetextMapper
- text mapper to update for the replaced text- Returns:
- encoded string
-
percentDecodeUrl
@NotNull public static java.lang.String percentDecodeUrl(@NotNull java.lang.CharSequence s)
- Parameters:
s
- string to encode- Returns:
- encoded string
-
percentDecodeUrl
@NotNull public static BasedSequence percentDecodeUrl(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper)
- Parameters:
s
- string to encodetextMapper
- text mapper to update for the replaced text- Returns:
- encoded string
-
normalizeReference
@NotNull public static java.lang.String normalizeReference(@NotNull java.lang.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 java.lang.String obfuscate(@NotNull java.lang.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 java.lang.String normalizeReferenceChars(@NotNull java.lang.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 java.lang.String collapseWhitespace(@NotNull java.lang.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 BasedSequence collapseWhitespace(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper)
-
-