git.iko.soy/typeable/pandoc
on master help sign in
Shared.stringify, removeFormatting: handle Quoted better.

Previously we were losing the qutation marks in Quoted elements. See #3958.

commit7d2ff7ed6d1cdd1b30d52e58decd830e1b8f819d authorJohn MacFarlane <jgm@berkeley.edu> dateSun 8 Oct 2017, 21:55 (9 years ago) parentad13189
1 file changed+9−2
src/Text/Pandoc/Shared.hs+9−2
src/Text/Pandoc/Shared.hs+9−2
@@ -353,7 +353,7 @@ extractSpaces f is =
353353
354354-- | Extract inlines, removing formatting.
355355removeFormatting :: Walkable Inline a => a -> [Inline]
356−removeFormatting = query go . walk deNote
356+removeFormatting = query go . walk (deNote . deQuote)
357357 where go :: Inline -> [Inline]
358358 go (Str xs) = [Str xs]
359359 go Space = [Space]
@@ -367,11 +367,18 @@ deNote :: Inline -> Inline
367367deNote (Note _) = Str ""
368368deNote x = x
369369
370+deQuote :: Inline -> Inline
371+deQuote (Quoted SingleQuote xs) =
372+ Span ("",[],[]) (Str "\8216" : xs ++ [Str "\8217"])
373+deQuote (Quoted DoubleQuote xs) =
374+ Span ("",[],[]) (Str "\8220" : xs ++ [Str "\8221"])
375+deQuote x = x
376+
370377-- | Convert pandoc structure to a string with formatting removed.
371378-- Footnotes are skipped (since we don't want their contents in link
372379-- labels).
373380stringify :: Walkable Inline a => a -> String
374−stringify = query go . walk deNote
381+stringify = query go . walk (deNote . deQuote)
375382 where go :: Inline -> [Char]
376383 go Space = " "
377384 go SoftBreak = " "