git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Ensure newline after Verbatim at end of footnote.

This fixes a regression. Also added a test for this.

commite14712dabd9773a44be9a29fecb903079dac162f authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 1 Jun 2012, 10:50 (14 years ago) parent3fd80cd
3 files changed+41−1
src/Tests/Writers/LaTeX.hs+35 src/Text/Pandoc/Writers/LaTeX.hs+4−1 src/test-pandoc.hs+2
src/Tests/Writers/LaTeX.hsnew file+35
@@ -0,0 +1,35 @@
1+{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
2+module Tests.Writers.LaTeX (tests) where
3+
4+import Test.Framework
5+import Text.Pandoc.Builder
6+import Text.Pandoc
7+import Tests.Helpers
8+import Tests.Arbitrary()
9+
10+latex :: (ToString a, ToPandoc a) => a -> String
11+latex = writeLaTeX defaultWriterOptions . toPandoc
12+
13+{-
14+ "my test" =: X =?> Y
15+
16+is shorthand for
17+
18+ test latex "my test" $ X =?> Y
19+
20+which is in turn shorthand for
21+
22+ test latex "my test" (X,Y)
23+-}
24+
25+infix 4 =:
26+(=:) :: (ToString a, ToPandoc a)
27+ => String -> (a, String) -> Test
28+(=:) = test latex
29+
30+tests :: [Test]
31+tests = [ testGroup "code blocks"
32+ [ "in footnotes" =: note (para "hi" <> codeBlock "hi") =?>
33+ "\\footnote{hi\n\n\\begin{Verbatim}\nhi\n\\end{Verbatim}\n}"
34+ ]
35+ ]
src/Text/Pandoc/Writers/LaTeX.hs+4−1
@@ -588,13 +588,16 @@ inlineToLaTeX (Note contents) = do
588588 contents' <- blockListToLaTeX contents
589589 modify (\s -> s {stInNote = False})
590590 inTable <- liftM stInTable get
591+ let optnl = case reverse contents of
592+ (CodeBlock _ _ : _) -> cr
593+ _ -> empty
591594 if inTable
592595 then do
593596 curnotes <- liftM stTableNotes get
594597 let marker = cycle ['a'..'z'] !! length curnotes
595598 modify $ \s -> s{ stTableNotes = (marker, contents') : curnotes }
596599 return $ "\\tmark" <> brackets (char marker) <> space
597− else return $ "\\footnote" <> braces (nest 2 contents')
600+ else return $ "\\footnote" <> braces (nest 2 contents' <> optnl)
598601 -- note: a \n before } needed when note ends with a Verbatim environment
599602
600603citationsToNatbib :: [Citation] -> State WriterState Doc
src/test-pandoc.hs+2
@@ -9,6 +9,7 @@ import qualified Tests.Readers.LaTeX
99import qualified Tests.Readers.Markdown
1010import qualified Tests.Readers.RST
1111import qualified Tests.Writers.ConTeXt
12+import qualified Tests.Writers.LaTeX
1213import qualified Tests.Writers.HTML
1314import qualified Tests.Writers.Native
1415import qualified Tests.Writers.Markdown
@@ -20,6 +21,7 @@ tests = [ testGroup "Old" Tests.Old.tests
2021 , testGroup "Writers"
2122 [ testGroup "Native" Tests.Writers.Native.tests
2223 , testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
24+ , testGroup "LaTeX" Tests.Writers.LaTeX.tests
2325 , testGroup "HTML" Tests.Writers.HTML.tests
2426 , testGroup "Markdown" Tests.Writers.Markdown.tests
2527 ]