@@ -64,6 +64,7 @@ import Data.Default (Default (..), def)
64import Control.Monad.Reader (Reader,ask, asks, local, runReader)
64import Control.Monad.Reader (Reader,ask, asks, local, runReader)
65import Network.URI (isURI)
65import Network.URI (isURI)
66import Text.Pandoc.Error
66import Text.Pandoc.Error
67+import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps)
68import Text.Parsec.Error
69import Text.Parsec.Error
@@ -252,6 +253,22 @@ pListItem nonItem = do
252 let liDiv = maybe mempty (\x -> B.divWith (x, [], []) mempty) (lookup "id" attr)
253 let liDiv = maybe mempty (\x -> B.divWith (x, [], []) mempty) (lookup "id" attr)
253 (liDiv <>) <$> pInTags "li" block <* skipMany nonItem
254 (liDiv <>) <$> pInTags "li" block <* skipMany nonItem
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
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
255pOrderedList :: TagParser Blocks
272pOrderedList :: TagParser Blocks
256pOrderedList = try $ do
273pOrderedList = try $ do
257 TagOpen _ attribs <- pSatisfy (~== TagOpen "ol" [])
274 TagOpen _ attribs <- pSatisfy (~== TagOpen "ol" [])
@@ -261,23 +278,19 @@ pOrderedList = try $ do
261 sta' = if all isDigit sta
278 sta' = if all isDigit sta
262 then read sta
279 then read sta
264− sty = fromMaybe (fromMaybe "" $
281+
282+ pickListStyle = pickStyleAttrProps ["list-style-type", "list-style"]
265− lookup "style" attribs) $
284+ typeAttr = fromMaybe "" $ lookup "type" attribs
266− lookup "class" attribs
285+ classAttr = fromMaybe "" $ lookup "class" attribs
267− sty' = case sty of
286+ styleAttr = fromMaybe "" $ lookup "style" attribs
268− "lower-roman" -> LowerRoman
287+ listStyle = fromMaybe "" $ pickListStyle styleAttr
269− "upper-roman" -> UpperRoman
288+
270− "lower-alpha" -> LowerAlpha
271− "upper-alpha" -> UpperAlpha
272− "decimal" -> Decimal
274− case lookup "type" attribs of
276− Just "I" -> UpperRoman
277− Just "i" -> LowerRoman
278− Just "A" -> UpperAlpha
279− Just "a" -> LowerAlpha
280− _ -> DefaultStyle
289+ sty' = foldOrElse DefaultStyle
290+ [ parseTypeAttr typeAttr
291+ , parseListStyleType classAttr
292+ , parseListStyleType listStyle
281 let nonItem = pSatisfy (\t ->
294 let nonItem = pSatisfy (\t ->
282 not (tagOpen (`elem` ["li","ol","ul","dl"]) (const True) t) &&
295 not (tagOpen (`elem` ["li","ol","ul","dl"]) (const True) t) &&
283 not (t ~== TagClose "ol"))
296 not (t ~== TagClose "ol"))
@@ -622,12 +635,11 @@ pSpan = try $ do
622 guardEnabled Ext_native_spans
635 guardEnabled Ext_native_spans
623 TagOpen _ attr <- lookAhead $ pSatisfy $ tagOpen (=="span") (const True)
636 TagOpen _ attr <- lookAhead $ pSatisfy $ tagOpen (=="span") (const True)
624 contents <- pInTags "span" inline
637 contents <- pInTags "span" inline
625− let attr' = mkAttr attr
638+ let isSmallCaps = fontVariant == "small-caps"
626− return $ case attr' of
639+ where styleAttr = fromMaybe "" $ lookup "style" attr
627− ("",[],[("style",s)])
640+ fontVariant = fromMaybe "" $ pickStyleAttrProps ["font-variant"] styleAttr
628− | filter (`notElem` " \t;") s == "font-variant:small-caps" ->
629− B.smallcaps contents
630− _ -> B.spanWith (mkAttr attr) contents
641+ let tag = if isSmallCaps then B.smallcaps else B.spanWith (mkAttr attr)
642+ return $ tag contents
632pRawHtmlInline :: TagParser Inlines
644pRawHtmlInline :: TagParser Inlines
633pRawHtmlInline = do
645pRawHtmlInline = do