diff --git a/spec-results.json b/spec-results.json index 062bd7b..ea271cd 100644 --- a/spec-results.json +++ b/spec-results.json @@ -169,6 +169,8 @@ 412, 413, 414, + 415, + 416, 417, 418, 419, @@ -215,6 +217,11 @@ 460, 461, 462, + 463, + 464, + 465, + 466, + 467, 468, 469, 470, @@ -715,6 +722,8 @@ 412, 413, 414, + 415, + 416, 417, 418, 419, @@ -761,6 +770,11 @@ 460, 461, 462, + 463, + 464, + 465, + 466, + 467, 468, 469, 470, diff --git a/src/Markdown/InlineParser.elm b/src/Markdown/InlineParser.elm index 780df9f..28c5967 100644 --- a/src/Markdown/InlineParser.elm +++ b/src/Markdown/InlineParser.elm @@ -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 diff --git a/src/Markdown/Parser.elm b/src/Markdown/Parser.elm index 1bb2a01..ccb4743 100644 --- a/src/Markdown/Parser.elm +++ b/src/Markdown/Parser.elm @@ -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. @@ -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) diff --git a/test-results/failing/CommonMark/Emphasis and strong emphasis.md b/test-results/failing/CommonMark/Emphasis and strong emphasis.md index 73a70ad..ff46001 100644 --- a/test-results/failing/CommonMark/Emphasis and strong emphasis.md +++ b/test-results/failing/CommonMark/Emphasis and strong emphasis.md @@ -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 -
foobarbaz
-```````````` - -But instead was: - -````````````html -foo***bar***baz
-```````````` -## [Example 416](https://spec.commonmark.org/0.29/#example-416) - -This markdown: - -````````````markdown -foo******bar*********baz - -```````````` - -Should give output: - -````````````html -foobar***baz
-```````````` - -But instead was: - -````````````html -foo******bar*********baz
-```````````` -## [Example 463](https://spec.commonmark.org/0.29/#example-463) - -This markdown: - -````````````markdown -****foo**** - -```````````` - -Should give output: - -````````````html -foo
-```````````` - -But instead was: - -````````````html -foo
-```````````` -## [Example 464](https://spec.commonmark.org/0.29/#example-464) - -This markdown: - -````````````markdown -____foo____ - -```````````` - -Should give output: - -````````````html -foo
-```````````` - -But instead was: - -````````````html -foo
-```````````` -## [Example 465](https://spec.commonmark.org/0.29/#example-465) - -This markdown: - -````````````markdown -******foo****** - -```````````` - -Should give output: - -````````````html -foo
-```````````` - -But instead was: - -````````````html -foo
-```````````` -## [Example 466](https://spec.commonmark.org/0.29/#example-466) - -This markdown: - -````````````markdown -***foo*** - -```````````` - -Should give output: - -````````````html -foo
-```````````` - -But instead was: - -````````````html -foo
-```````````` -## [Example 467](https://spec.commonmark.org/0.29/#example-467) - -This markdown: - -````````````markdown -_____foo_____ - -```````````` - -Should give output: - -````````````html -foo
-```````````` - -But instead was: - -````````````html -foo
-```````````` ## [Example 474](https://spec.commonmark.org/0.29/#example-474) This markdown: diff --git a/test-results/failing/GFM/Emphasis and strong emphasis.md b/test-results/failing/GFM/Emphasis and strong emphasis.md index 802dde8..608b793 100644 --- a/test-results/failing/GFM/Emphasis and strong emphasis.md +++ b/test-results/failing/GFM/Emphasis and strong emphasis.md @@ -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 -foobarbaz
-```````````` - -But instead was: - -````````````html -foo***bar***baz
-```````````` -## [Example 416](https://spec.commonmark.org/0.29/#example-416) - -This markdown: - -````````````markdown -foo******bar*********baz - -```````````` - -Should give output: - -````````````html -foobar***baz
-```````````` - -But instead was: - -````````````html -foo******bar*********baz
-```````````` -## [Example 463](https://spec.commonmark.org/0.29/#example-463) - -This markdown: - -````````````markdown -****foo**** - -```````````` - -Should give output: - -````````````html -foo
-```````````` - -But instead was: - -````````````html -foo
-```````````` -## [Example 464](https://spec.commonmark.org/0.29/#example-464) - -This markdown: - -````````````markdown -____foo____ - -```````````` - -Should give output: - -````````````html -foo
-```````````` - -But instead was: - -````````````html -foo
-```````````` -## [Example 465](https://spec.commonmark.org/0.29/#example-465) - -This markdown: - -````````````markdown -******foo****** - -```````````` - -Should give output: - -````````````html -foo
-```````````` - -But instead was: - -````````````html -foo
-```````````` -## [Example 466](https://spec.commonmark.org/0.29/#example-466) - -This markdown: - -````````````markdown -***foo*** - -```````````` - -Should give output: - -````````````html -foo
-```````````` - -But instead was: - -````````````html -foo
-```````````` -## [Example 467](https://spec.commonmark.org/0.29/#example-467) - -This markdown: - -````````````markdown -_____foo_____ - -```````````` - -Should give output: - -````````````html -foo
-```````````` - -But instead was: - -````````````html -foo
-```````````` ## [Example 474](https://spec.commonmark.org/0.29/#example-474) This markdown: diff --git a/test-results/failing/New/em_list_links.md b/test-results/failing/New/em_list_links.md index 1c0d99c..285751a 100644 --- a/test-results/failing/New/em_list_links.md +++ b/test-results/failing/New/em_list_links.md @@ -56,5 +56,5 @@ Should give output: But instead was: ````````````html --named link-named link-named link-named link
-named link-named link-named link-named link
-named link-named link-named link-named link-named link-named link-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link-named link-named link-named link
-named link-named link-named link-named link
-named link-named link-named link-named link-named link-named link-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
-named link
This is strong and em.
So isthisword.
This is strong and em.
So isthisword.
+This is strong and em.
So isthisword.
This is strong and em.
So isthisword.
```````````` diff --git a/test-results/passing-CommonMark.md b/test-results/passing-CommonMark.md index 29c3c5d..c485381 100644 --- a/test-results/passing-CommonMark.md +++ b/test-results/passing-CommonMark.md @@ -3019,6 +3019,42 @@ Gives this correct output: ```````````` +### [Example 415](https://spec.commonmark.org/0.29/#example-415) + +This markdown: + + +````````````markdown +foo***bar***baz + +```````````` + +Gives this correct output: + + +````````````html +foobarbaz
+ +```````````` + +### [Example 416](https://spec.commonmark.org/0.29/#example-416) + +This markdown: + + +````````````markdown +foo******bar*********baz + +```````````` + +Gives this correct output: + + +````````````html +foobar***baz
+ +```````````` + ### [Example 417](https://spec.commonmark.org/0.29/#example-417) This markdown: @@ -3851,6 +3887,96 @@ Gives this correct output: ```````````` +### [Example 463](https://spec.commonmark.org/0.29/#example-463) + +This markdown: + + +````````````markdown +****foo**** + +```````````` + +Gives this correct output: + + +````````````html +foo
+ +```````````` + +### [Example 464](https://spec.commonmark.org/0.29/#example-464) + +This markdown: + + +````````````markdown +____foo____ + +```````````` + +Gives this correct output: + + +````````````html +foo
+ +```````````` + +### [Example 465](https://spec.commonmark.org/0.29/#example-465) + +This markdown: + + +````````````markdown +******foo****** + +```````````` + +Gives this correct output: + + +````````````html +foo
+ +```````````` + +### [Example 466](https://spec.commonmark.org/0.29/#example-466) + +This markdown: + + +````````````markdown +***foo*** + +```````````` + +Gives this correct output: + + +````````````html +foo
+ +```````````` + +### [Example 467](https://spec.commonmark.org/0.29/#example-467) + +This markdown: + + +````````````markdown +_____foo_____ + +```````````` + +Gives this correct output: + + +````````````html +foo
+ +```````````` + ### [Example 468](https://spec.commonmark.org/0.29/#example-468) This markdown: diff --git a/test-results/passing-GFM.md b/test-results/passing-GFM.md index 2b3d116..1f5a46d 100644 --- a/test-results/passing-GFM.md +++ b/test-results/passing-GFM.md @@ -3019,6 +3019,42 @@ Gives this correct output: ```````````` +### [Example 415](https://spec.commonmark.org/0.29/#example-415) + +This markdown: + + +````````````markdown +foo***bar***baz + +```````````` + +Gives this correct output: + + +````````````html +foobarbaz
+ +```````````` + +### [Example 416](https://spec.commonmark.org/0.29/#example-416) + +This markdown: + + +````````````markdown +foo******bar*********baz + +```````````` + +Gives this correct output: + + +````````````html +foobar***baz
+ +```````````` + ### [Example 417](https://spec.commonmark.org/0.29/#example-417) This markdown: @@ -3851,6 +3887,96 @@ Gives this correct output: ```````````` +### [Example 463](https://spec.commonmark.org/0.29/#example-463) + +This markdown: + + +````````````markdown +****foo**** + +```````````` + +Gives this correct output: + + +````````````html +foo
+ +```````````` + +### [Example 464](https://spec.commonmark.org/0.29/#example-464) + +This markdown: + + +````````````markdown +____foo____ + +```````````` + +Gives this correct output: + + +````````````html +foo
+ +```````````` + +### [Example 465](https://spec.commonmark.org/0.29/#example-465) + +This markdown: + + +````````````markdown +******foo****** + +```````````` + +Gives this correct output: + + +````````````html +foo
+ +```````````` + +### [Example 466](https://spec.commonmark.org/0.29/#example-466) + +This markdown: + + +````````````markdown +***foo*** + +```````````` + +Gives this correct output: + + +````````````html +foo
+ +```````````` + +### [Example 467](https://spec.commonmark.org/0.29/#example-467) + +This markdown: + + +````````````markdown +_____foo_____ + +```````````` + +Gives this correct output: + + +````````````html +foo
+ +```````````` + ### [Example 468](https://spec.commonmark.org/0.29/#example-468) This markdown: