diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2020-11-25 17:51:15 +0100 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2020-11-25 17:55:42 +0100 |
commit | c6f2663a237897a7310d30b825dc5ad8c6bedd3e (patch) | |
tree | 5ce3033c5fef35735ea8cf4864649088b4648349 /src/Text/Pandoc/Readers | |
parent | e26d31d56bc61553d5d6153f2130184643869877 (diff) | |
download | pandoc-c6f2663a237897a7310d30b825dc5ad8c6bedd3e.tar.gz |
HTML reader: simplify list attribute handling
This removes the `foldOrElse` function from the internal Text.Pandoc.CSS
module.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index e33dface7..95f034521 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -46,7 +46,7 @@ import Text.HTML.TagSoup.Match import Text.Pandoc.Builder (Blocks, Inlines, trimInlines) import qualified Text.Pandoc.Builder as B import Text.Pandoc.Class.PandocMonad (PandocMonad (..)) -import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps) +import Text.Pandoc.CSS (pickStyleAttrProps) import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.Definition import Text.Pandoc.Readers.HTML.Parsing @@ -290,23 +290,14 @@ pOrderedList :: PandocMonad m => TagParser m Blocks pOrderedList = try $ do TagOpen _ attribs' <- pSatisfy (matchTagOpen "ol" []) let attribs = toStringAttr attribs' - let (start, style) = (sta', sty') - where sta = fromMaybe "1" $ - lookup "start" attribs - sta' = fromMaybe 1 $ safeRead sta - - pickListStyle = pickStyleAttrProps ["list-style-type", "list-style"] - - typeAttr = fromMaybe "" $ lookup "type" attribs - classAttr = fromMaybe "" $ lookup "class" attribs - styleAttr = fromMaybe "" $ lookup "style" attribs - listStyle = fromMaybe "" $ pickListStyle styleAttr - - sty' = foldOrElse DefaultStyle - [ parseTypeAttr typeAttr - , parseListStyleType classAttr - , parseListStyleType listStyle - ] + let start = fromMaybe 1 $ lookup "start" attribs >>= safeRead + let style = fromMaybe DefaultStyle + $ (parseTypeAttr <$> lookup "type" attribs) + <|> (parseListStyleType <$> lookup "class" attribs) + <|> (parseListStyleType <$> (lookup "style" attribs >>= pickListStyle)) + where + pickListStyle = pickStyleAttrProps ["list-style-type", "list-style"] + let nonItem = pSatisfy (\t -> not (tagOpen (`elem` ["li","ol","ul","dl"]) (const True) t) && not (matchTagClose "ol" t)) |