git.iko.soy/typeable/pandoc
on master help sign in
Don't print a line break between a footnote and immediately following nonspace
66d459afiddlosopher
Text/Pandoc/Shared.hs+15−6
@@ -243,13 +243,22 @@ wrappedTeX includePercent listWriter sect = do
243 if null rest
243 if null rest
244 then return firstpartWrapped
244 then return firstpartWrapped
245 else do let (note:rest') = rest
245 else do let (note:rest') = rest
246− restWrapped <- if null rest'
246+ let (rest1, rest2) = break (== Space) rest'
247+ -- rest1 is whatever comes between the note and a Space.
248+ -- if the note is followed directly by a Space, rest1 is null.
249+ -- rest1 is printed after the note but before the line break,
250+ -- to avoid spurious blank space the note and immediately
251+ -- following punctuation.
252+ rest1Out <- if null rest1
247− then return empty
253+ then return empty
254+ else listWriter rest1
255+ rest2Wrapped <- if null rest2
256+ then return empty
248− else wrappedTeX includePercent listWriter rest'
257+ else wrappedTeX includePercent listWriter (tail rest2)
249 noteText <- listWriter [note]
258 noteText <- listWriter [note]
250− return $ firstpartWrapped <>
251− (if includePercent then PP.char '%' else empty) $$
259+ return $ (firstpartWrapped <> if includePercent then PP.char '%' else empty) $$
252− noteText $$ restWrapped
260+ (noteText <> rest1Out) $$
261+ rest2Wrapped
253
262
254-- | Wrap inlines if the text wrap option is selected, specialized
263-- | Wrap inlines if the text wrap option is selected, specialized
255-- for LaTeX and ConTeXt.
264-- for LaTeX and ConTeXt.