diff --git a/spec-results.json b/spec-results.json index ea271cd..25c7f53 100644 --- a/spec-results.json +++ b/spec-results.json @@ -364,6 +364,7 @@ 184, 185, 186, + 187, 188 ], "Links": [ @@ -917,6 +918,7 @@ 184, 185, 186, + 187, 188 ], "Links": [ diff --git a/src/Markdown/Parser.elm b/src/Markdown/Parser.elm index ccb4743..f643afd 100644 --- a/src/Markdown/Parser.elm +++ b/src/Markdown/Parser.elm @@ -59,7 +59,7 @@ parse input = Ok v -> -- then parse the inlines of each raw block - case parseAllInlines v of + case parseAllInlines (parseContainers v) of Err e -> -- NOTE these messages get an incorrect location, -- because they are parsed outside of the main (raw block) parser context. @@ -80,6 +80,35 @@ parse input = Ok (List.filter isNotEmptyParagraph blocks) +parseContainers: State-> State +parseContainers state = + parseContainersHelp state.rawBlocks {linkReferenceDefinitions=state.linkReferenceDefinitions, rawBlocks = []} + + +parseContainersHelp : List RawBlock -> State -> State +parseContainersHelp unparsedRawBlocks parsedState = + case unparsedRawBlocks of + rawBlock :: rest -> + case rawBlock of + BlockQuote rawBlocks -> + case Advanced.run rawBlockParser rawBlocks of + Ok value -> + parseContainersHelp rest + { linkReferenceDefinitions = parsedState.linkReferenceDefinitions ++ (parseContainers value).linkReferenceDefinitions + , rawBlocks = parsedState.rawBlocks ++[ (parseContainers value).rawBlocks|>ParsedBlockQuote] + } + Err e -> + -- TODO return this error + {linkReferenceDefinitions=[], rawBlocks= []} + _ -> + parseContainersHelp rest + { linkReferenceDefinitions = parsedState.linkReferenceDefinitions + , rawBlocks = parsedState.rawBlocks ++ [rawBlock] + } + [] -> + parsedState + + deadEndsToString : List (Advanced.DeadEnd String Parser.Problem) -> String deadEndsToString deadEnds = deadEnds @@ -294,19 +323,16 @@ parseInlines linkReferences rawBlock = EmptyBlock BlockQuote rawBlocks -> - case Advanced.run rawBlockParser rawBlocks of - Ok value -> - case parseAllInlines value of - Ok parsedBlocks -> - Block.BlockQuote parsedBlocks - |> ParsedBlock - - Err e -> - InlineProblem e + EmptyBlock - Err error -> - InlineProblem (Parser.Problem (deadEndsToString error)) + ParsedBlockQuote rawBlocks-> + case parseAllInlines {linkReferenceDefinitions = linkReferences, rawBlocks = rawBlocks} of + Ok parsedBlocks -> + Block.BlockQuote parsedBlocks + |> ParsedBlock + Err e -> + InlineProblem e IndentedCodeBlock codeBlockBody -> Block.CodeBlock { body = codeBlockBody, language = Nothing } |> ParsedBlock diff --git a/src/Markdown/RawBlock.elm b/src/Markdown/RawBlock.elm index bf11470..e864818 100644 --- a/src/Markdown/RawBlock.elm +++ b/src/Markdown/RawBlock.elm @@ -37,4 +37,5 @@ type RawBlock | TableDelimiter Markdown.Table.TableDelimiterRow | BlankLine | BlockQuote String + | ParsedBlockQuote (List RawBlock) | SetextLine SetextLevel String diff --git a/test-results/failing/CommonMark/HTML blocks.md b/test-results/failing/CommonMark/HTML blocks.md index 8b54349..f24c870 100644 --- a/test-results/failing/CommonMark/HTML blocks.md +++ b/test-results/failing/CommonMark/HTML blocks.md @@ -498,7 +498,7 @@ Should give output: But instead was: ````````````html -ERROR Problem at row 1 Problem at row 2 Expecting symbol + ```````````` ## [Example 144](https://spec.commonmark.org/0.29/#example-144) diff --git a/test-results/failing/CommonMark/Link reference definitions.md b/test-results/failing/CommonMark/Link reference definitions.md index 5473900..1a65ade 100644 --- a/test-results/failing/CommonMark/Link reference definitions.md +++ b/test-results/failing/CommonMark/Link reference definitions.md @@ -89,25 +89,3 @@ But instead was: ````````````html
Foobar
```````````` -## [Example 187](https://spec.commonmark.org/0.29/#example-187) - -This markdown: - -````````````markdown -[foo] - -> [foo]: /url - -```````````` - -Should give output: - -````````````html - -```````````` - -But instead was: - -````````````html -[foo]
-```````````` diff --git a/test-results/failing/GFM/HTML blocks.md b/test-results/failing/GFM/HTML blocks.md index 795fc24..fcb1b6c 100644 --- a/test-results/failing/GFM/HTML blocks.md +++ b/test-results/failing/GFM/HTML blocks.md @@ -498,7 +498,7 @@ Should give output: But instead was: ````````````html -ERROR Problem at row 1 Problem at row 2 Expecting symbol + ```````````` ## [Example 144](https://spec.commonmark.org/0.29/#example-144) diff --git a/test-results/failing/GFM/Link reference definitions.md b/test-results/failing/GFM/Link reference definitions.md index 6693a03..3db0092 100644 --- a/test-results/failing/GFM/Link reference definitions.md +++ b/test-results/failing/GFM/Link reference definitions.md @@ -89,25 +89,3 @@ But instead was: ````````````htmlFoobar
```````````` -## [Example 187](https://spec.commonmark.org/0.29/#example-187) - -This markdown: - -````````````markdown -[foo] - -> [foo]: /url - -```````````` - -Should give output: - -````````````html - -```````````` - -But instead was: - -````````````html -[foo]
-```````````` diff --git a/test-results/passing-CommonMark.md b/test-results/passing-CommonMark.md index c485381..1b20409 100644 --- a/test-results/passing-CommonMark.md +++ b/test-results/passing-CommonMark.md @@ -6624,6 +6624,28 @@ Gives this correct output: ```````````` +### [Example 187](https://spec.commonmark.org/0.29/#example-187) + +This markdown: + + +````````````markdown +[foo] + +> [foo]: /url + +```````````` + +Gives this correct output: + + +````````````html + +++ +```````````` + ### [Example 188](https://spec.commonmark.org/0.29/#example-188) This markdown: diff --git a/test-results/passing-GFM.md b/test-results/passing-GFM.md index 1f5a46d..d696b6d 100644 --- a/test-results/passing-GFM.md +++ b/test-results/passing-GFM.md @@ -6624,6 +6624,28 @@ Gives this correct output: ```````````` +### [Example 187](https://spec.commonmark.org/0.29/#example-187) + +This markdown: + + +````````````markdown +[foo] + +> [foo]: /url + +```````````` + +Gives this correct output: + + +````````````html + +
++ +```````````` + ### [Example 188](https://spec.commonmark.org/0.29/#example-188) This markdown: