aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-07-25 11:55:48 -0700
committerJohn MacFarlane <[email protected]>2022-07-25 11:55:48 -0700
commitac7fa3da4d70433d367274bc19c726e1c30f7a81 (patch)
treecacb0bc3f95e01a3abfa65b595695458e278e55b /src
parentb7bc98008996eb6186c8f823d75ec3d6b980958e (diff)
HTML writer: Allow "spanlike" classes to be combined.
Previously classes like "underline" and "marked" had to be the first class in a span in order for the span to be interpreted as a "ul" or "mark" element. This commit allows these special classes to be "stacked," e.g. `[test]{.mark .underline}`; in addition, the special classes are no longer required to come first in the list of classes. See #8194 for context.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs29
1 files changed, 21 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)