From d2105f66930f4d14bbeabe2bbbe4f764bb9cb10f Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Thu, 21 Dec 2006 19:33:57 +0000 Subject: + Added regression tests with footnotes in quote blocks and lists. + This uncovered an existing bug in the RTF writer, which got indentation wrong on footnotes occuring in indented blocks like lists. Fixed this bug. git-svn-id: https://pandoc.googlecode.com/svn/trunk@263 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Writers/RTF.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs index 6ae32df8b..19b4a5934 100644 --- a/src/Text/Pandoc/Writers/RTF.hs +++ b/src/Text/Pandoc/Writers/RTF.hs @@ -32,6 +32,7 @@ module Text.Pandoc.Writers.RTF ( ) where import Text.Pandoc.Definition import Text.Pandoc.Shared +import Text.Regex ( matchRegexAll, mkRegex ) import List ( isSuffixOf ) import Char ( ord, chr ) @@ -189,9 +190,12 @@ listItemToRTF notes indent marker [] = (marker ++ "\\tx" ++ (show listIncrement) ++ "\\tab ") listItemToRTF notes indent marker list = let (first:rest) = map (blockToRTF notes (indent + listIncrement)) list in - let modFirst = gsub "\\\\fi-?[0-9]+" ("\\\\fi" ++ - (show (0 - listIncrement)) ++ " " ++ marker ++ - "\\\\tx" ++ (show listIncrement) ++ "\\\\tab") first in + -- insert the list marker into the (processed) first block + let modFirst = case matchRegexAll (mkRegex "\\\\fi-?[0-9]+") first of + Just (before, matched, after, _) -> before ++ "\\fi" ++ + show (0 - listIncrement) ++ " " ++ marker ++ "\\tx" ++ + show listIncrement ++ "\\tab" ++ after + Nothing -> first in modFirst ++ (concat rest) -- | Convert list of inline items to RTF. -- cgit v1.2.3