git.iko.soy/typeable/pandoc
on master help sign in
Fix parsing bug affected indented code after raw HTML.

Closes #6009, #5360.

commit82f44592ae1f2253a5f7ca52d5d3a2299e9bc7a9 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 27 Dec 2019, 11:46 (7 years ago) parentea2c515
3 files changed+47−8
src/Text/Pandoc/Readers/Markdown.hs+10−8 test/command/5360.md+19 test/command/6009.md+18
src/Text/Pandoc/Readers/Markdown.hs+10−8
@@ -1094,18 +1094,20 @@ rawHtmlBlocks = do
10941094 -- inline will not be parsed as inline tags
10951095 oldInHtmlBlock <- stateInHtmlBlock <$> getState
10961096 updateState $ \st -> st{ stateInHtmlBlock = Just tagtype }
1097− let closer = htmlTag (\x -> x ~== TagClose tagtype)
1098− let block' = try $
1099− do notFollowedBy' closer
1100− gobbleAtMostSpaces indentlevel
1101− block
1097+ let closer = htmlTag (~== TagClose tagtype)
1098+ let block' = try $ do
1099+ gobbleAtMostSpaces indentlevel
1100+ notFollowedBy' closer
1101+ block
11021102 contents <- mconcat <$> many block'
11031103 result <-
1104− (closer >>= \(_, rawcloser) -> return (
1105− return (B.rawBlock "html" $ stripMarkdownAttribute raw) <>
1104+ try
1105+ (do gobbleAtMostSpaces indentlevel
1106+ (_, rawcloser) <- closer
1107+ return (return (B.rawBlock "html" $ stripMarkdownAttribute raw) <>
11061108 contents <>
11071109 return (B.rawBlock "html" rawcloser)))
1108− <|> return (return (B.rawBlock "html" raw) <> contents)
1110+ <|> (return (return (B.rawBlock "html" raw) <> contents))
11091111 updateState $ \st -> st{ stateInHtmlBlock = oldInHtmlBlock }
11101112 return result
11111113
test/command/5360.mdnew file+19
@@ -0,0 +1,19 @@
1+```
2+% pandoc -t native
3+::: {.foo}
4+<table>
5+ <tr>
6+ <td>hi</td>
7+ </tr>
8+</table>
9+:::
10+^D
11+[Div ("",["foo"],[])
12+ [RawBlock (Format "html") "<table>"
13+ ,RawBlock (Format "html") "<tr>"
14+ ,RawBlock (Format "html") "<td>"
15+ ,Plain [Str "hi"]
16+ ,RawBlock (Format "html") "</td>"
17+ ,RawBlock (Format "html") "</tr>"
18+ ,RawBlock (Format "html") "</table>"]]
19+```
test/command/6009.mdnew file+18
@@ -0,0 +1,18 @@
1+```
2+% pandoc -t native
3+ <tr>
4+ <td>
5+ </td>
6+ </tr>
7+
8+x
9+
10+ y
11+^D
12+[RawBlock (Format "html") "<tr>"
13+,RawBlock (Format "html") "<td>"
14+,RawBlock (Format "html") "</td>"
15+,RawBlock (Format "html") "</tr>"
16+,Para [Str "x"]
17+,CodeBlock ("",[],[]) "y"]
18+```