diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-11-19 21:36:16 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-11-19 21:36:16 +0100 |
commit | 5a1796e65002f8ac719ff31e69de002f217069e5 (patch) | |
tree | dc052ce35a84519c544a99d9bf630a4526d585f9 /src | |
parent | e4798a6726e417decb959c86dae7545ab6c8522d (diff) | |
download | pandoc-5a1796e65002f8ac719ff31e69de002f217069e5.tar.gz |
LaTeX reader: improved parsing of tables.
Reader can now parse simple LaTeX tables such as those
generated by pandoc itself.
We still can't handle pandoc multiline tables which involve
minipages and column widths.
Partially addresses #2669.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index ab7aabab1..ca15cb59c 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1088,7 +1088,7 @@ environments = M.fromList resetCaption *> skipopts *> blocks >>= addImageCaption) , ("center", env "center" blocks) , ("longtable", env "longtable" $ - resetCaption *> skipopts *> blocks >>= addTableCaption) + resetCaption *> simpTable False >>= addTableCaption) , ("table", env "table" $ resetCaption *> skipopts *> blocks >>= addTableCaption) , ("tabular*", env "tabular" $ simpTable True) @@ -1374,7 +1374,9 @@ hline = try $ do return () lbreak :: LP () -lbreak = () <$ try (spaces' *> controlSeq "\\" <* spaces') +lbreak = () <$ try (spaces' *> + (controlSeq "\\" <|> controlSeq "tabularnewline") <* + spaces') amp :: LP () amp = () <$ try (spaces' *> char '&') @@ -1402,9 +1404,15 @@ simpTable hasWidthParameter = try $ do skipopts aligns <- parseAligns let cols = length aligns - optional hline - header' <- option [] $ try (parseTableRow cols <* lbreak <* hline) - rows <- sepEndBy (parseTableRow cols) (lbreak <* optional hline) + optional $ controlSeq "caption" *> skipopts *> setCaption + optional lbreak + spaces' + skipMany hline + header' <- option [] $ try (parseTableRow cols <* lbreak <* many1 hline) + rows <- sepEndBy (parseTableRow cols) (lbreak <* optional (skipMany hline)) + spaces' + optional $ controlSeq "caption" *> skipopts *> setCaption + optional lbreak spaces' let header'' = if null header' then replicate cols mempty |