git.iko.soy/typeable/pandoc
on master help sign in
+ 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

commitd2105f66930f4d14bbeabe2bbbe4f764bb9cb10f authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 21 Dec 2006, 19:33 (20 years ago) parent48b8267
10 files changed+85−3
src/Text/Pandoc/Writers/RTF.hs+7−3 tests/testsuite.native+12 tests/testsuite.txt+4 tests/writer.html+10 tests/writer.latex+7 tests/writer.markdown+10 tests/writer.native+12 tests/writer.rst+9 tests/writer.rtf+4 tests/writer.smart.html+10
src/Text/Pandoc/Writers/RTF.hs+7−3
@@ -32,6 +32,7 @@ module Text.Pandoc.Writers.RTF (
3232 ) where
3333import Text.Pandoc.Definition
3434import Text.Pandoc.Shared
35+import Text.Regex ( matchRegexAll, mkRegex )
3536import List ( isSuffixOf )
3637import Char ( ord, chr )
3738
@@ -189,9 +190,12 @@ listItemToRTF notes indent marker [] =
189190 (marker ++ "\\tx" ++ (show listIncrement) ++ "\\tab ")
190191listItemToRTF notes indent marker list =
191192 let (first:rest) = map (blockToRTF notes (indent + listIncrement)) list in
192− let modFirst = gsub "\\\\fi-?[0-9]+" ("\\\\fi" ++
193− (show (0 - listIncrement)) ++ " " ++ marker ++
194− "\\\\tx" ++ (show listIncrement) ++ "\\\\tab") first in
193+ -- insert the list marker into the (processed) first block
194+ let modFirst = case matchRegexAll (mkRegex "\\\\fi-?[0-9]+") first of
195+ Just (before, matched, after, _) -> before ++ "\\fi" ++
196+ show (0 - listIncrement) ++ " " ++ marker ++ "\\tx" ++
197+ show listIncrement ++ "\\tab" ++ after
198+ Nothing -> first in
195199 modFirst ++ (concat rest)
196200
197201-- | Convert list of inline items to RTF.
tests/testsuite.native+12
@@ -319,6 +319,12 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
319319, HorizontalRule
320320, Header 1 [Str "Footnotes"]
321321, 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"]
322+, BlockQuote
323+ [ Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",NoteRef "4"] ]
324+
325+, OrderedList
326+ [ [ Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",NoteRef "5"] ]
327+ ]
322328, 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."]
323329, Note "1"
324330 [ 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
330336 , 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."] ]
331337, Note "3"
332338 [ 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."] ]
339+
340+, Note "4"
341+ [ Para [Str "In",Space,Str "quote."] ]
342+
343+, Note "5"
344+ [ Para [Str "In",Space,Str "list."] ]
333345 ]
tests/testsuite.txt+4
@@ -596,6 +596,10 @@ contains a space.[^my note] Here is an inline note.^[This
596596is *easier* to type. Inline notes may contain
597597[links](http://google.com) and `]` verbatim characters.]
598598
599+> Notes can go in quotes.^[In quote.]
600+
601+1. And in list items.^[In list.]
602+
599603[^longnote]: Here's the long note. This one contains multiple
600604blocks.
601605
tests/writer.html+10
@@ -473,6 +473,12 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>');
473473<a id="Footnotes"></a>
474474<h1>Footnotes</h1>
475475<p>Here is a footnote reference,<sup class="footnoteRef" id="fnref1"><a href="#fn1">1</a></sup> and another.<sup class="footnoteRef" id="fnref2"><a href="#fn2">2</a></sup> This should <em>not</em> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<sup class="footnoteRef" id="fnref3"><a href="#fn3">3</a></sup></p>
476+<blockquote>
477+<p>Notes can go in quotes.<sup class="footnoteRef" id="fnref4"><a href="#fn4">4</a></sup></p>
478+</blockquote>
479+<ol>
480+<li>And in list items.<sup class="footnoteRef" id="fnref5"><a href="#fn5">5</a></sup></li>
481+</ol>
476482<p>This paragraph should not be part of the note, as it is not indented.</p>
477483<div class="footnotes">
478484<hr />
@@ -487,6 +493,10 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>');
487493 <a href="#fnref2" class="footnoteBacklink" title="Jump back to footnote 2">&#8617;</a></li>
488494<li id="fn3"><p>This is <em>easier</em> to type. Inline notes may contain <a href="http://google.com">links</a> and <code>]</code> verbatim characters.</p>
489495 <a href="#fnref3" class="footnoteBacklink" title="Jump back to footnote 3">&#8617;</a></li>
496+<li id="fn4"><p>In quote.</p>
497+ <a href="#fnref4" class="footnoteBacklink" title="Jump back to footnote 4">&#8617;</a></li>
498+<li id="fn5"><p>In list.</p>
499+ <a href="#fnref5" class="footnoteBacklink" title="Jump back to footnote 5">&#8617;</a></li>
490500</ol>
491501</div>
492502</body>
tests/writer.latex+7
@@ -576,6 +576,13 @@ Subsequent blocks are indented to show that they belong to the footnote (as with
576576\end{verbatim}
577577If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.} This should \emph{not} be a footnote reference, because it contains a space.[\^{}my note] Here is an inline note.\footnote{This is \emph{easier} to type. Inline notes may contain \href{http://google.com}{links} and \verb!]! verbatim characters.}
578578
579+\begin{quote}
580+Notes can go in quotes.\footnote{In quote.}
581+
582+\end{quote}
583+\begin{enumerate}
584+\item And in list items.\footnote{In list.}
585+\end{enumerate}
579586This paragraph should not be part of the note, as it is not indented.
580587
581588
tests/writer.markdown+10
@@ -611,6 +611,10 @@ Here is a footnote reference,[^1] and another.[^2] This should
611611*not* be a footnote reference, because it contains a space.[\^my
612612note] Here is an inline note.[^3]
613613
614+> Notes can go in quotes.[^4]
615+
616+1. And in list items.[^5]
617+
614618This paragraph should not be part of the note, as it is not
615619indented.
616620
@@ -630,3 +634,9 @@ indented.
630634[^3]: This is *easier* to type. Inline notes may contain
631635 [links](http://google.com) and `]` verbatim characters.
632636
637+[^4]: In quote.
638+
639+
640+[^5]: In list.
641+
642+
tests/writer.native+12
@@ -319,6 +319,12 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
319319, HorizontalRule
320320, Header 1 [Str "Footnotes"]
321321, 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"]
322+, BlockQuote
323+ [ Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",NoteRef "4"] ]
324+
325+, OrderedList
326+ [ [ Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",NoteRef "5"] ]
327+ ]
322328, 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."]
323329, Note "1"
324330 [ 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
330336 , 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."] ]
331337, Note "3"
332338 [ 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."] ]
339+
340+, Note "4"
341+ [ Para [Str "In",Space,Str "quote."] ]
342+
343+, Note "5"
344+ [ Para [Str "In",Space,Str "list."] ]
333345 ]
tests/writer.rst+9
@@ -699,6 +699,11 @@ Here is a footnote reference, [1]_ and another. [2]_ This should
699699*not* be a footnote reference, because it contains a space.[^my
700700note] Here is an inline note. [3]_
701701
702+ Notes can go in quotes. [4]_
703+
704+
705+1. And in list items. [5]_
706+
702707This paragraph should not be part of the note, as it is not
703708indented.
704709
@@ -723,6 +728,10 @@ indented.
723728 This is *easier* to type. Inline notes may contain `links`_ and
724729 ``]`` verbatim characters.
725730
731+.. [4] In quote.
732+
733+.. [5] In list.
734+
726735
727736.. _embedded link: /url
728737.. _emphasized link: /url
tests/writer.rtf+4
@@ -377,6 +377,10 @@ links
377377}}}
378378 and {\f1 ]} verbatim characters.\par}
379379}\par}
380+{\pard \f0 \sa180 \li720 \fi0 Notes can go in quotes.{\super\chftn}{\*\footnote\chftn\~\plain\pard {\pard \f0 \sa180 \li0 \fi0 In quote.\par}
381+}\par}
382+{\pard \f0 \sa0 \li360 \fi-360 1.\tx360\tab And in list items.{\super\chftn}{\*\footnote\chftn\~\plain\pard {\pard \f0 \sa180 \li0 \fi0 In list.\par}
383+}\sa180\par}
380384{\pard \f0 \sa180 \li0 \fi0 This paragraph should not be part of the note, as it is not indented.\par}
381385
382386}
tests/writer.smart.html+10
@@ -473,6 +473,12 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>');
473473<a id="Footnotes"></a>
474474<h1>Footnotes</h1>
475475<p>Here is a footnote reference,<sup class="footnoteRef" id="fnref1"><a href="#fn1">1</a></sup> and another.<sup class="footnoteRef" id="fnref2"><a href="#fn2">2</a></sup> This should <em>not</em> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<sup class="footnoteRef" id="fnref3"><a href="#fn3">3</a></sup></p>
476+<blockquote>
477+<p>Notes can go in quotes.<sup class="footnoteRef" id="fnref4"><a href="#fn4">4</a></sup></p>
478+</blockquote>
479+<ol>
480+<li>And in list items.<sup class="footnoteRef" id="fnref5"><a href="#fn5">5</a></sup></li>
481+</ol>
476482<p>This paragraph should not be part of the note, as it is not indented.</p>
477483<div class="footnotes">
478484<hr />
@@ -487,6 +493,10 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>');
487493 <a href="#fnref2" class="footnoteBacklink" title="Jump back to footnote 2">&#8617;</a></li>
488494<li id="fn3"><p>This is <em>easier</em> to type. Inline notes may contain <a href="http://google.com">links</a> and <code>]</code> verbatim characters.</p>
489495 <a href="#fnref3" class="footnoteBacklink" title="Jump back to footnote 3">&#8617;</a></li>
496+<li id="fn4"><p>In quote.</p>
497+ <a href="#fnref4" class="footnoteBacklink" title="Jump back to footnote 4">&#8617;</a></li>
498+<li id="fn5"><p>In list.</p>
499+ <a href="#fnref5" class="footnoteBacklink" title="Jump back to footnote 5">&#8617;</a></li>
490500</ol>
491501</div>
492502</body>