Small caps in Bracketed Spans (#3191)

* Markdown reader: modify bracketedSpan to check small caps

* MANUAL.txt: add description on the use of `bracketed_spans` in small cap

* Improve markdown readers: bracketedSpan function EXACTLY as spanHtml
This commit is contained in:
ickc 2016-11-16 02:53:51 -08:00 committed by John MacFarlane
parent 0dfcedad7e
commit e8ce21d614
3 changed files with 19 additions and 1 deletions

View file

@ -2736,6 +2736,10 @@ To write small caps, you can use an HTML span tag:
(The semicolon is optional and there may be space after the (The semicolon is optional and there may be space after the
colon.) This will work in all output formats that support small caps. colon.) This will work in all output formats that support small caps.
Alternatively, you can also use the new `bracketed_spans` syntax:
[Small caps]{style="font-variant:small-caps;"}
Math Math
---- ----

View file

@ -3388,6 +3388,14 @@ To write small caps, you can use an HTML span tag:
.PP .PP
(The semicolon is optional and there may be space after the colon.) This (The semicolon is optional and there may be space after the colon.) This
will work in all output formats that support small caps. will work in all output formats that support small caps.
.PP
Alternatively, you can also use the new \f[C]bracketed_spans\f[] syntax:
.IP
.nf
\f[C]
[Small\ caps]{style="font\-variant:small\-caps;"}
\f[]
.fi
.SS Math .SS Math
.SS Extension: \f[C]tex_math_dollars\f[] .SS Extension: \f[C]tex_math_dollars\f[]
.PP .PP

View file

@ -1764,7 +1764,13 @@ bracketedSpan = try $ do
guardEnabled Ext_bracketed_spans guardEnabled Ext_bracketed_spans
(lab,_) <- reference (lab,_) <- reference
attr <- attributes attr <- attributes
return $ B.spanWith attr <$> lab let (ident,classes,keyvals) = attr
case lookup "style" keyvals of
Just s | null ident && null classes &&
map toLower (filter (`notElem` " \t;") s) ==
"font-variant:small-caps"
-> return $ B.smallcaps <$> lab
_ -> return $ B.spanWith attr <$> lab
regLink :: (Attr -> String -> String -> Inlines -> Inlines) regLink :: (Attr -> String -> String -> Inlines -> Inlines)
-> F Inlines -> MarkdownParser (F Inlines) -> F Inlines -> MarkdownParser (F Inlines)