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.
This commit is contained in:
parent
e4798a6726
commit
5a1796e650
1 changed files with 13 additions and 5 deletions
|
@ -1088,7 +1088,7 @@ environments = M.fromList
|
||||||
resetCaption *> skipopts *> blocks >>= addImageCaption)
|
resetCaption *> skipopts *> blocks >>= addImageCaption)
|
||||||
, ("center", env "center" blocks)
|
, ("center", env "center" blocks)
|
||||||
, ("longtable", env "longtable" $
|
, ("longtable", env "longtable" $
|
||||||
resetCaption *> skipopts *> blocks >>= addTableCaption)
|
resetCaption *> simpTable False >>= addTableCaption)
|
||||||
, ("table", env "table" $
|
, ("table", env "table" $
|
||||||
resetCaption *> skipopts *> blocks >>= addTableCaption)
|
resetCaption *> skipopts *> blocks >>= addTableCaption)
|
||||||
, ("tabular*", env "tabular" $ simpTable True)
|
, ("tabular*", env "tabular" $ simpTable True)
|
||||||
|
@ -1374,7 +1374,9 @@ hline = try $ do
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
lbreak :: LP ()
|
lbreak :: LP ()
|
||||||
lbreak = () <$ try (spaces' *> controlSeq "\\" <* spaces')
|
lbreak = () <$ try (spaces' *>
|
||||||
|
(controlSeq "\\" <|> controlSeq "tabularnewline") <*
|
||||||
|
spaces')
|
||||||
|
|
||||||
amp :: LP ()
|
amp :: LP ()
|
||||||
amp = () <$ try (spaces' *> char '&')
|
amp = () <$ try (spaces' *> char '&')
|
||||||
|
@ -1402,9 +1404,15 @@ simpTable hasWidthParameter = try $ do
|
||||||
skipopts
|
skipopts
|
||||||
aligns <- parseAligns
|
aligns <- parseAligns
|
||||||
let cols = length aligns
|
let cols = length aligns
|
||||||
optional hline
|
optional $ controlSeq "caption" *> skipopts *> setCaption
|
||||||
header' <- option [] $ try (parseTableRow cols <* lbreak <* hline)
|
optional lbreak
|
||||||
rows <- sepEndBy (parseTableRow cols) (lbreak <* optional hline)
|
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'
|
spaces'
|
||||||
let header'' = if null header'
|
let header'' = if null header'
|
||||||
then replicate cols mempty
|
then replicate cols mempty
|
||||||
|
|
Loading…
Reference in a new issue