diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-04-23 10:55:16 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-04-23 11:03:48 +0200 |
commit | 51a46b7e31c92c717ca4778df96535b0e492babe (patch) | |
tree | e6aa72b6e4fb02d1a8c708123e31138cac48e175 /src | |
parent | c5f4a0b9c52188f94b8798c43df8f4f5c61278e4 (diff) | |
download | pandoc-51a46b7e31c92c717ca4778df96535b0e492babe.tar.gz |
HTML reader: Revise treatment of li with id attribute.
Previously we always added an empty div before the list
item, but this created problems with spacing in tight
lists. Now we do this:
If the list item contents begin with a Plain block,
we modify the Plain block by adding a Span around
its contents.
Otherwise, we add a Div around the contents of the
list item (instead of adding an empty Div to the
beginning, as before).
Closes #3596.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 8 |
1 files changed, 6 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 |