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

commit5a1796e65002f8ac719ff31e69de002f217069e5 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 19 Nov 2016, 21:36 (10 years ago) parente4798a6
1 file changed+13−5
src/Text/Pandoc/Readers/LaTeX.hs+13−5
src/Text/Pandoc/Readers/LaTeX.hs+13−5
@@ -1088,7 +1088,7 @@ environments = M.fromList
10881088 resetCaption *> skipopts *> blocks >>= addImageCaption)
10891089 , ("center", env "center" blocks)
10901090 , ("longtable", env "longtable" $
1091− resetCaption *> skipopts *> blocks >>= addTableCaption)
1091+ resetCaption *> simpTable False >>= addTableCaption)
10921092 , ("table", env "table" $
10931093 resetCaption *> skipopts *> blocks >>= addTableCaption)
10941094 , ("tabular*", env "tabular" $ simpTable True)
@@ -1374,7 +1374,9 @@ hline = try $ do
13741374 return ()
13751375
13761376lbreak :: LP ()
1377−lbreak = () <$ try (spaces' *> controlSeq "\\" <* spaces')
1377+lbreak = () <$ try (spaces' *>
1378+ (controlSeq "\\" <|> controlSeq "tabularnewline") <*
1379+ spaces')
13781380
13791381amp :: LP ()
13801382amp = () <$ try (spaces' *> char '&')
@@ -1402,9 +1404,15 @@ simpTable hasWidthParameter = try $ do
14021404 skipopts
14031405 aligns <- parseAligns
14041406 let cols = length aligns
1405− optional hline
1406− header' <- option [] $ try (parseTableRow cols <* lbreak <* hline)
1407− rows <- sepEndBy (parseTableRow cols) (lbreak <* optional hline)
1407+ optional $ controlSeq "caption" *> skipopts *> setCaption
1408+ optional lbreak
1409+ spaces'
1410+ skipMany hline
1411+ header' <- option [] $ try (parseTableRow cols <* lbreak <* many1 hline)
1412+ rows <- sepEndBy (parseTableRow cols) (lbreak <* optional (skipMany hline))
1413+ spaces'
1414+ optional $ controlSeq "caption" *> skipopts *> setCaption
1415+ optional lbreak
14081416 spaces'
14091417 let header'' = if null header'
14101418 then replicate cols mempty