summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-10-08 21:55:57 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-10-08 21:55:57 -0700
commit7d2ff7ed6d1cdd1b30d52e58decd830e1b8f819d (patch)
tree36323e3a73d689256f16cbe14634b51355cf8d35 /src/Text/Pandoc
parentad13189c8f3ce051a29817550f2619c912439edb (diff)
Shared.stringify, removeFormatting: handle Quoted better.
Previously we were losing the qutation marks in Quoted elements. See #3958.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Shared.hs11
1 files changed, 9 insertions, 2 deletions
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 = " "