git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: improved parsing of indented raw HTML blocks.

Previously we inadvertently interpreted indented HTML as code blocks. This was a regression. We now seek to determine the indentation level of the contents of an HTML block, and (optionally) skip that much indentation. As a side effect, indentation may be stripped off of raw HTML blocks, if `markdown_in_html_blocks` is used. This is better than having things interpreted as indented code blocks. Closes #1841.

commit82cc7fb0d462401b54bfe5172e7e49ab7b7302d9 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 6 May 2017, 22:56 (9 years ago) parentf20c89e
2 files changed+49−1
src/Text/Pandoc/Readers/Markdown.hs+7−1 test/command/1841.md+42
src/Text/Pandoc/Readers/Markdown.hs+7−1
@@ -1088,13 +1088,19 @@ rawTeXBlock = do
10881088rawHtmlBlocks :: PandocMonad m => MarkdownParser m (F Blocks)
10891089rawHtmlBlocks = do
10901090 (TagOpen tagtype _, raw) <- htmlTag isBlockTag
1091+ -- we don't want '<td> text' to be a code block:
1092+ skipMany spaceChar
1093+ indentlevel <- (blankline >> length <$> many (char ' ')) <|> return 0
10911094 -- try to find closing tag
10921095 -- we set stateInHtmlBlock so that closing tags that can be either block or
10931096 -- inline will not be parsed as inline tags
10941097 oldInHtmlBlock <- stateInHtmlBlock <$> getState
10951098 updateState $ \st -> st{ stateInHtmlBlock = Just tagtype }
10961099 let closer = htmlTag (\x -> x ~== TagClose tagtype)
1097− contents <- mconcat <$> many (notFollowedBy' closer >> block)
1100+ let block' = do notFollowedBy' closer
1101+ atMostSpaces indentlevel
1102+ block
1103+ contents <- mconcat <$> many block'
10981104 result <-
10991105 (closer >>= \(_, rawcloser) -> return (
11001106 return (B.rawBlock "html" $ stripMarkdownAttribute raw) <>
test/command/1841.mdnew file+42
@@ -0,0 +1,42 @@
1+```
2+% pandoc
3+<table>
4+<tr>
5+<td> *one*</td>
6+<td> [a link](http://google.com)</td>
7+</tr>
8+</table>
9+^D
10+<table>
11+<tr>
12+<td>
13+<em>one</em>
14+</td>
15+<td>
16+<a href="http://google.com">a link</a>
17+</td>
18+</tr>
19+</table>
20+```
21+
22+```
23+% pandoc
24+<table>
25+ <tr>
26+ <td>*one*</td>
27+ <td>[a link](http://google.com)</td>
28+ </tr>
29+</table>
30+^D
31+<table>
32+<tr>
33+<td>
34+<em>one</em>
35+</td>
36+<td>
37+<a href="http://google.com">a link</a>
38+</td>
39+</tr>
40+</table>
41+```
42+