File tree Expand file tree Collapse file tree
commonmark/src/main/java/org/commonmark/internal/inline Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import java .util .Collections ;
44import java .util .Set ;
5- import java .util .regex .Pattern ;
6- import org .commonmark .internal .util .Escaping ;
75import org .commonmark .node .HardLineBreak ;
86import org .commonmark .node .Text ;
97import org .commonmark .parser .beta .*;
8+ import org .commonmark .text .AsciiMatcher ;
109
1110/**
1211 * Parse a backslash-escaped special character, adding either the escaped character, a hard line
1514 */
1615public class BackslashInlineParser implements InlineContentParser {
1716
18- private static final Pattern ESCAPABLE = Pattern .compile ('^' + Escaping .ESCAPABLE );
17+ // The characters matched by Escaping.ESCAPABLE (ASCII punctuation)
18+ private static final AsciiMatcher ESCAPABLE =
19+ AsciiMatcher .builder ()
20+ .anyOf ("!\" #$%&'()*+,./:;<=>?@[\\ ]^_`{|}~-" )
21+ .build ();
1922
2023 @ Override
2124 public ParsedInline tryParse (InlineParserState inlineParserState ) {
@@ -27,7 +30,7 @@ public ParsedInline tryParse(InlineParserState inlineParserState) {
2730 if (next == '\n' ) {
2831 scanner .next ();
2932 return ParsedInline .of (new HardLineBreak (), scanner .position ());
30- } else if (ESCAPABLE .matcher ( String . valueOf ( next )). matches ()) {
33+ } else if (ESCAPABLE .matches (next )) {
3134 scanner .next ();
3235 return ParsedInline .of (new Text (String .valueOf (next )), scanner .position ());
3336 } else {
You can’t perform that action at this time.
0 commit comments