git.iko.soy/typeable/pandoc
on master help sign in
Added support for tables in markdown reader and in LaTeX,

DocBook, and HTML writers. The syntax is documented in README. Tests have been added to the test suite. git-svn-id: https://pandoc.googlecode.com/svn/trunk@493 788f1e2b-df1e-0410-8736-df70ead52e1b

commit60989d0637780787fb337b94af212f1ee9e1ae22 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateMon 15 Jan 2007, 19:52 (20 years ago) parent4224d91
21 files changed+1033−13
README+65 debian/changelog+8 src/Main.hs+8−2 src/Text/Pandoc/Definition.hs+11 src/Text/Pandoc/Readers/Markdown.hs+153−8 src/Text/Pandoc/Shared.hs+11 src/Text/Pandoc/Writers/Docbook.hs+33−1 src/Text/Pandoc/Writers/HTML.hs+32 src/Text/Pandoc/Writers/LaTeX.hs+33 src/Text/Pandoc/Writers/Markdown.hs+4 src/Text/Pandoc/Writers/RST.hs+3 src/Text/Pandoc/Writers/RTF.hs+2 src/Text/ParserCombinators/Pandoc.hs+13−1 src/headers/LaTeXHeader+4 tests/runtests.pl+18−1 tests/tables.db+286 tests/tables.html+138 tests/tables.native+11 tests/tables.tex+139 tests/tables.txt+57 tests/writer.latex+4
README+65
@@ -471,6 +471,71 @@ they cannot contain multiple paragraphs). The syntax is as follows:
471471
472472Inline and regular footnotes may be mixed freely.
473473
474+Tables
475+------
476+
477+Two kinds of tables may be used. Both kinds presuppose the use of
478+a fixed-width font, such as Courier. Currently only the HTML,
479+Docbook, and LaTeX writers support tables.
480+
481+Simple tables look like this:
482+
483+ Right Left Center Default
484+ ------- ------ ---------- -------
485+ 12 12 12 12
486+ 123 123 123 123
487+ 1 1 1 1
488+
489+ Table: Demonstration of simple table syntax.
490+
491+The headers and table rows must each fit on one line. Column
492+alignments are determined by the position of the header text relative
493+to the dashed line below it:[^2]
494+
495+ - If the dashed line is flush with the header text on the right side
496+ but extends beyond it on the left, the column is right-aligned.
497+ - If the dashed line is flush with the header text on the left side
498+ but extends beyond it on the right, the column is left-aligned.
499+ - If the dashed line extends beyond the header text on both sides,
500+ the column is centered.
501+ - If the dashed line is flush with the header text on both sides,
502+ the default alignment is used (in most cases, this will be left).
503+
504+[^2]: This scheme is due to Michel Fortin, who proposed it on the
505+ Markdown discussion list: <http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html>
506+
507+The table must end with a blank line. Optionally, a caption may be
508+provided (as illustrated in the example above). A caption is a paragraph
509+beginning with the string `Table:`, which will be stripped off.
510+
511+The table parser pays attention to the widths of the columns, and
512+the writers try to reproduce these relative widths in the output.
513+So, if you find that one of the columns is too narrow in the output,
514+try widening it in the markdown source.
515+
516+Multiline tables allow headers and table rows to span multiple lines
517+of text. Here is an example:
518+
519+ ---------------------------------------------------------------
520+ Centered Left Right
521+ Header Aligned Aligned Default aligned
522+ ---------- --------- ----------- ---------------------------
523+ First row 12.0 Example of a row that spans
524+ multiple lines.
525+
526+ Second row 5.0 Here's another one. Note
527+ the blank line between rows.
528+ ---------------------------------------------------------------
529+
530+ Table: Optional caption. This, too, may span multiple
531+ lines.
532+
533+These work like simple tables, but with the following differences:
534+
535+ - They must begin with a row of dashes, before the header text.
536+ - They must end with a row of dashes, then a blank line.
537+ - The rows must be separated by blank lines.
538+
474539Embedded HTML
475540-------------
476541
debian/changelog+8
@@ -1,3 +1,11 @@
1+pandoc (0.4) unstable; urgency=low
2+
3+ [ John MacFarlane ]
4+
5+ * Added support for simple and multiline tables to markdown reader,
6+ LaTeX writer, DocBook writer, and HTML writer. Added tests and
7+ documentation in README.
8+
19pandoc (0.3) unstable; urgency=low
210
311 [ John MacFarlane ]
src/Main.hs+8−2
@@ -48,7 +48,7 @@ import Text.Pandoc.Writers.DefaultHeaders ( defaultHtmlHeader,
4848import Text.Pandoc.Definition
4949import Text.Pandoc.Shared
5050import Text.Regex ( mkRegex, matchRegex )
51−import System.Environment ( getArgs, getProgName )
51+import System.Environment ( getArgs, getProgName, getEnvironment )
5252import System.Exit ( exitWith, ExitCode (..) )
5353import System.Console.GetOpt
5454import System.IO
@@ -58,7 +58,7 @@ import Char ( toLower )
5858import Control.Monad ( (>>=) )
5959
6060version :: String
61−version = "0.3"
61+version = "0.4"
6262
6363copyrightMessage :: String
6464copyrightMessage = "\nCopyright (C) 2006 John MacFarlane\nWeb: http://sophos.berkeley.edu/macfarlane/pandoc\nThis is free software; see the source for copying conditions. There is no\nwarranty, not even for merchantability or fitness for a particular purpose."
@@ -426,6 +426,11 @@ main = do
426426 then return stdout
427427 else openFile outputFile WriteMode
428428
429+ environment <- getEnvironment
430+ let columns = case lookup "COLUMNS" environment of
431+ Just cols -> read cols
432+ Nothing -> stateColumns defaultParserState
433+
429434 let tabFilter = if preserveTabs then id else (tabsToSpaces tabStop)
430435 let addBlank str = str ++ "\n\n"
431436 let removeCRs str = filter (/= '\r') str -- remove DOS-style line endings
@@ -435,6 +440,7 @@ main = do
435440 stateTabStop = tabStop,
436441 stateStandalone = standalone && (not strict),
437442 stateSmart = smart || writerName' == "latex",
443+ stateColumns = columns,
438444 stateStrict = strict }
439445 let csslink = if (css == "")
440446 then ""
src/Text/Pandoc/Definition.hs+11
@@ -39,6 +39,12 @@ data Meta = Meta [Inline] -- title
3939 String -- date
4040 deriving (Eq, Show, Read)
4141
42+-- | Alignment of a table column.
43+data Alignment = AlignLeft
44+ | AlignRight
45+ | AlignCenter
46+ | AlignDefault deriving (Eq, Show, Read)
47+
4248-- | Block element.
4349data Block
4450 = Plain [Inline] -- ^ Plain text, not a paragraph
@@ -57,6 +63,11 @@ data Block
5763 | HorizontalRule -- ^ Horizontal rule
5864 | Note String [Block] -- ^ Footnote or endnote - reference (string),
5965 -- text (list of blocks)
66+ | Table [Inline] -- ^ Table caption,
67+ [Alignment] -- column alignments,
68+ [Float] -- column widths (relative to page),
69+ [[Block]] -- column headers, and
70+ [[[Block]]] -- rows
6071 deriving (Eq, Read, Show)
6172
6273-- | Target for a link: either a URL or an indirect (labeled) reference.
src/Text/Pandoc/Readers/Markdown.hs+153−8
@@ -31,7 +31,7 @@ module Text.Pandoc.Readers.Markdown (
3131 readMarkdown
3232 ) where
3333
34−import Data.List ( findIndex, sortBy )
34+import Data.List ( findIndex, sortBy, transpose )
3535import Data.Char ( isAlphaNum )
3636import Text.ParserCombinators.Pandoc
3737import Text.Pandoc.Definition
@@ -88,6 +88,7 @@ setextHChars = ['=','-']
8888blockQuoteChar = '>'
8989hyphenChar = '-'
9090ellipsesChar = '.'
91+listColSepChar = '|'
9192
9293-- treat these as potentially non-text when parsing inline:
9394specialChars = [escapeChar, labelStart, labelEnd, emphStart, emphEnd,
@@ -106,9 +107,9 @@ indentSpaces = do
106107 state <- getState
107108 let tabStop = stateTabStop state
108109 count tabStop (char ' ') <|>
109− (do{skipNonindentSpaces; string "\t"}) <?> "indentation"
110+ (do{nonindentSpaces; string "\t"}) <?> "indentation"
110111
111−skipNonindentSpaces = do
112+nonindentSpaces = do
112113 state <- getState
113114 let tabStop = stateTabStop state
114115 choice (map (\n -> (try (count n (char ' ')))) (reverse [0..(tabStop - 1)]))
@@ -192,7 +193,7 @@ parseMarkdown = do
192193
193194parseBlocks = manyTill block eof
194195
195−block = choice [ codeBlock, note, referenceKey, header, hrule, list,
196+block = choice [ header, table, codeBlock, note, referenceKey, hrule, list,
196197 blockQuote, htmlBlock, rawLaTeXEnvironment', para,
197198 plain, blankBlock, nullBlock ] <?> "block"
198199
@@ -322,7 +323,7 @@ emacsBoxQuote = try (do
322323 return raw)
323324
324325emailBlockQuoteStart = try (do
325− skipNonindentSpaces
326+ nonindentSpaces
326327 char blockQuoteChar
327328 option ' ' (char ' ')
328329 return "> ")
@@ -356,7 +357,7 @@ list = choice [ bulletList, orderedList ] <?> "list"
356357
357358bulletListStart = try (do
358359 option ' ' newline -- if preceded by a Plain block in a list context
359− skipNonindentSpaces
360+ nonindentSpaces
360361 notFollowedBy' hrule -- because hrules start out just like lists
361362 oneOf bulletListMarkers
362363 spaceChar
@@ -364,7 +365,7 @@ bulletListStart = try (do
364365
365366orderedListStart = try (do
366367 option ' ' newline -- if preceded by a Plain block in a list context
367− skipNonindentSpaces
368+ nonindentSpaces
368369 many1 digit <|> (do{failIfStrict; count 1 letter})
369370 delim <- oneOf orderedListDelimiters
370371 if delim /= '.' then failIfStrict else return ()
@@ -501,7 +502,7 @@ rawHtmlBlocks = try (do
501502--
502503
503504referenceKey = try (do
504− skipNonindentSpaces
505+ nonindentSpaces
505506 label <- reference
506507 char labelSep
507508 skipSpaces
@@ -523,6 +524,150 @@ rawLaTeXEnvironment' = do
523524 failIfStrict
524525 rawLaTeXEnvironment
525526
527+--
528+-- Tables
529+--
530+
531+-- | Parse a dashed line with optional trailing spaces; return its length
532+-- and the length including trailing space.
533+dashedLine ch = do
534+ dashes <- many1 (char ch)
535+ sp <- many spaceChar
536+ return $ (length dashes, length $ dashes ++ sp)
537+
538+-- | Parse a table header with dashed lines of '-' preceded by
539+-- one line of text.
540+simpleTableHeader = do
541+ rawContent <- anyLine
542+ initSp <- nonindentSpaces
543+ dashes <- many1 (dashedLine '-')
544+ newline
545+ let (lengths, lines) = unzip dashes
546+ let indices = scanl (+) (length initSp) lines
547+ let rawHeads = tail $ splitByIndices (init indices) rawContent
548+ let aligns = zipWith alignType (map (\a -> [a]) rawHeads) lengths
549+ return $ (rawHeads, aligns, indices)
550+
551+-- | Parse a table footer - dashed lines followed by blank line.
552+tableFooter = try $ do
553+ nonindentSpaces
554+ many1 (dashedLine '-')
555+ blanklines
556+
557+-- | Parse a table separator - dashed line.
558+tableSep = try $ do
559+ nonindentSpaces
560+ many1 (dashedLine '-')
561+ string "\n"
562+
563+-- | Parse a raw line and split it into chunks by indices.
564+rawTableLine indices = do
565+ notFollowedBy' (blanklines <|> tableFooter)
566+ line <- many1Till anyChar newline
567+ return $ map removeLeadingTrailingSpace $ tail $
568+ splitByIndices (init indices) line
569+
570+-- | Parse a table line and return a list of lists of blocks (columns).
571+tableLine indices = try $ do
572+ rawline <- rawTableLine indices
573+ mapM (parseFromStr (many plain)) rawline
574+
575+-- | Parse a multiline table row and return a list of blocks (columns).
576+multilineRow indices = try $ do
577+ colLines <- many1 (rawTableLine indices)
578+ option "" blanklines
579+ let cols = map unlines $ transpose colLines
580+ mapM (parseFromStr (many plain)) cols
581+
582+-- | Calculate relative widths of table columns, based on indices
583+widthsFromIndices :: Int -- ^ Number of columns on terminal
584+ -> [Int] -- ^ Indices
585+ -> [Float] -- ^ Fractional relative sizes of columns
586+widthsFromIndices _ [] = []
587+widthsFromIndices numColumns indices =
588+ let lengths = zipWith (-) indices (0:indices)
589+ totLength = sum lengths
590+ quotient = if totLength > numColumns
591+ then fromIntegral totLength
592+ else fromIntegral numColumns
593+ fracs = map (\l -> (fromIntegral l) / quotient) lengths in
594+ tail fracs
595+
596+-- | Parses a table caption: inlines beginning with 'Table:'
597+-- and followed by blank lines
598+tableCaption = try $ do
599+ nonindentSpaces
600+ string "Table:"
601+ result <- many1 inline
602+ blanklines
603+ return $ normalizeSpaces result
604+
605+-- | Parse a table using 'headerParser', 'lineParser', and 'footerParser'
606+tableWith headerParser lineParser footerParser = try $ do
607+ (rawHeads, aligns, indices) <- headerParser
608+ lines <- many1Till (lineParser indices) footerParser
609+ caption <- option [] tableCaption
610+ heads <- mapM (parseFromStr (many plain)) rawHeads
611+ state <- getState
612+ let numColumns = stateColumns state
613+ let widths = widthsFromIndices numColumns indices
614+ return $ Table caption aligns widths heads lines
615+
616+-- | Parse a simple table with '---' header and one line per row.
617+simpleTable = tableWith simpleTableHeader tableLine blanklines
618+
619+-- | Parse a multiline table: starts with row of '-' on top, then header
620+-- (which may be multiline), then the rows,
621+-- which may be multiline, separated by blank lines, and
622+-- ending with a footer (dashed line followed by blank line).
623+multilineTable = tableWith multilineTableHeader multilineRow tableFooter
624+
625+multilineTableHeader = try $ do
626+ tableSep
627+ rawContent <- many1 (do{notFollowedBy' tableSep;
628+ many1Till anyChar newline})
629+ initSp <- nonindentSpaces
630+ dashes <- many1 (dashedLine '-')
631+ newline
632+ let (lengths, lines) = unzip dashes
633+ let indices = scanl (+) (length initSp) lines
634+ let rawHeadsList = transpose $ map
635+ (\ln -> tail $ splitByIndices (init indices) ln)
636+ rawContent
637+ let rawHeads = map (joinWithSep " ") rawHeadsList
638+ let aligns = zipWith alignType rawHeadsList lengths
639+ return $ ((map removeLeadingTrailingSpace rawHeads),
640+ aligns, indices)
641+
642+-- | Returns the longest of a list of strings.
643+longest :: [String] -> String
644+longest [] = ""
645+longest [x] = x
646+longest (x:xs) =
647+ if (length x) >= (maximum $ map length xs)
648+ then x
649+ else longest xs
650+
651+-- | Returns an alignment type for a table, based on a list of strings
652+-- (the rows of the column header) and a number (the length of the
653+-- dashed line under the rows.
654+alignType :: [String] -> Int -> Alignment
655+alignType [] len = AlignDefault
656+alignType strLst len =
657+ let str = longest $ map removeTrailingSpace strLst
658+ leftSpace = if null str then False else ((str !! 0) `elem` " \t")
659+ rightSpace = (length str < len || (str !! (len - 1)) `elem` " \t") in
660+ case (leftSpace, rightSpace) of
661+ (True, False) -> AlignRight
662+ (False, True) -> AlignLeft
663+ (True, True) -> AlignCenter
664+ (False, False) -> AlignDefault
665+
666+table = do
667+ failIfStrict
668+ result <- simpleTable <|> multilineTable <?> "table"
669+ return result
670+
526671--
527672-- inline
528673--
src/Text/Pandoc/Shared.hs+11
@@ -30,6 +30,7 @@ Utility functions and definitions used by the various Pandoc modules.
3030module Text.Pandoc.Shared (
3131 -- * List processing
3232 splitBy,
33+ splitByIndices,
3334 -- * Text processing
3435 gsub,
3536 joinWithSep,
@@ -133,6 +134,8 @@ data ParserState = ParserState
133134 stateDate :: String, -- ^ Date of document
134135 stateStrict :: Bool, -- ^ Use strict markdown syntax
135136 stateSmart :: Bool, -- ^ Use smart typography
137+ stateColumns :: Int, -- ^ Number of columns in
138+ -- terminal (used for tables)
136139 stateHeaderTable :: [HeaderType] -- ^ List of header types used,
137140 -- in what order (rst only)
138141 }
@@ -154,6 +157,7 @@ defaultParserState =
154157 stateDate = [],
155158 stateStrict = False,
156159 stateSmart = False,
160+ stateColumns = 80,
157161 stateHeaderTable = [] }
158162
159163-- | Indent string as a block.
@@ -292,6 +296,13 @@ splitBy sep lst =
292296 rest' = dropWhile (== sep) rest in
293297 first:(splitBy sep rest')
294298
299+-- | Split list into chunks divided at specified indices.
300+splitByIndices :: [Int] -> [a] -> [[a]]
301+splitByIndices [] lst = [lst]
302+splitByIndices (x:xs) lst =
303+ let (first, rest) = splitAt x lst in
304+ first:(splitByIndices (map (\y -> y - x) xs) rest)
305+
295306-- | Normalize a list of inline elements: remove leading and trailing
296307-- @Space@ elements, and collapse double @Space@s into singles.
297308normalizeSpaces :: [Inline] -> [Inline]
src/Text/Pandoc/Writers/Docbook.hs+33−1
@@ -151,7 +151,39 @@ blockToDocbook opts (RawHtml str) = text str -- raw XML block
151151blockToDocbook opts HorizontalRule = empty -- not semantic
152152blockToDocbook opts (Note _ _) = empty -- shouldn't occur
153153blockToDocbook opts (Key _ _) = empty -- shouldn't occur
154−blockToDocbook opts _ = inTagsIndented "para" (text "Unknown block type")
154+blockToDocbook opts (Table caption aligns widths headers rows) =
155+ let alignStrings = map alignmentToString aligns
156+ captionDoc = if null caption
157+ then empty
158+ else inTagsIndented "caption"
159+ (inlinesToDocbook opts caption)
160+ tableType = if isEmpty captionDoc then "informaltable" else "table" in
161+ inTagsIndented tableType $ captionDoc $$
162+ (colHeadsToDocbook opts alignStrings widths headers) $$
163+ (vcat $ map (tableRowToDocbook opts alignStrings) rows)
164+
165+colHeadsToDocbook opts alignStrings widths headers =
166+ let heads = zipWith3
167+ (\align width item -> tableItemToDocbook opts "th" align width item)
168+ alignStrings widths headers in
169+ inTagsIndented "tr" $ vcat heads
170+
171+alignmentToString alignment = case alignment of
172+ AlignLeft -> "left"
173+ AlignRight -> "right"
174+ AlignCenter -> "center"
175+ AlignDefault -> "left"
176+
177+tableRowToDocbook opts aligns cols =
178+ inTagsIndented "tr" $ vcat $ zipWith3 (tableItemToDocbook opts "td") aligns (repeat 0) cols
179+
180+tableItemToDocbook opts tag align width item =
181+ let attrib = [("align", align)] ++
182+ if (width /= 0)
183+ then [("style", "{width: " ++
184+ show (truncate (100*width)) ++ "%;}")]
185+ else [] in
186+ inTags True tag attrib $ vcat $ map (blockToDocbook opts) item
155187
156188-- | Put string in CDATA section
157189cdata :: String -> Doc
src/Text/Pandoc/Writers/HTML.hs+32
@@ -186,6 +186,38 @@ blockToHtml opts (Header level lst) =
186186 if ((level > 0) && (level <= 6))
187187 then inTagsSimple ("h" ++ show level) contents
188188 else inTagsSimple "p" contents
189+blockToHtml opts (Table caption aligns widths headers rows) =
190+ let alignStrings = map alignmentToString aligns
191+ captionDoc = if null caption
192+ then empty
193+ else inTagsSimple "caption"
194+ (inlineListToHtml opts caption) in
195+ inTagsIndented "table" $ captionDoc $$
196+ (colHeadsToHtml opts alignStrings widths headers) $$
197+ (vcat $ map (tableRowToHtml opts alignStrings) rows)
198+
199+colHeadsToHtml opts alignStrings widths headers =
200+ let heads = zipWith3
201+ (\align width item -> tableItemToHtml opts "th" align width item)
202+ alignStrings widths headers in
203+ inTagsIndented "tr" $ vcat heads
204+
205+alignmentToString alignment = case alignment of
206+ AlignLeft -> "left"
207+ AlignRight -> "right"
208+ AlignCenter -> "center"
209+ AlignDefault -> "left"
210+
211+tableRowToHtml opts aligns cols =
212+ inTagsIndented "tr" $ vcat $ zipWith3 (tableItemToHtml opts "td") aligns (repeat 0) cols
213+
214+tableItemToHtml opts tag align width item =
215+ let attrib = [("align", align)] ++
216+ if (width /= 0)
217+ then [("style", "{width: " ++
218+ show (truncate (100*width)) ++ "%;}")]
219+ else [] in
220+ inTags False tag attrib $ vcat $ map (blockToHtml opts) item
189221
190222listItemToHtml :: WriterOptions -> [Block] -> Doc
191223listItemToHtml opts list =
src/Text/Pandoc/Writers/LaTeX.hs+33
@@ -32,6 +32,7 @@ module Text.Pandoc.Writers.LaTeX (
3232 ) where
3333import Text.Pandoc.Definition
3434import Text.Pandoc.Shared
35+import Text.Printf ( printf )
3536import List ( (\\) )
3637
3738-- | Convert Pandoc to LaTeX.
@@ -123,6 +124,38 @@ blockToLaTeX notes (Header level lst) =
123124 then "\\" ++ (concat (replicate (level - 1) "sub")) ++ "section{" ++
124125 (inlineListToLaTeX notes (deVerb lst)) ++ "}\n\n"
125126 else (inlineListToLaTeX notes lst) ++ "\n\n"
127+blockToLaTeX notes (Table caption aligns widths heads rows) =
128+ let colWidths = map printDecimal widths
129+ colDescriptors = concat $ zipWith
130+ (\width align -> ">{\\PBS" ++
131+ (case align of
132+ AlignLeft -> "\\raggedright"
133+ AlignRight -> "\\raggedleft"
134+ AlignCenter -> "\\centering"
135+ AlignDefault -> "\\raggedright") ++
136+ "\\hspace{0pt}}p{" ++ width ++
137+ "\\textwidth}")
138+ colWidths aligns
139+ headers = tableRowToLaTeX notes heads
140+ captionText = inlineListToLaTeX notes caption
141+ tableBody = "\\begin{tabular}{" ++ colDescriptors ++ "}\n" ++
142+ headers ++ "\\hline\n" ++
143+ (concatMap (tableRowToLaTeX notes) rows) ++
144+ "\\end{tabular}\n"
145+ centered str = "\\begin{center}\n" ++ str ++ "\\end{center}\n" in
146+ if null captionText
147+ then centered tableBody ++ "\n"
148+ else "\\begin{table}[h]\n" ++ centered tableBody ++ "\\caption{" ++
149+ captionText ++ "}\n" ++ "\\end{table}\n\n"
150+
151+
152+printDecimal :: Float -> String
153+printDecimal = printf "%.2f"
154+
155+tableColumnWidths notes cols = map (length . (concatMap (blockToLaTeX notes))) cols
156+
157+tableRowToLaTeX notes cols = joinWithSep " & " (map (concatMap (blockToLaTeX notes)) cols) ++ "\\\\\n"
158+
126159listItemToLaTeX notes list = "\\item " ++
127160 (concatMap (blockToLaTeX notes) list)
128161
src/Text/Pandoc/Writers/Markdown.hs+4
@@ -132,6 +132,10 @@ blockToMarkdown tabStop (OrderedList lst) =
132132blockToMarkdown tabStop HorizontalRule = text "\n* * * * *\n"
133133blockToMarkdown tabStop (Header level lst) = text ((replicate level '#') ++
134134 " ") <> (inlineListToMarkdown lst) <> (text "\n")
135+blockToMarkdown tabStop (Table caption _ _ headers rows) =
136+ blockToMarkdown tabStop (Para [Str "pandoc: TABLE unsupported in Markdown writer"])
137+
138+
135139bulletListItemToMarkdown tabStop list =
136140 hang (text "- ") tabStop (vcat (map (blockToMarkdown tabStop) list))
137141
src/Text/Pandoc/Writers/RST.hs+3
@@ -148,6 +148,9 @@ blockToRST tabStop (Header level lst) =
148148 let headerChar = if (level > 5) then ' ' else "=-~^'" !! (level - 1) in
149149 let border = text $ replicate headerLength headerChar in
150150 (headerText <> char '\n' <> border <> char '\n', refs)
151+blockToRST tabStop (Table caption _ _ headers rows) =
152+ blockToRST tabStop (Para [Str "pandoc: TABLE unsupported in RST writer"])
153+
151154
152155-- | Convert bullet list item (list of blocks) to reStructuredText.
153156-- Returns a pair of 'Doc', the first the main text, the second references
src/Text/Pandoc/Writers/RTF.hs+2
@@ -170,6 +170,8 @@ blockToRTF notes indent HorizontalRule =
170170blockToRTF notes indent (Header level lst) =
171171 rtfPar indent 0 ("\\b \\fs" ++ (show (40 - (level * 4))) ++ " " ++
172172 (inlineListToRTF notes lst))
173+blockToRTF notes indent (Table caption _ _ headers rows) =
174+ blockToRTF notes indent (Para [Str "pandoc: TABLE unsupported in RST writer"])
173175
174176-- | Ensure that there's the same amount of space after compact
175177-- lists as after regular lists.
src/Text/ParserCombinators/Pandoc.hs+13−1
@@ -41,7 +41,8 @@ module Text.ParserCombinators.Pandoc (
4141 enclosed,
4242 blankBlock,
4343 nullBlock,
44− stringAnyCase
44+ stringAnyCase,
45+ parseFromStr
4546 ) where
4647import Text.ParserCombinators.Parsec
4748import Text.Pandoc.Definition
@@ -138,3 +139,14 @@ stringAnyCase (x:xs) = try (do
138139 firstChar <- choice [ char (toUpper x), char (toLower x) ]
139140 rest <- stringAnyCase xs
140141 return (firstChar:rest))
142+
143+-- | Parse contents of 'str' using 'parser' and return result.
144+parseFromStr :: GenParser tok st a -> [tok] -> GenParser tok st a
145+parseFromStr parser str = try $ do
146+ oldInput <- getInput
147+ setInput str
148+ result <- parser
149+ setInput oldInput
150+ return result
151+
152+
src/headers/LaTeXHeader+4
@@ -3,8 +3,12 @@
33\usepackage{ucs}
44\usepackage[utf8x]{inputenc}
55\usepackage{graphicx}
6+\usepackage{array}
67\setlength{\parindent}{0pt}
78\setlength{\parskip}{6pt plus 2pt minus 1pt}
89% This is needed for code blocks in footnotes:
910\usepackage{fancyvrb}
1011\VerbatimFootnotes
12+% This is needed because raggedright in table elements redefines //:
13+\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
14+\let\PBS=\PreserveBackslash
tests/runtests.pl+18−1
@@ -4,7 +4,7 @@ $verbose = 1;
44my $diffexists = `which diff`;
55if ($diffexists eq "") { die "diff not found in path.\n"; }
66
7−my $script = "./pandoc";
7+my $script = "COLUMNS=78 ./pandoc";
88
99use Getopt::Long;
1010GetOptions("script=s" => \$script);
@@ -73,12 +73,29 @@ print "Testing -H -B -A -c options...";
7373`$script -r native -s -w html -H insert -B insert -A insert -c main.css s5.native > tmp.html`;
7474test_results("-B, -A, -H, -c options", "tmp.html", "s5.inserts.html");
7575
76+print "Testing tables:\n";
77+print " html writer...";
78+`$script -r native -w html tables.native > tmp.html`;
79+test_results("html table writer", "tmp.html", "tables.html");
80+
81+print " latex writer...";
82+`$script -r native -w latex tables.native > tmp.tex`;
83+test_results("latex table writer", "tmp.tex", "tables.tex");
84+
85+print " docbook writer...";
86+`$script -r native -w docbook tables.native > tmp.db`;
87+test_results("docbook table writer", "tmp.db", "tables.db");
88+
7689print "\nReader tests:\n";
7790
7891print "Testing markdown reader...";
7992`$script -r markdown -w native -s -S testsuite.txt > tmp.native`;
8093test_results("markdown reader", "tmp.native", "testsuite.native");
8194
95+print " tables...";
96+`$script -r markdown -w native tables.txt > tmp.native`;
97+test_results("markdown table reader", "tmp.native", "tables.native");
98+
8299print "Testing rst reader...";
83100`$script -r rst -w native -s rst-reader.rst > tmp.native`;
84101test_results("rst reader", "tmp.native", "rst-reader.native");
tests/tables.dbnew file+286
@@ -0,0 +1,286 @@
1+<para>
2+ Simple table with caption:
3+</para>
4+<table>
5+ <caption>
6+ Demonstration of simple table syntax.
7+ </caption>
8+ <tr>
9+ <th align="right" style="{width: 15%;}">
10+ Right
11+ </th>
12+ <th align="left" style="{width: 8%;}">
13+ Left
14+ </th>
15+ <th align="center" style="{width: 16%;}">
16+ Center
17+ </th>
18+ <th align="left" style="{width: 12%;}">
19+ Default
20+ </th>
21+ </tr>
22+ <tr>
23+ <td align="right">
24+ 12
25+ </td>
26+ <td align="left">
27+ 12
28+ </td>
29+ <td align="center">
30+ 12
31+ </td>
32+ <td align="left">
33+ 12
34+ </td>
35+ </tr>
36+ <tr>
37+ <td align="right">
38+ 123
39+ </td>
40+ <td align="left">
41+ 123
42+ </td>
43+ <td align="center">
44+ 123
45+ </td>
46+ <td align="left">
47+ 123
48+ </td>
49+ </tr>
50+ <tr>
51+ <td align="right">
52+ 1
53+ </td>
54+ <td align="left">
55+ 1
56+ </td>
57+ <td align="center">
58+ 1
59+ </td>
60+ <td align="left">
61+ 1
62+ </td>
63+ </tr>
64+</table>
65+<para>
66+ Simple table without caption:
67+</para>
68+<informaltable>
69+ <tr>
70+ <th align="right" style="{width: 15%;}">
71+ Right
72+ </th>
73+ <th align="left" style="{width: 8%;}">
74+ Left
75+ </th>
76+ <th align="center" style="{width: 16%;}">
77+ Center
78+ </th>
79+ <th align="left" style="{width: 12%;}">
80+ Default
81+ </th>
82+ </tr>
83+ <tr>
84+ <td align="right">
85+ 12
86+ </td>
87+ <td align="left">
88+ 12
89+ </td>
90+ <td align="center">
91+ 12
92+ </td>
93+ <td align="left">
94+ 12
95+ </td>
96+ </tr>
97+ <tr>
98+ <td align="right">
99+ 123
100+ </td>
101+ <td align="left">
102+ 123
103+ </td>
104+ <td align="center">
105+ 123
106+ </td>
107+ <td align="left">
108+ 123
109+ </td>
110+ </tr>
111+ <tr>
112+ <td align="right">
113+ 1
114+ </td>
115+ <td align="left">
116+ 1
117+ </td>
118+ <td align="center">
119+ 1
120+ </td>
121+ <td align="left">
122+ 1
123+ </td>
124+ </tr>
125+</informaltable>
126+<para>
127+ Simple table indented two spaces:
128+</para>
129+<table>
130+ <caption>
131+ Demonstration of simple table syntax.
132+ </caption>
133+ <tr>
134+ <th align="right" style="{width: 15%;}">
135+ Right
136+ </th>
137+ <th align="left" style="{width: 8%;}">
138+ Left
139+ </th>
140+ <th align="center" style="{width: 16%;}">
141+ Center
142+ </th>
143+ <th align="left" style="{width: 12%;}">
144+ Default
145+ </th>
146+ </tr>
147+ <tr>
148+ <td align="right">
149+ 12
150+ </td>
151+ <td align="left">
152+ 12
153+ </td>
154+ <td align="center">
155+ 12
156+ </td>
157+ <td align="left">
158+ 12
159+ </td>
160+ </tr>
161+ <tr>
162+ <td align="right">
163+ 123
164+ </td>
165+ <td align="left">
166+ 123
167+ </td>
168+ <td align="center">
169+ 123
170+ </td>
171+ <td align="left">
172+ 123
173+ </td>
174+ </tr>
175+ <tr>
176+ <td align="right">
177+ 1
178+ </td>
179+ <td align="left">
180+ 1
181+ </td>
182+ <td align="center">
183+ 1
184+ </td>
185+ <td align="left">
186+ 1
187+ </td>
188+ </tr>
189+</table>
190+<para>
191+ Multiline table with caption:
192+</para>
193+<table>
194+ <caption>
195+ Here's the caption. It may span multiple lines.
196+ </caption>
197+ <tr>
198+ <th align="center" style="{width: 15%;}">
199+ Centered Header
200+ </th>
201+ <th align="left" style="{width: 13%;}">
202+ Left Aligned
203+ </th>
204+ <th align="right" style="{width: 16%;}">
205+ Right Aligned
206+ </th>
207+ <th align="left" style="{width: 33%;}">
208+ Default aligned
209+ </th>
210+ </tr>
211+ <tr>
212+ <td align="center">
213+ First
214+ </td>
215+ <td align="left">
216+ row
217+ </td>
218+ <td align="right">
219+ 12.0
220+ </td>
221+ <td align="left">
222+ Example of a row that spans multiple lines.
223+ </td>
224+ </tr>
225+ <tr>
226+ <td align="center">
227+ Second
228+ </td>
229+ <td align="left">
230+ row
231+ </td>
232+ <td align="right">
233+ 5.0
234+ </td>
235+ <td align="left">
236+ Here's another one. Note the blank line between rows.
237+ </td>
238+ </tr>
239+</table>
240+<para>
241+ Multiline table without caption:
242+</para>
243+<informaltable>
244+ <tr>
245+ <th align="center" style="{width: 15%;}">
246+ Centered Header
247+ </th>
248+ <th align="left" style="{width: 13%;}">
249+ Left Aligned
250+ </th>
251+ <th align="right" style="{width: 16%;}">
252+ Right Aligned
253+ </th>
254+ <th align="left" style="{width: 33%;}">
255+ Default aligned
256+ </th>
257+ </tr>
258+ <tr>
259+ <td align="center">
260+ First
261+ </td>
262+ <td align="left">
263+ row
264+ </td>
265+ <td align="right">
266+ 12.0
267+ </td>
268+ <td align="left">
269+ Example of a row that spans multiple lines.
270+ </td>
271+ </tr>
272+ <tr>
273+ <td align="center">
274+ Second
275+ </td>
276+ <td align="left">
277+ row
278+ </td>
279+ <td align="right">
280+ 5.0
281+ </td>
282+ <td align="left">
283+ Here's another one. Note the blank line between rows.
284+ </td>
285+ </tr>
286+</informaltable>
tests/tables.htmlnew file+138
@@ -0,0 +1,138 @@
1+<p>
2+ Simple table with caption:
3+</p>
4+<table>
5+ <caption>Demonstration of simple table syntax.</caption>
6+ <tr>
7+ <th align="right" style="{width: 15%;}">Right</th>
8+ <th align="left" style="{width: 8%;}">Left</th>
9+ <th align="center" style="{width: 16%;}">Center</th>
10+ <th align="left" style="{width: 12%;}">Default</th>
11+ </tr>
12+ <tr>
13+ <td align="right">12</td>
14+ <td align="left">12</td>
15+ <td align="center">12</td>
16+ <td align="left">12</td>
17+ </tr>
18+ <tr>
19+ <td align="right">123</td>
20+ <td align="left">123</td>
21+ <td align="center">123</td>
22+ <td align="left">123</td>
23+ </tr>
24+ <tr>
25+ <td align="right">1</td>
26+ <td align="left">1</td>
27+ <td align="center">1</td>
28+ <td align="left">1</td>
29+ </tr>
30+</table>
31+<p>
32+ Simple table without caption:
33+</p>
34+<table>
35+ <tr>
36+ <th align="right" style="{width: 15%;}">Right</th>
37+ <th align="left" style="{width: 8%;}">Left</th>
38+ <th align="center" style="{width: 16%;}">Center</th>
39+ <th align="left" style="{width: 12%;}">Default</th>
40+ </tr>
41+ <tr>
42+ <td align="right">12</td>
43+ <td align="left">12</td>
44+ <td align="center">12</td>
45+ <td align="left">12</td>
46+ </tr>
47+ <tr>
48+ <td align="right">123</td>
49+ <td align="left">123</td>
50+ <td align="center">123</td>
51+ <td align="left">123</td>
52+ </tr>
53+ <tr>
54+ <td align="right">1</td>
55+ <td align="left">1</td>
56+ <td align="center">1</td>
57+ <td align="left">1</td>
58+ </tr>
59+</table>
60+<p>
61+ Simple table indented two spaces:
62+</p>
63+<table>
64+ <caption>Demonstration of simple table syntax.</caption>
65+ <tr>
66+ <th align="right" style="{width: 15%;}">Right</th>
67+ <th align="left" style="{width: 8%;}">Left</th>
68+ <th align="center" style="{width: 16%;}">Center</th>
69+ <th align="left" style="{width: 12%;}">Default</th>
70+ </tr>
71+ <tr>
72+ <td align="right">12</td>
73+ <td align="left">12</td>
74+ <td align="center">12</td>
75+ <td align="left">12</td>
76+ </tr>
77+ <tr>
78+ <td align="right">123</td>
79+ <td align="left">123</td>
80+ <td align="center">123</td>
81+ <td align="left">123</td>
82+ </tr>
83+ <tr>
84+ <td align="right">1</td>
85+ <td align="left">1</td>
86+ <td align="center">1</td>
87+ <td align="left">1</td>
88+ </tr>
89+</table>
90+<p>
91+ Multiline table with caption:
92+</p>
93+<table>
94+ <caption>Here's the caption. It may span multiple lines.</caption>
95+ <tr>
96+ <th align="center" style="{width: 15%;}">Centered Header</th>
97+ <th align="left" style="{width: 13%;}">Left Aligned</th>
98+ <th align="right" style="{width: 16%;}">Right Aligned</th>
99+ <th align="left" style="{width: 33%;}">Default aligned</th>
100+ </tr>
101+ <tr>
102+ <td align="center">First</td>
103+ <td align="left">row</td>
104+ <td align="right">12.0</td>
105+ <td align="left">Example of a row that spans multiple lines.</td>
106+ </tr>
107+ <tr>
108+ <td align="center">Second</td>
109+ <td align="left">row</td>
110+ <td align="right">5.0</td>
111+ <td align="left">Here's another one. Note the blank line between
112+ rows.</td>
113+ </tr>
114+</table>
115+<p>
116+ Multiline table without caption:
117+</p>
118+<table>
119+ <tr>
120+ <th align="center" style="{width: 15%;}">Centered Header</th>
121+ <th align="left" style="{width: 13%;}">Left Aligned</th>
122+ <th align="right" style="{width: 16%;}">Right Aligned</th>
123+ <th align="left" style="{width: 33%;}">Default aligned</th>
124+ </tr>
125+ <tr>
126+ <td align="center">First</td>
127+ <td align="left">row</td>
128+ <td align="right">12.0</td>
129+ <td align="left">Example of a row that spans multiple lines.</td>
130+ </tr>
131+ <tr>
132+ <td align="center">Second</td>
133+ <td align="left">row</td>
134+ <td align="right">5.0</td>
135+ <td align="left">Here's another one. Note the blank line between
136+ rows.</td>
137+ </tr>
138+</table>
tests/tables.nativenew file+11
@@ -0,0 +1,11 @@
1+Pandoc (Meta [] [] "")
2+[ Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption:"]
3+, Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.15,8.75e-2,0.1625,0.125] [[Plain [Str "Right"]],[Plain [Str "Left"]],[Plain [Str "Center"]],[Plain [Str "Default"]]] [[[Plain [Str "12"]],[Plain [Str "12"]],[Plain [Str "12"]],[Plain [Str "12"]]],[[Plain [Str "123"]],[Plain [Str "123"]],[Plain [Str "123"]],[Plain [Str "123"]]],[[Plain [Str "1"]],[Plain [Str "1"]],[Plain [Str "1"]],[Plain [Str "1"]]]]
4+, Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption:"]
5+, Table [] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.15,8.75e-2,0.1625,0.125] [[Plain [Str "Right"]],[Plain [Str "Left"]],[Plain [Str "Center"]],[Plain [Str "Default"]]] [[[Plain [Str "12"]],[Plain [Str "12"]],[Plain [Str "12"]],[Plain [Str "12"]]],[[Plain [Str "123"]],[Plain [Str "123"]],[Plain [Str "123"]],[Plain [Str "123"]]],[[Plain [Str "1"]],[Plain [Str "1"]],[Plain [Str "1"]],[Plain [Str "1"]]]]
6+, Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces:"]
7+, Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.15,8.75e-2,0.1625,0.125] [[Plain [Str "Right"]],[Plain [Str "Left"]],[Plain [Str "Center"]],[Plain [Str "Default"]]] [[[Plain [Str "12"]],[Plain [Str "12"]],[Plain [Str "12"]],[Plain [Str "12"]]],[[Plain [Str "123"]],[Plain [Str "123"]],[Plain [Str "123"]],[Plain [Str "123"]]],[[Plain [Str "1"]],[Plain [Str "1"]],[Plain [Str "1"]],[Plain [Str "1"]]]]
8+, Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption:"]
9+, Table [Str "Here",Str "'",Str "s",Space,Str "the",Space,Str "caption",Str ".",Space,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines",Str "."] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375] [[Plain [Str "Centered",Space,Str "Header"]],[Plain [Str "Left",Space,Str "Aligned"]],[Plain [Str "Right",Space,Str "Aligned"]],[Plain [Str "Default",Space,Str "aligned"]]] [[[Plain [Str "First"]],[Plain [Str "row"]],[Plain [Str "12",Str ".",Str "0"]],[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]],[[Plain [Str "Second"]],[Plain [Str "row"]],[Plain [Str "5",Str ".",Str "0"]],[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]
10+, Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption:"]
11+, Table [] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375] [[Plain [Str "Centered",Space,Str "Header"]],[Plain [Str "Left",Space,Str "Aligned"]],[Plain [Str "Right",Space,Str "Aligned"]],[Plain [Str "Default",Space,Str "aligned"]]] [[[Plain [Str "First"]],[Plain [Str "row"]],[Plain [Str "12",Str ".",Str "0"]],[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]],[[Plain [Str "Second"]],[Plain [Str "row"]],[Plain [Str "5",Str ".",Str "0"]],[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]] ]
tests/tables.texnew file+139
@@ -0,0 +1,139 @@
1+Simple table with caption:
2+
3+\begin{table}[h]
4+\begin{center}
5+\begin{tabular}{>{\PBS\raggedleft\hspace{0pt}}p{0.15\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.09\textwidth}>{\PBS\centering\hspace{0pt}}p{0.16\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.13\textwidth}}
6+Right
7+ & Left
8+ & Center
9+ & Default
10+\\
11+\hline
12+12
13+ & 12
14+ & 12
15+ & 12
16+\\
17+123
18+ & 123
19+ & 123
20+ & 123
21+\\
22+1
23+ & 1
24+ & 1
25+ & 1
26+\\
27+\end{tabular}
28+\end{center}
29+\caption{Demonstration of simple table syntax.}
30+\end{table}
31+
32+Simple table without caption:
33+
34+\begin{center}
35+\begin{tabular}{>{\PBS\raggedleft\hspace{0pt}}p{0.15\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.09\textwidth}>{\PBS\centering\hspace{0pt}}p{0.16\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.13\textwidth}}
36+Right
37+ & Left
38+ & Center
39+ & Default
40+\\
41+\hline
42+12
43+ & 12
44+ & 12
45+ & 12
46+\\
47+123
48+ & 123
49+ & 123
50+ & 123
51+\\
52+1
53+ & 1
54+ & 1
55+ & 1
56+\\
57+\end{tabular}
58+\end{center}
59+
60+Simple table indented two spaces:
61+
62+\begin{table}[h]
63+\begin{center}
64+\begin{tabular}{>{\PBS\raggedleft\hspace{0pt}}p{0.15\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.09\textwidth}>{\PBS\centering\hspace{0pt}}p{0.16\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.13\textwidth}}
65+Right
66+ & Left
67+ & Center
68+ & Default
69+\\
70+\hline
71+12
72+ & 12
73+ & 12
74+ & 12
75+\\
76+123
77+ & 123
78+ & 123
79+ & 123
80+\\
81+1
82+ & 1
83+ & 1
84+ & 1
85+\\
86+\end{tabular}
87+\end{center}
88+\caption{Demonstration of simple table syntax.}
89+\end{table}
90+
91+Multiline table with caption:
92+
93+\begin{table}[h]
94+\begin{center}
95+\begin{tabular}{>{\PBS\centering\hspace{0pt}}p{0.15\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.14\textwidth}>{\PBS\raggedleft\hspace{0pt}}p{0.16\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.34\textwidth}}
96+Centered Header
97+ & Left Aligned
98+ & Right Aligned
99+ & Default aligned
100+\\
101+\hline
102+First
103+ & row
104+ & 12.0
105+ & Example of a row that spans multiple lines.
106+\\
107+Second
108+ & row
109+ & 5.0
110+ & Here's another one. Note the blank line between rows.
111+\\
112+\end{tabular}
113+\end{center}
114+\caption{Here's the caption. It may span multiple lines.}
115+\end{table}
116+
117+Multiline table without caption:
118+
119+\begin{center}
120+\begin{tabular}{>{\PBS\centering\hspace{0pt}}p{0.15\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.14\textwidth}>{\PBS\raggedleft\hspace{0pt}}p{0.16\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.34\textwidth}}
121+Centered Header
122+ & Left Aligned
123+ & Right Aligned
124+ & Default aligned
125+\\
126+\hline
127+First
128+ & row
129+ & 12.0
130+ & Example of a row that spans multiple lines.
131+\\
132+Second
133+ & row
134+ & 5.0
135+ & Here's another one. Note the blank line between rows.
136+\\
137+\end{tabular}
138+\end{center}
139+
tests/tables.txtnew file+57
@@ -0,0 +1,57 @@
1+Simple table with caption:
2+
3+ Right Left Center Default
4+------- ------ ---------- -------
5+ 12 12 12 12
6+ 123 123 123 123
7+ 1 1 1 1
8+
9+Table: Demonstration of simple table syntax.
10+
11+Simple table without caption:
12+
13+ Right Left Center Default
14+------- ------ ---------- -------
15+ 12 12 12 12
16+ 123 123 123 123
17+ 1 1 1 1
18+
19+Simple table indented two spaces:
20+
21+ Right Left Center Default
22+ ------- ------ ---------- -------
23+ 12 12 12 12
24+ 123 123 123 123
25+ 1 1 1 1
26+
27+ Table: Demonstration of simple table syntax.
28+
29+Multiline table with caption:
30+
31+---------------------------------------------------------------
32+ Centered Left Right
33+ Header Aligned Aligned Default aligned
34+---------- --------- ----------- ---------------------------
35+ First row 12.0 Example of a row that spans
36+ multiple lines.
37+
38+ Second row 5.0 Here's another one. Note
39+ the blank line between rows.
40+---------------------------------------------------------------
41+
42+Table: Here's the caption.
43+It may span multiple lines.
44+
45+Multiline table without caption:
46+
47+---------------------------------------------------------------
48+ Centered Left Right
49+ Header Aligned Aligned Default aligned
50+---------- --------- ----------- ---------------------------
51+ First row 12.0 Example of a row that spans
52+ multiple lines.
53+
54+ Second row 5.0 Here's another one. Note
55+ the blank line between rows.
56+---------------------------------------------------------------
57+
tests/writer.latex+4
@@ -3,11 +3,15 @@
33\usepackage{ucs}
44\usepackage[utf8x]{inputenc}
55\usepackage{graphicx}
6+\usepackage{array}
67\setlength{\parindent}{0pt}
78\setlength{\parskip}{6pt plus 2pt minus 1pt}
89% This is needed for code blocks in footnotes:
910\usepackage{fancyvrb}
1011\VerbatimFootnotes
12+% This is needed because raggedright in table elements redefines //:
13+\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
14+\let\PBS=\PreserveBackslash
1115\setcounter{secnumdepth}{0}
1216\title{Pandoc Test Suite}
1317\author{John MacFarlane\\Anonymous}