diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2024-03-17 19:15:49 -0700 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2024-03-17 19:15:49 -0700 |
| commit | a1aca22e0dfa3e7d014419a47d395ae9d5c5a51e (patch) | |
| tree | 7545a98fcaedc2f0099fe5485d97ae165136299f /src | |
| parent | a22bac2361aee3376879f3e1946a1eb263a9a84e (diff) | |
LaTeX reader: better handling of colwidths.
Previously the parser just failed if the column width
specified in `p{}` wasn't a multiple of `\linewidth`.
This led to cases where content was skipped.
Now we treat these as ColWidthDefault and silently
parse the table.
A future improvement could be to guess relative column
widths from the dimensions specified, based on a default
line width.
Closes #9579.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Readers/LaTeX/Table.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX/Table.hs b/src/Text/Pandoc/Readers/LaTeX/Table.hs index e6e3fc436..d2d8223d6 100644 --- a/src/Text/Pandoc/Readers/LaTeX/Table.hs +++ b/src/Text/Pandoc/Readers/LaTeX/Table.hs @@ -87,11 +87,12 @@ parseAligns = try $ do let alignPrefix = symbol '>' >> braced let alignSuffix = symbol '<' >> braced let colWidth = try $ do - symbol '{' - ds <- trim . untokenize <$> manyTill anyTok (controlSeq "linewidth") - spaces - symbol '}' - return $ safeRead ds + ts <- braced + let isLinewidth (Tok _ (CtrlSeq "linewidth") _) = True + isLinewidth _ = False + case break isLinewidth ts of + (ds, _:_) -> return $ safeRead $ trim $ untokenize ds + _ -> return Nothing let alignSpec = do pref <- option [] alignPrefix spaces |
