From e8ce21d614b0a65a1cc1a9d3e41e6e38220875d8 Mon Sep 17 00:00:00 2001 From: ickc Date: Wed, 16 Nov 2016 02:53:51 -0800 Subject: [PATCH] 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 --- MANUAL.txt | 4 ++++ man/pandoc.1 | 8 ++++++++ src/Text/Pandoc/Readers/Markdown.hs | 8 +++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/MANUAL.txt b/MANUAL.txt index d987919d9..379c61ca5 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -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 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 ---- diff --git a/man/pandoc.1 b/man/pandoc.1 index 42a7ad10d..e02ed270e 100644 --- a/man/pandoc.1 +++ b/man/pandoc.1 @@ -3388,6 +3388,14 @@ To write small caps, you can use an HTML span tag: .PP (The semicolon is optional and there may be space after the colon.) This 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 Extension: \f[C]tex_math_dollars\f[] .PP diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index b3459eec0..20a478aa9 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1764,7 +1764,13 @@ bracketedSpan = try $ do guardEnabled Ext_bracketed_spans (lab,_) <- reference 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) -> F Inlines -> MarkdownParser (F Inlines)