From 66d459a545b0ddfa372a5abd200fb8916677785b Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sun, 19 Oct 2008 00:33:12 +0000 Subject: Don't print a line break between a footnote and immediately following nonspace in LaTeX and ConTeXt output, as it is interpreted as a space. This is problematic for cases like "text^[note]---". Modified wrappedTeX (in Text.Pandoc.Shared). Resolves Issue #93. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1469 788f1e2b-df1e-0410-8736-df70ead52e1b --- Text/Pandoc/Shared.hs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'Text') diff --git a/Text/Pandoc/Shared.hs b/Text/Pandoc/Shared.hs index b3682e4b8..6485372db 100644 --- a/Text/Pandoc/Shared.hs +++ b/Text/Pandoc/Shared.hs @@ -243,13 +243,22 @@ wrappedTeX includePercent listWriter sect = do if null rest then return firstpartWrapped else do let (note:rest') = rest - restWrapped <- if null rest' - then return empty - else wrappedTeX includePercent listWriter rest' + let (rest1, rest2) = break (== Space) rest' + -- rest1 is whatever comes between the note and a Space. + -- if the note is followed directly by a Space, rest1 is null. + -- rest1 is printed after the note but before the line break, + -- to avoid spurious blank space the note and immediately + -- following punctuation. + rest1Out <- if null rest1 + then return empty + else listWriter rest1 + rest2Wrapped <- if null rest2 + then return empty + else wrappedTeX includePercent listWriter (tail rest2) noteText <- listWriter [note] - return $ firstpartWrapped <> - (if includePercent then PP.char '%' else empty) $$ - noteText $$ restWrapped + return $ (firstpartWrapped <> if includePercent then PP.char '%' else empty) $$ + (noteText <> rest1Out) $$ + rest2Wrapped -- | Wrap inlines if the text wrap option is selected, specialized -- for LaTeX and ConTeXt. -- cgit v1.2.3