@@ -64,6 +64,7 @@ import Data.Default (Default (..), def)
6464import Control.Monad.Reader (Reader,ask, asks, local, runReader)
6565import Network.URI (isURI)
6666import Text.Pandoc.Error
67+import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps)
6768
6869import Text.Parsec.Error
6970
@@ -252,6 +253,22 @@ pListItem nonItem = do
252253 let liDiv = maybe mempty (\x -> B.divWith (x, [], []) mempty) (lookup "id" attr)
253254 (liDiv <>) <$> pInTags "li" block <* skipMany nonItem
254255
256+parseListStyleType :: String -> ListNumberStyle
257+parseListStyleType "lower-roman" = LowerRoman
258+parseListStyleType "upper-roman" = UpperRoman
259+parseListStyleType "lower-alpha" = LowerAlpha
260+parseListStyleType "upper-alpha" = UpperAlpha
261+parseListStyleType "decimal" = Decimal
262+parseListStyleType _ = DefaultStyle
263+
264+parseTypeAttr :: String -> ListNumberStyle
265+parseTypeAttr "i" = LowerRoman
266+parseTypeAttr "I" = UpperRoman
267+parseTypeAttr "a" = LowerAlpha
268+parseTypeAttr "A" = UpperAlpha
269+parseTypeAttr "1" = Decimal
270+parseTypeAttr _ = DefaultStyle
271+
255272pOrderedList :: TagParser Blocks
256273pOrderedList = try $ do
257274 TagOpen _ attribs <- pSatisfy (~== TagOpen "ol" [])
@@ -261,23 +278,19 @@ pOrderedList = try $ do
261278 sta' = if all isDigit sta
262279 then read sta
263280 else 1
264− sty = fromMaybe (fromMaybe "" $
265− lookup "style" attribs) $
266− lookup "class" attribs
267− sty' = case sty of
268− "lower-roman" -> LowerRoman
269− "upper-roman" -> UpperRoman
270− "lower-alpha" -> LowerAlpha
271− "upper-alpha" -> UpperAlpha
272− "decimal" -> Decimal
273− _ ->
274− case lookup "type" attribs of
275− Just "1" -> Decimal
276− Just "I" -> UpperRoman
277− Just "i" -> LowerRoman
278− Just "A" -> UpperAlpha
279− Just "a" -> LowerAlpha
280− _ -> DefaultStyle
281+
282+ pickListStyle = pickStyleAttrProps ["list-style-type", "list-style"]
283+
284+ typeAttr = fromMaybe "" $ lookup "type" attribs
285+ classAttr = fromMaybe "" $ lookup "class" attribs
286+ styleAttr = fromMaybe "" $ lookup "style" attribs
287+ listStyle = fromMaybe "" $ pickListStyle styleAttr
288+
289+ sty' = foldOrElse DefaultStyle
290+ [ parseTypeAttr typeAttr
291+ , parseListStyleType classAttr
292+ , parseListStyleType listStyle
293+ ]
281294 let nonItem = pSatisfy (\t ->
282295 not (tagOpen (`elem` ["li","ol","ul","dl"]) (const True) t) &&
283296 not (t ~== TagClose "ol"))
@@ -622,12 +635,11 @@ pSpan = try $ do
622635 guardEnabled Ext_native_spans
623636 TagOpen _ attr <- lookAhead $ pSatisfy $ tagOpen (=="span") (const True)
624637 contents <- pInTags "span" inline
625− let attr' = mkAttr attr
626− return $ case attr' of
627− ("",[],[("style",s)])
628− | filter (`notElem` " \t;") s == "font-variant:small-caps" ->
629− B.smallcaps contents
630− _ -> B.spanWith (mkAttr attr) contents
638+ let isSmallCaps = fontVariant == "small-caps"
639+ where styleAttr = fromMaybe "" $ lookup "style" attr
640+ fontVariant = fromMaybe "" $ pickStyleAttrProps ["font-variant"] styleAttr
641+ let tag = if isSmallCaps then B.smallcaps else B.spanWith (mkAttr attr)
642+ return $ tag contents
631643
632644pRawHtmlInline :: TagParser Inlines
633645pRawHtmlInline = do