Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pandoc Markdown parses too much LaTeX as a raw environment #9579

Closed
charmoniumQ opened this issue Mar 15, 2024 · 9 comments
Closed

Pandoc Markdown parses too much LaTeX as a raw environment #9579

charmoniumQ opened this issue Mar 15, 2024 · 9 comments

Comments

@charmoniumQ
Copy link

Explain the problem.

$ cat test.md
\begin{tabular}{p{2in}}
\end{tabular}

# Test

\begin{tabular}{p{2\linewidth}}
\end{tabular}

$ pandoc test.md --to=native
[ RawBlock
    (Format "tex")
    "\\begin{tabular}{p{2in}}\n\\end{tabular}\n\n# Test\n\n\\begin{tabular}{p{2\\linewidth}}\n\\end{tabular}"
]

However, switching the order of the tabular environments, removing any of the tabular environments, or changing \linewidth to \textwidth causes the correct parse, which should be:

[ RawBlock
    (Format "tex") "\\begin{tabular}{p{2in}}\n\\end{tabular}"
, Header 1 ( "test" , [] , [] ) [ Str "Test" ]
, RawBlock
    (Format "tex")
    "\\begin{tabular}{p{2\\textwidth}}\n\\end{tabular}"
]

Pandoc version?

$ pandoc --version
pandoc 3.1.11
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/sam/.local/share/pandoc
Copyright (C) 2006-2023 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.

NixOS (if that matters)

Based on the description, I think this is distinct from this issue, because this issue is not about table elements.

@jgm
Copy link
Owner

jgm commented Mar 15, 2024

I can reproduce this on the latest version too. It's quite bizarre!

@jgm
Copy link
Owner

jgm commented Mar 15, 2024

Processing this with pandoc -f latex -t native just yields one table, not two, and the intermediate stuff is ignored. Similarly if you delete the #.

@jgm
Copy link
Owner

jgm commented Mar 15, 2024

If you change the first 2in to 2\linewidth, it works, and if you change the second 2\linewidth to 2in, it works.

@jgm
Copy link
Owner

jgm commented Mar 15, 2024

% 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 ( "" , [] , [] ) [])
]

@jgm
Copy link
Owner

jgm commented Mar 15, 2024

Looking at the code, it seems that colwidth is currently set up only to handle cases like 2\linewidth, and not 2in. I'm not sure exactly how to handle 2in, because we don't have access to the linewidth in inches, but we could estimate I guess.

@jgm
Copy link
Owner

jgm commented Mar 15, 2024

@charmoniumQ
Copy link
Author

charmoniumQ commented Mar 15, 2024

When going from Markdown -> LaTeX, Should it not just pass through the \begin{...}...\end{...} as a raw block?

@jgm
Copy link
Owner

jgm commented Mar 15, 2024

Yes, that's the desired end result. But the Markdown reader is deferring to the LaTeX reader to parse the raw environment. Something is going wrong there.

@jgm
Copy link
Owner

jgm commented Mar 15, 2024

Also, as you can see above, this issue affects -f latex as well.

@jgm jgm closed this as completed in a1aca22 Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants