From 7d2ff7ed6d1cdd1b30d52e58decd830e1b8f819d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 8 Oct 2017 21:55:57 -0700 Subject: Shared.stringify, removeFormatting: handle Quoted better. Previously we were losing the qutation marks in Quoted elements. See #3958. --- src/Text/Pandoc/Shared.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 9f88a0ad4..f0c2f172e 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -353,7 +353,7 @@ extractSpaces f is = -- | Extract inlines, removing formatting. removeFormatting :: Walkable Inline a => a -> [Inline] -removeFormatting = query go . walk deNote +removeFormatting = query go . walk (deNote . deQuote) where go :: Inline -> [Inline] go (Str xs) = [Str xs] go Space = [Space] @@ -367,11 +367,18 @@ deNote :: Inline -> Inline deNote (Note _) = Str "" deNote x = x +deQuote :: Inline -> Inline +deQuote (Quoted SingleQuote xs) = + Span ("",[],[]) (Str "\8216" : xs ++ [Str "\8217"]) +deQuote (Quoted DoubleQuote xs) = + Span ("",[],[]) (Str "\8220" : xs ++ [Str "\8221"]) +deQuote x = x + -- | Convert pandoc structure to a string with formatting removed. -- Footnotes are skipped (since we don't want their contents in link -- labels). stringify :: Walkable Inline a => a -> String -stringify = query go . walk deNote +stringify = query go . walk (deNote . deQuote) where go :: Inline -> [Char] go Space = " " go SoftBreak = " " -- cgit v1.2.3