aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/HTML.hs
diff options
context:
space:
mode:
authorOle Martin Ruud <barskern@outlook.com>2019-10-25 07:27:49 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2019-10-24 22:27:49 -0700
commit45479114e88a351fc63bb8eff142bb10cfd2c661 (patch)
treec7942576b5f590b78bab5c74c88a6a843afa78bd /src/Text/Pandoc/Writers/HTML.hs
parent91c325c714050313429f6d553d7fa1bef15892a2 (diff)
downloadpandoc-45479114e88a351fc63bb8eff142bb10cfd2c661.tar.gz
HTML reader/writer: Better handling of <q> with cite attribute (#5837)
* HTML reader: Handle cite attribute for quotes. If a `<q>` tag has a `cite` attribute, we interpret it as a Quoted element with an inner Span. Closes #5798 * Refactor url canonicalization into a helper function * Modify HTML writer to handle quote with cite. [0]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/q
Diffstat (limited to 'src/Text/Pandoc/Writers/HTML.hs')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index a1a617829..08d8345b0 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE CPP #-}
+{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
@@ -1047,10 +1048,17 @@ inlineToHtml opts inline = do
strToHtml "’")
DoubleQuote -> (strToHtml "“",
strToHtml "”")
- in if writerHtmlQTags opts
+
+ in if writerHtmlQTags opts
then do
modify $ \st -> st{ stQuotes = True }
- H.q `fmap` inlineListToHtml opts lst
+ let (maybeAttr, lst') = case lst of
+ [Span attr@(_, _, kvs) cs]
+ | any ((=="cite") . fst) kvs
+ -> (Just attr, cs)
+ cs -> (Nothing, cs)
+ H.q `fmap` inlineListToHtml opts lst'
+ >>= maybe return (addAttrs opts) maybeAttr
else (\x -> leftQuote >> x >> rightQuote)
`fmap` inlineListToHtml opts lst
(Math t str) -> do