From 45479114e88a351fc63bb8eff142bb10cfd2c661 Mon Sep 17 00:00:00 2001 From: Ole Martin Ruud Date: Fri, 25 Oct 2019 07:27:49 +0200 Subject: HTML reader/writer: Better handling of with cite attribute (#5837) * HTML reader: Handle cite attribute for quotes. If a `` 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 --- src/Text/Pandoc/Writers/HTML.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') 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 -- cgit v1.2.3