Skip to content

Commit

Permalink
Merge pull request #82 from LutSa/master
Browse files Browse the repository at this point in the history
Fix minor emphasis parsing cases
  • Loading branch information
dillonkearns authored May 23, 2021
2 parents 4ab0eb2 + b0d45a5 commit a72ce49
Show file tree
Hide file tree
Showing 9 changed files with 275 additions and 285 deletions.
14 changes: 14 additions & 0 deletions spec-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@
412,
413,
414,
415,
416,
417,
418,
419,
Expand Down Expand Up @@ -215,6 +217,11 @@
460,
461,
462,
463,
464,
465,
466,
467,
468,
469,
470,
Expand Down Expand Up @@ -715,6 +722,8 @@
412,
413,
414,
415,
416,
417,
418,
419,
Expand Down Expand Up @@ -761,6 +770,11 @@
460,
461,
462,
463,
464,
465,
466,
467,
468,
469,
470,
Expand Down
2 changes: 1 addition & 1 deletion src/Markdown/InlineParser.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,7 @@ isOpenEmphasisToken closeToken openToken =
-- is not multiple of 3
-- is Open emphasis
modBy 3 (closeToken.length + openToken.length) /= 0

|| (modBy 3 closeToken.length == 0 && modBy 3 openToken.length == 0)
else
True

