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.
This commit is contained in:
John MacFarlane 2014-06-20 15:24:24 -07:00
parent d397a66107
commit 5d0103606f
2 changed files with 14 additions and 1 deletions

8
README
View file

@ -2020,6 +2020,14 @@ Attributes can be attached to verbatim text, just as with
`<$>`{.haskell}
### Small caps ###
To write small caps, you can use an HTML span tag:
<span style="font-variant:small-caps;">Small caps</span>
This will work in all output formats that support small caps.
Math
----

View file

@ -1736,7 +1736,12 @@ spanHtml = try $ do
let ident = fromMaybe "" $ lookup "id" attrs
let classes = maybe [] words $ lookup "class" attrs
let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]
return $ B.spanWith (ident, classes, keyvals) <$> contents
case lookup "style" keyvals of
Just s | null ident && null classes &&
map toLower (filter (`notElem` " \t;") s) ==
"font-variant:small-caps"
-> return $ B.smallcaps <$> contents
_ -> return $ B.spanWith (ident, classes, keyvals) <$> contents
divHtml :: MarkdownParser (F Blocks)
divHtml = try $ do