git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Support smallcaps through span.

`<span style="font-variant:small-caps;">foo</span>` will be parsed as a `SmallCaps` inline, and will work in all output formats that support small caps. Closes #1360.

commit5d0103606f469a6336beb2f7a90f210dd29485bd authorJohn MacFarlane <jgm@berkeley.edu> dateFri 20 Jun 2014, 15:24 (12 years ago) parentd397a66
2 files changed+14−1
README+8 src/Text/Pandoc/Readers/Markdown.hs+6−1
README+8
@@ -2020,6 +2020,14 @@ Attributes can be attached to verbatim text, just as with
20202020
20212021 `<$>`{.haskell}
20222022
2023+### Small caps ###
2024+
2025+To write small caps, you can use an HTML span tag:
2026+
2027+ <span style="font-variant:small-caps;">Small caps</span>
2028+
2029+This will work in all output formats that support small caps.
2030+
20232031Math
20242032----
20252033
src/Text/Pandoc/Readers/Markdown.hs+6−1
@@ -1736,7 +1736,12 @@ spanHtml = try $ do
17361736 let ident = fromMaybe "" $ lookup "id" attrs
17371737 let classes = maybe [] words $ lookup "class" attrs
17381738 let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]
1739− return $ B.spanWith (ident, classes, keyvals) <$> contents
1739+ case lookup "style" keyvals of
1740+ Just s | null ident && null classes &&
1741+ map toLower (filter (`notElem` " \t;") s) ==
1742+ "font-variant:small-caps"
1743+ -> return $ B.smallcaps <$> contents
1744+ _ -> return $ B.spanWith (ident, classes, keyvals) <$> contents
17401745
17411746divHtml :: MarkdownParser (F Blocks)
17421747divHtml = try $ do