Fixed some loose ends in #1592.
Added test cases. Fixed HTML reader to parse a span with class "smallcaps" as SmallCaps. Fixed Markdown writer to render SmallCaps as a native span when native spans are enabled.
This commit is contained in:
parent
40d1dc417a
commit
0517cf0bc0
3 changed files with 53 additions and 5 deletions
|
@ -684,9 +684,11 @@ pSpan = try $ do
|
|||
guardEnabled Ext_native_spans
|
||||
TagOpen _ attr <- lookAhead $ pSatisfy $ tagOpen (=="span") (const True)
|
||||
contents <- pInTags "span" inline
|
||||
let isSmallCaps = fontVariant == "small-caps"
|
||||
let isSmallCaps = fontVariant == "small-caps" || "smallcaps" `elem` classes
|
||||
where styleAttr = fromMaybe "" $ lookup "style" attr
|
||||
fontVariant = fromMaybe "" $ pickStyleAttrProps ["font-variant"] styleAttr
|
||||
classes = fromMaybe [] $
|
||||
words <$> lookup "class" attr
|
||||
let tag = if isSmallCaps then B.smallcaps else B.spanWith (mkAttr attr)
|
||||
return $ tag contents
|
||||
|
||||
|
|
|
@ -971,10 +971,7 @@ inlineToMarkdown opts (SmallCaps lst) = do
|
|||
plain <- asks envPlain
|
||||
if not plain &&
|
||||
(isEnabled Ext_raw_html opts || isEnabled Ext_native_spans opts)
|
||||
then do
|
||||
contents <- inlineListToMarkdown opts lst
|
||||
return $ tagWithAttrs "span" ("",["smallcaps"],[])
|
||||
<> contents <> text "</span>"
|
||||
then inlineToMarkdown opts (Span ("",["smallcaps"],[]) lst)
|
||||
else inlineListToMarkdown opts $ capitalize lst
|
||||
inlineToMarkdown opts (Quoted SingleQuote lst) = do
|
||||
contents <- inlineListToMarkdown opts lst
|
||||
|
|
49
test/command/1592.md
Normal file
49
test/command/1592.md
Normal file
|
@ -0,0 +1,49 @@
|
|||
```
|
||||
% pandoc -t native
|
||||
[hi]{.smallcaps}
|
||||
^D
|
||||
[Para [SmallCaps [Str "hi"]]]
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -t native
|
||||
[hi]{style="font-variant: small-caps;"}
|
||||
^D
|
||||
[Para [SmallCaps [Str "hi"]]]
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -t native
|
||||
<span class="smallcaps">hi</span>
|
||||
^D
|
||||
[Para [SmallCaps [Str "hi"]]]
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f html -t native
|
||||
<p><span class="smallcaps">hi</span></p>
|
||||
^D
|
||||
[Para [SmallCaps [Str "hi"]]]
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f html -t native
|
||||
<p><span style="font-variant:small-caps">hi</span></p>
|
||||
^D
|
||||
[Para [SmallCaps [Str "hi"]]]
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f native -t html
|
||||
[Para [SmallCaps [Str "hi"]]]
|
||||
^D
|
||||
<p><span class="smallcaps">hi</span></p>
|
||||
```
|
||||
|
||||
```
|
||||
pandoc -f native -t markdown
|
||||
[Para [SmallCaps [Str "hi"]]]
|
||||
^D
|
||||
[hi]{.smallcaps}
|
||||
```
|
||||
|
Loading…
Reference in a new issue