Expand Down
8 changes: 6 additions & 2 deletions src/Markdown/Parser.elm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Parser.Advanced as Advanced exposing ((|.), (|=), Nestable(..), Step(..),
import Parser.Token as Token
import ThematicBreak

import Markdown.Helpers exposing (isEven)

{-| Try parsing a markdown String into `Markdown.Block.Block`s.
Expand Down Expand Up @@ -187,8 +188,11 @@ mapInline inline =
Block.Strong (inlines |> List.map mapInline)

_ ->
-- TODO fix this
Block.Strong (inlines |> List.map mapInline)
if level |> isEven then
Block.Strong [Inline.Emphasis (level - 2) inlines |> mapInline]
else
Block.Emphasis [Inline.Emphasis (level - 1) inlines |> mapInline]

Inline.Strikethrough inlines ->
Block.Strikethrough (inlines |> List.map mapInline)

Expand Down
140 changes: 0 additions & 140 deletions test-results/failing/CommonMark/Emphasis and strong emphasis.md
Original file line number Diff line number Diff line change
@@ -1,145 +1,5 @@
# CommonMark - Emphasis and strong emphasis

## [Example 415](https://spec.commonmark.org/0.29/#example-415)

This markdown:

````````````markdown
foo***bar***baz

````````````

Should give output:

````````````html
<p>foo<em><strong>bar</strong></em>baz</p>
````````````

But instead was:

````````````html
<p>foo***bar***baz</p>
````````````
## [Example 416](https://spec.commonmark.org/0.29/#example-416)

This markdown:

````````````markdown
foo******bar*********baz

````````````

Should give output:

````````````html
<p>foo<strong><strong><strong>bar</strong></strong></strong>***baz</p>
````````````

But instead was:

````````````html
<p>foo******bar*********baz</p>
````````````
## [Example 463](https://spec.commonmark.org/0.29/#example-463)

This markdown:

````````````markdown
****foo****

````````````

Should give output:

````````````html
<p><strong><strong>foo</strong></strong></p>
````````````

But instead was:

````````````html
<p><strong>foo</strong></p>
````````````
## [Example 464](https://spec.commonmark.org/0.29/#example-464)

This markdown:

````````````markdown
____foo____

````````````

Should give output:

````````````html
<p><strong><strong>foo</strong></strong></p>
````````````

But instead was:

````````````html
<p><strong>foo</strong></p>
````````````
## [Example 465](https://spec.commonmark.org/0.29/#example-465)

This markdown:

````````````markdown
******foo******

````````````

Should give output:

````````````html
<p><strong><strong><strong>foo</strong></strong></strong></p>
````````````

But instead was:

````````````html
<p><strong>foo</strong></p>
````````````
## [Example 466](https://spec.commonmark.org/0.29/#example-466)

This markdown:

````````````markdown
***foo***

````````````

Should give output:

````````````html
<p><em><strong>foo</strong></em></p>
````````````

But instead was:

````````````html
<p><strong>foo</strong></p>
````````````
## [Example 467](https://spec.commonmark.org/0.29/#example-467)

This markdown:

````````````markdown
_____foo_____

````````````

Should give output:

````````````html
<p><em><strong><strong>foo</strong></strong></em></p>
````````````

But instead was:

````````````html
<p><strong>foo</strong></p>
````````````
## [Example 474](https://spec.commonmark.org/0.29/#example-474)

This markdown:
Expand Down
140 changes: 0 additions & 140 deletions test-results/failing/GFM/Emphasis and strong emphasis.md
Original file line number Diff line number Diff line change
@@ -1,145 +1,5 @@
# GFM - Emphasis and strong emphasis

## [Example 415](https://spec.commonmark.org/0.29/#example-415)

This markdown:

````````````markdown
foo***bar***baz

````````````

Should give output:

````````````html
<p>foo<em><strong>bar</strong></em>baz</p>
````````````

But instead was:

````````````html
<p>foo***bar***baz</p>
````````````
## [Example 416](https://spec.commonmark.org/0.29/#example-416)

This markdown:

````````````markdown
foo******bar*********baz

````````````

Should give output:

````````````html
<p>foo<strong><strong><strong>bar</strong></strong></strong>***baz</p>
````````````

But instead was:

````````````html
<p>foo******bar*********baz</p>
````````````
## [Example 463](https://spec.commonmark.org/0.29/#example-463)

This markdown:

````````````markdown
****foo****

````````````

Should give output:

````````````html
<p><strong><strong>foo</strong></strong></p>
````````````

But instead was:

````````````html
<p><strong>foo</strong></p>
````````````
## [Example 464](https://spec.commonmark.org/0.29/#example-464)

This markdown:

````````````markdown
____foo____

````````````

Should give output:

````````````html
<p><strong><strong>foo</strong></strong></p>
````````````

But instead was:

````````````html
<p><strong>foo</strong></p>
````````````
## [Example 465](https://spec.commonmark.org/0.29/#example-465)

This markdown:

````````````markdown
******foo******

````````````

Should give output:

````````````html
<p><strong><strong><strong>foo</strong></strong></strong></p>
````````````

But instead was:

````````````html
<p><strong>foo</strong></p>
````````````
## [Example 466](https://spec.commonmark.org/0.29/#example-466)

This markdown:

````````````markdown
***foo***

````````````

Should give output:

````````````html
<p><em><strong>foo</strong></em></p>
````````````

But instead was:

````````````html
<p><strong>foo</strong></p>
````````````
## [Example 467](https://spec.commonmark.org/0.29/#example-467)

This markdown:

````````````markdown
_____foo_____

````````````

Should give output:

````````````html
<p><em><strong><strong>foo</strong></strong></em></p>
````````````

But instead was:

````````````html
<p><strong>foo</strong></p>
````````````
## [Example 474](https://spec.commonmark.org/0.29/#example-474)

This markdown:
Expand Down
2 changes: 1 addition & 1 deletion test-results/failing/New/em_list_links.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ Should give output:
But instead was:

````````````html
<ul><li>italic</li></ul><p>-<a href="https://www.google.com"><em>named link</em></a>-<em><a href="https://www.google.com">named link</a></em>-<a href="https://www.google.com"><em>named link</em></a>-<em><a href="https://www.google.com">named link</a></em></p><ul><li>bold</li></ul><p>-<a href="https://www.google.com"><strong>named link</strong></a>-<strong><a href="https://www.google.com">named link</a></strong>-<a href="https://www.google.com"><strong>named link</strong></a>-<strong><a href="https://www.google.com">named link</a></strong></p><ul><li>bold italic</li></ul><p>-<a href="https://www.google.com"><strong>named link</strong></a>-<strong><a href="https://www.google.com">named link</a></strong>-<a href="https://www.google.com"><strong>named link</strong></a>-<strong><a href="https://www.google.com">named link</a></strong>-<a href="https://www.google.com"><em><strong>named link</strong></em></a>-<a href="https://www.google.com"><strong><em>named link</em></strong></a>-<strong><em><a href="https://www.google.com">named link</a></em></strong></p><ul><li>code</li></ul><p>-<a href="https://www.google.com"><code>named link</code></a></p><ul><li>code italic</li></ul><p>-<em><a href="https://www.google.com"><code>named link</code></a></em>-<a href="https://www.google.com"><em><code>named link</code></em></a>-<em><a href="https://www.google.com"><code>named link</code></a></em>-<a href="https://www.google.com"><em><code>named link</code></em></a></p><ul><li>code bold</li></ul><p>-<strong><a href="https://www.google.com"><code>named link</code></a></strong>-<a href="https://www.google.com"><strong><code>named link</code></strong></a>-<strong><a href="https://www.google.com"><code>named link</code></a></strong>-<a href="https://www.google.com"><strong><code>named link</code></strong></a></p><ul><li>code bold italic</li></ul><p>-<a href="https://www.google.com"><strong><code>named link</code></strong></a>-<strong><a href="https://www.google.com"><code>named link</code></a></strong>-<a href="https://www.google.com"><strong><code>named link</code></strong></a>-<strong><a href="https://www.google.com"><code>named link</code></a></strong>-<a href="https://www.google.com"><em><strong><code>named link</code></strong></em></a>-<a href="https://www.google.com"><strong><em><code>named link</code></em></strong></a>-<strong><em><a href="https://www.google.com"><code>named link</code></a></em></strong></p>
<ul><li>italic</li></ul><p>-<a href="https://www.google.com"><em>named link</em></a>-<em><a href="https://www.google.com">named link</a></em>-<a href="https://www.google.com"><em>named link</em></a>-<em><a href="https://www.google.com">named link</a></em></p><ul><li>bold</li></ul><p>-<a href="https://www.google.com"><strong>named link</strong></a>-<strong><a href="https://www.google.com">named link</a></strong>-<a href="https://www.google.com"><strong>named link</strong></a>-<strong><a href="https://www.google.com">named link</a></strong></p><ul><li>bold italic</li></ul><p>-<a href="https://www.google.com"><em><strong>named link</strong></em></a>-<em><strong><a href="https://www.google.com">named link</a></strong></em>-<a href="https://www.google.com"><em><strong>named link</strong></em></a>-<em><strong><a href="https://www.google.com">named link</a></strong></em>-<a href="https://www.google.com"><em><strong>named link</strong></em></a>-<a href="https://www.google.com"><strong><em>named link</em></strong></a>-<strong><em><a href="https://www.google.com">named link</a></em></strong></p><ul><li>code</li></ul><p>-<a href="https://www.google.com"><code>named link</code></a></p><ul><li>code italic</li></ul><p>-<em><a href="https://www.google.com"><code>named link</code></a></em>-<a href="https://www.google.com"><em><code>named link</code></em></a>-<em><a href="https://www.google.com"><code>named link</code></a></em>-<a href="https://www.google.com"><em><code>named link</code></em></a></p><ul><li>code bold</li></ul><p>-<strong><a href="https://www.google.com"><code>named link</code></a></strong>-<a href="https://www.google.com"><strong><code>named link</code></strong></a>-<strong><a href="https://www.google.com"><code>named link</code></a></strong>-<a href="https://www.google.com"><strong><code>named link</code></strong></a></p><ul><li>code bold italic</li></ul><p>-<a href="https://www.google.com"><em><strong><code>named link</code></strong></em></a>-<em><strong><a href="https://www.google.com"><code>named link</code></a></strong></em>-<a href="https://www.google.com"><em><strong><code>named link</code></strong></em></a>-<em><strong><a href="https://www.google.com"><code>named link</code></a></strong></em>-<a href="https://www.google.com"><em><strong><code>named link</code></strong></em></a>-<a href="https://www.google.com"><strong><em><code>named link</code></em></strong></a>-<strong><em><a href="https://www.google.com"><code>named link</code></a></em></strong></p>
````````````
2 changes: 1 addition & 1 deletion test-results/failing/Original/strong_and_em_together.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ Should give output:
But instead was:

````````````html
<p><strong>This is strong and em.</strong></p><p>So is<strong>this</strong>word.</p><p><strong>This is strong and em.</strong></p><p>So is<strong>this</strong>word.</p>
<p><em><strong>This is strong and em.</strong></em></p><p>So is<em><strong>this</strong></em>word.</p><p><em><strong>This is strong and em.</strong></em></p><p>So is<em><strong>this</strong></em>word.</p>
````````````
Loading

0 comments on commit a72ce49

Please sign in to comment.