git.iko.soy/typeable/pandoc
on master help sign in
HTML reader: Parse appropriately styled span as SmallCaps.
commit9d52ecdd422a6821c9f37f53e3d30d4be4e41e8f authorJohn MacFarlane <jgm@berkeley.edu> dateSat 16 Aug 2014, 22:57 (12 years ago) parentcb4ae61
3 files changed+8−1
src/Text/Pandoc/Readers/HTML.hs+6−1 tests/html-reader.html+1 tests/html-reader.native+1
src/Text/Pandoc/Readers/HTML.hs+6−1
@@ -570,7 +570,12 @@ pSpan = try $ do
570570 guardEnabled Ext_native_spans
571571 TagOpen _ attr <- lookAhead $ pSatisfy $ tagOpen (=="span") (const True)
572572 contents <- pInTags "span" inline
573− return $ B.spanWith (mkAttr attr) contents
573+ let attr' = mkAttr attr
574+ return $ case attr' of
575+ ("",[],[("style",s)])
576+ | filter (`notElem` " \t;") s == "font-variant:small-caps" ->
577+ B.smallcaps contents
578+ _ -> B.spanWith (mkAttr attr) contents
574579
575580pRawHtmlInline :: TagParser Inlines
576581pRawHtmlInline = do
tests/html-reader.html+1
@@ -309,6 +309,7 @@ These should not be escaped: \$ \\ \> \[ \{
309309<p><strong><em>This is strong and em.</em></strong></p>
310310<p>So is <strong><em>this</em></strong> word.</p>
311311<p>This is code: <code>&gt;</code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code>&lt;html&gt;</code>.</p>
312+<p>This is <span style="font-variant: small-caps;">small caps</span>.</p>
312313<hr />
313314<h1>Smart quotes, ellipses, dashes</h1>
314315<p>"Hello," said the spider. "'Shelob' is my name."</p>
tests/html-reader.native+1
@@ -193,6 +193,7 @@ Pandoc (Meta {unMeta = fromList [("generator",MetaInlines [Str "pandoc"]),("titl
193193,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
194194,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
195195,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
196+,Para [Str "This",Space,Str "is",Space,SmallCaps [Str "small",Space,Str "caps"],Str "."]
196197,HorizontalRule
197198,Header 1 ("",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
198199,Para [Str "\"Hello,\"",Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Str "\"'Shelob'",Space,Str "is",Space,Str "my",Space,Str "name.\""]