aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs8
-rw-r--r--test/command/3596.md61
2 files changed, 67 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index 5251962f2..14b051539 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -260,8 +260,12 @@ pBulletList = try $ do
pListItem :: PandocMonad m => TagParser m a -> TagParser m Blocks
pListItem nonItem = do
TagOpen _ attr <- lookAhead $ pSatisfy (~== TagOpen "li" [])
- let liDiv = maybe mempty (\x -> B.divWith (x, [], []) mempty) (lookup "id" attr)
- (liDiv <>) <$> pInTags "li" block <* skipMany nonItem
+ let addId ident bs = case B.toList bs of
+ (Plain ils:xs) -> B.fromList (Plain
+ [Span (ident, [], []) ils] : xs)
+ _ -> B.divWith (ident, [], []) bs
+ (maybe id addId (lookup "id" attr)) <$>
+ pInTags "li" block <* skipMany nonItem
parseListStyleType :: String -> ListNumberStyle
parseListStyleType "lower-roman" = LowerRoman
diff --git a/test/command/3596.md b/test/command/3596.md
new file mode 100644
index 000000000..a064ca632
--- /dev/null
+++ b/test/command/3596.md
@@ -0,0 +1,61 @@
+```
+% pandoc -f html -t markdown-raw_html-bracketed_spans-native_spans
+<ul>
+<li>foo</li>
+<li id="id">bar</li>
+<li>baz</li>
+</ul>
+^D
+- foo
+- bar
+- baz
+```
+
+```
+% pandoc -f html -t markdown-raw_html-bracketed_spans-native_spans
+<ul>
+<li>foo</li>
+<li id="id">bar<ul><li>subbar</li></ul></li>
+<li>baz</li>
+</ul>
+^D
+- foo
+- bar
+ - subbar
+- baz
+```
+
+
+```
+% pandoc -f html -t markdown
+<ul>
+<li>foo</li>
+<li id="id">bar</li>
+<li>baz</li>
+</ul>
+^D
+- foo
+- [bar]{#id}
+- baz
+```
+
+
+```
+% pandoc -f html -t markdown
+<ul>
+<li><p>foo</p></li>
+<li id="id"><p>bar</p></li>
+<li><p>baz</p></li>
+</ul>
+^D
+- foo
+
+- <div id="id">
+
+ bar
+
+ </div>
+
+- baz
+
+```