Some performance improvement on delimiter syntaxes (dart-lang/markdown#485)
diff --git a/pkgs/markdown/lib/src/inline_syntaxes/emphasis_syntax.dart b/pkgs/markdown/lib/src/inline_syntaxes/emphasis_syntax.dart index 9a70b17..58f2e70 100644 --- a/pkgs/markdown/lib/src/inline_syntaxes/emphasis_syntax.dart +++ b/pkgs/markdown/lib/src/inline_syntaxes/emphasis_syntax.dart
@@ -2,12 +2,18 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import '../charcode.dart'; import 'delimiter_syntax.dart'; class EmphasisSyntax extends DelimiterSyntax { /// Parses `__strong__` and `_emphasis_`. EmphasisSyntax.underscore() - : super('_+', requiresDelimiterRun: true, tags: _tags); + : super( + '_+', + requiresDelimiterRun: true, + tags: _tags, + startCharacter: $underscore, + ); /// Parses `**strong**` and `*emphasis*`. EmphasisSyntax.asterisk() @@ -16,6 +22,7 @@ requiresDelimiterRun: true, allowIntraWord: true, tags: _tags, + startCharacter: $asterisk, ); static final _tags = [DelimiterTag('em', 1), DelimiterTag('strong', 2)];
diff --git a/pkgs/markdown/lib/src/inline_syntaxes/strikethrough_syntax.dart b/pkgs/markdown/lib/src/inline_syntaxes/strikethrough_syntax.dart index 9b4dc7b..ddb0eef 100644 --- a/pkgs/markdown/lib/src/inline_syntaxes/strikethrough_syntax.dart +++ b/pkgs/markdown/lib/src/inline_syntaxes/strikethrough_syntax.dart
@@ -2,6 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import '../charcode.dart'; import 'delimiter_syntax.dart'; /// Matches strikethrough syntax according to the GFM spec. @@ -11,6 +12,7 @@ '~+', requiresDelimiterRun: true, allowIntraWord: true, + startCharacter: $tilde, tags: [DelimiterTag('del', 2)], ); }