diff --git a/src/Text/Pandoc/Readers/LaTeX/Table.hs b/src/Text/Pandoc/Readers/LaTeX/Table.hs index e6e3fc43685e..d2d8223d60a0 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 diff --git a/test/command/9579.md b/test/command/9579.md new file mode 100644 index 000000000000..6ebd71947dff --- /dev/null +++ b/test/command/9579.md @@ -0,0 +1,46 @@ +``` +% pandoc -t native +\begin{tabular}{p{2in}} +\end{tabular} + +# Test + +\begin{tabular}{p{2\linewidth}} +\end{tabular} +^D +[ RawBlock + (Format "tex") "\\begin{tabular}{p{2in}}\n\\end{tabular}" +, Header 1 ( "test" , [] , [] ) [ Str "Test" ] +, RawBlock + (Format "tex") + "\\begin{tabular}{p{2\\linewidth}}\n\\end{tabular}" +] +``` + +``` +% pandoc -f latex -t native +\begin{tabular}{p{2in}} +\end{tabular} + +Test + +\begin{tabular}{p{2\linewidth}} +\end{tabular} +^D +[ Table + ( "" , [] , [] ) + (Caption Nothing []) + [ ( AlignLeft , ColWidthDefault ) ] + (TableHead ( "" , [] , [] ) []) + [ TableBody ( "" , [] , [] ) (RowHeadColumns 0) [] [] ] + (TableFoot ( "" , [] , [] ) []) +, Para [ Str "Test" ] +, Table + ( "" , [] , [] ) + (Caption Nothing []) + [ ( AlignLeft , ColWidth 2.0 ) ] + (TableHead ( "" , [] , [] ) []) + [ TableBody ( "" , [] , [] ) (RowHeadColumns 0) [] [] ] + (TableFoot ( "" , [] , [] ) []) +] +```