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. diff --git a/tests/testsuite.native b/tests/testsuite.native index 910de1f39..4f1efaec7 100644 --- a/tests/testsuite.native +++ b/tests/testsuite.native @@ -319,6 +319,12 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane , HorizontalRule , Header 1 [Str "Footnotes"] , Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference,",NoteRef "1",Space,Str "and",Space,Str "another.",NoteRef "2",Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space.",Str "[",Str "^",Str "my",Space,Str "note",Str "]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note.",NoteRef "3"] +, BlockQuote + [ Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",NoteRef "4"] ] + +, OrderedList + [ [ Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",NoteRef "5"] ] + ] , Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented."] , Note "1" [ Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference.",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."] ] @@ -330,4 +336,10 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane , Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."] ] , Note "3" [ Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] (Src "http://google.com" ""),Space,Str "and",Space,Code "]",Space,Str "verbatim",Space,Str "characters."] ] + +, Note "4" + [ Para [Str "In",Space,Str "quote."] ] + +, Note "5" + [ Para [Str "In",Space,Str "list."] ] ] diff --git a/tests/testsuite.txt b/tests/testsuite.txt index 9d6481126..2d3b7967d 100644 --- a/tests/testsuite.txt +++ b/tests/testsuite.txt @@ -596,6 +596,10 @@ contains a space.[^my note] Here is an inline note.^[This is *easier* to type. Inline notes may contain [links](http://google.com) and `]` verbatim characters.] +> Notes can go in quotes.^[In quote.] + +1. And in list items.^[In list.] + [^longnote]: Here's the long note. This one contains multiple blocks. diff --git a/tests/writer.html b/tests/writer.html index 2d067c8d5..c421d24c4 100644 --- a/tests/writer.html +++ b/tests/writer.html @@ -473,6 +473,12 @@ document.write(''+e+'<\/'+'a'+'>');
Here is a footnote reference,1 and another.2 This should not be a footnote reference, because it contains a space.[^my note] Here is an inline note.3
+++Notes can go in quotes.4
+
This paragraph should not be part of the note, as it is not indented.