summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs29
-rw-r--r--test/command/nested-spanlike.md6
2 files changed, 27 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index a8c662e09..cdbf11e1e 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -1389,15 +1389,28 @@ inlineToHtml opts inline = do
-> inlineListToHtml opts ils >>= inDiv cls
(Span (id',classes,kvs) ils) ->
- let spanLikeTag = case classes of
- (c:_) -> do
- guard (c `Set.member` htmlSpanLikeElements)
- pure $ customParent (textTag c)
- _ -> Nothing
- in case spanLikeTag of
- Just tag -> do
+ let go Nothing c
+ | c `Set.member` htmlSpanLikeElements
+ = Just (customParent (textTag c), [])
+ | c == "smallcaps"
+ = Just (H.span ! A.class_ "smallcaps", [])
+ | c == "underline"
+ = Just (H.u, [])
+ | otherwise = Nothing
+ go (Just (t,cs)) c
+ | c `Set.member` htmlSpanLikeElements
+ = Just (t . customParent (textTag c), cs)
+ | c == "smallcaps"
+ = Just (t . (H.span ! A.class_ "smallcaps"), cs)
+ | c == "underline"
+ = Just (t . H.u, cs)
+ | otherwise
+ = Just (t, c:cs)
+ spanLikeTags = foldl' go Nothing
+ in case spanLikeTags classes of
+ Just (tag, cs) -> do
h <- inlineListToHtml opts ils
- addAttrs opts (id',tail classes',kvs') $ tag h
+ addAttrs opts (id',cs,kvs') $ tag h
Nothing -> do
h <- inlineListToHtml opts ils
addAttrs opts (id',classes',kvs') (H.span h)
diff --git a/test/command/nested-spanlike.md b/test/command/nested-spanlike.md
new file mode 100644
index 000000000..98d634052
--- /dev/null
+++ b/test/command/nested-spanlike.md
@@ -0,0 +1,6 @@
+```
+% pandoc -f markdown -t html
+[test]{.foo .underline #bar .smallcaps .kbd}
+^D
+<p><u id="bar"><span class="smallcaps"><kbd>test</kbd></span></u></p>
+```