diff --git a/pkgs/markdown/CHANGELOG.md b/pkgs/markdown/CHANGELOG.md index 6b1d45be0..03316c4bb 100644 --- a/pkgs/markdown/CHANGELOG.md +++ b/pkgs/markdown/CHANGELOG.md @@ -17,8 +17,7 @@ without ampersands. * Split a fenced code block info string at the first space or tab, so a tab no longer ends up inside the `language-` class (matching cmark and - commonmark.js). Also return early from `escapePunctuation` when the input - has no backslash. + commonmark.js). * Sort footnote definitions by their case-insensitive labels rather than their URI-encoded HTML IDs, so Unicode and escaped labels keep first-reference order. diff --git a/pkgs/markdown/lib/src/block_syntaxes/fenced_code_block_syntax.dart b/pkgs/markdown/lib/src/block_syntaxes/fenced_code_block_syntax.dart index ffbb70d42..d89fba009 100644 --- a/pkgs/markdown/lib/src/block_syntaxes/fenced_code_block_syntax.dart +++ b/pkgs/markdown/lib/src/block_syntaxes/fenced_code_block_syntax.dart @@ -176,11 +176,7 @@ class _FenceMatch { } // We assume the info string is trimmed already. - var separatorIndex = info.indexOf(' '); - final tabIndex = info.indexOf('\t'); - if (separatorIndex == -1 || (tabIndex != -1 && tabIndex < separatorIndex)) { - separatorIndex = tabIndex; - } + final separatorIndex = info.indexOf(RegExp(r'[ \t]')); if (separatorIndex == -1) { return (info, null); } diff --git a/pkgs/markdown/lib/src/util.dart b/pkgs/markdown/lib/src/util.dart index 75d60b03e..92bb25dfb 100644 --- a/pkgs/markdown/lib/src/util.dart +++ b/pkgs/markdown/lib/src/util.dart @@ -143,7 +143,6 @@ extension MatchExtensions on Match { /// Escapes the ASCII punctuation characters after backslash(`\`). String escapePunctuation(String input) { - if (!input.contains(r'\')) return input; final buffer = StringBuffer(); for (var i = 0; i < input.length; i++) { diff --git a/pkgs/markdown/test/util_test.dart b/pkgs/markdown/test/util_test.dart index 6db001b41..663e89339 100644 --- a/pkgs/markdown/test/util_test.dart +++ b/pkgs/markdown/test/util_test.dart @@ -106,17 +106,6 @@ void main() { expect(decodeHtmlCharacters('A'), 'A'); }); }); - - group('escapePunctuation', () { - test('keeps unescaped content intact', () { - expect(escapePunctuation('fence language'), 'fence language'); - }); - - test('removes punctuation escapes but not ordinary backslashes', () { - expect(escapePunctuation(r'\*escaped\!'), '*escaped!'); - expect(escapePunctuation(r'\a'), r'\a'); - }); - }); } extension on Line {