Ignore underscores in the middle of words. Fix #41. R=sethladd@google.com Review URL: https://codereview.chromium.org//1340143003 .
diff --git a/CHANGELOG.md b/CHANGELOG.md index e5040d6..d7d580c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md
@@ -4,6 +4,7 @@ `InlineParser.currentSource`. * Switch tests to use [test][] instead of [unittest][]. * Fix a few bugs in inline code syntax. +* Ignore underscores inside words (#41). [test]: https://pub.dartlang.org/packages/test [unittest]: https://pub.dartlang.org/packages/unittest
diff --git a/lib/src/inline_parser.dart b/lib/src/inline_parser.dart index 3b1d9fa..9f0db08 100644 --- a/lib/src/inline_parser.dart +++ b/lib/src/inline_parser.dart
@@ -43,13 +43,11 @@ // Parse "**strong**" tags. new TagSyntax(r'\*\*', tag: 'strong'), // Parse "__strong__" tags. - new TagSyntax(r'__', tag: 'strong'), + new TagSyntax(r'\b__', tag: 'strong', end: r'__\b'), // Parse "*emphasis*" tags. new TagSyntax(r'\*', tag: 'em'), // Parse "_emphasis_" tags. - // TODO(rnystrom): Underscores in the middle of a word should not be - // parsed as emphasis like_in_this. - new TagSyntax(r'_', tag: 'em'), + new TagSyntax(r'\b_', tag: 'em', end: r'_\b'), new CodeSyntax(), // We will add the LinkSyntax once we know about the specific link resolver. ];
diff --git a/pubspec.yaml b/pubspec.yaml index 0c2eedf..e459456 100644 --- a/pubspec.yaml +++ b/pubspec.yaml
@@ -1,5 +1,5 @@ name: markdown -version: 0.8.0-dev +version: 0.8.0 author: Dart Team <misc@dartlang.org> description: A library for converting markdown to HTML. homepage: https://github.com/dart-lang/markdown
diff --git a/test/original/emphasis_and_strong.unit b/test/original/emphasis_and_strong.unit index 5e67fc0..90aea56 100644 --- a/test/original/emphasis_and_strong.unit +++ b/test/original/emphasis_and_strong.unit
@@ -70,3 +70,19 @@ <<< <p><em>a _b </em>c<em> d_ e</em></p> +>>> in the middle of a word +a_b_c a__b__c a*b*c a**b**c +<<< +<p>a_b_c a__b__c a<em>b</em>c a<strong>b</strong>c</p> +>>> prefixing a word +_a_b __a__b *a*b **a**b +<<< +<p>_a_b __a__b <em>a</em>b <strong>a</strong>b</p> +>>> suffixing a word +a_b_ a__b__ a*b* a**b** +<<< +<p>a_b_ a__b__ a<em>b</em> a<strong>b</strong></p> +>>> spanning words +_a_b c_d_ __a__b c__d__ *a*b c*d* **a**b c**d** +<<< +<p><em>a_b c_d</em> <strong>a__b c__d</strong> <em>a</em>b c<em>d</em> <strong>a</strong>b c<strong>d</strong></p> \ No newline at end of file