Closed alexander-matsievsky closed 8 years ago
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
If you add this \providecomand
line to your
latex source, it should work. The problem is,
as it says, that pandoc doesn't know about
tabularnewline.
+++ alexander-matsievsky [Aug 24 16 10:58 ]:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands. %% Because html converters don't know tabularnewline \providecommand{\tabularnewline}{}
— You are receiving this because you are subscribed to this thread. Reply to this email directly, [1]view it on GitHub, or [2]mute the thread.
References
This snippet \providecommand{\tabularnewline}{\\}
is present in both input.txt
and input-wo-tabularnewline.txt
. The .tex
sources above are excerpts.
Besides that, pandoc seems to recognize this command and substitute \tabularnewline
with \\
when doing --parse-raw
:
> cat input.txt | pandoc --from=latex --to=markdown --parse-raw
\begin{tabular}{|c|c|c|}
\hline
a & b & c{\\}\hline
\hline
1 & 2 & 3{\\}\hline
\end{tabular}
I had to construct a pipeline to make it work from the original source:
> cat input.txt | pandoc --from=latex --to=markdown
<span>|c|c|c|</span> a & b & c<span>\
</span> 1 & 2 & 3<span>\
</span>
> cat input.txt | sed -e s/\\tabularnewline/\\\\/g | pandoc --from=latex --to=markdown
a b c
--- --- ---
1 2 3
I wonder if that's the only way.
Pandoc currently resolves macros only for math and for raw LaTeX bits. So if you use --parse-raw
, then pandoc will, on realizing it can't parse the table, emit a raw LaTeX table with the macro resolved. This isn't much help for converting to markdown, though. Also, there's an issue with the current macro resolution: spurious {}
are added, which breaks the table (see #1390).
It would be better to resolve macros on the raw latex before doing any parsing at all, with a two-pass system. For various complicated reasons it wasn't done this way in the first place.
@jgm Thank you for a detailed explanation!
Problem
Good day! I'm trying to convert a
.tex
document to.md
. I've encountered an issue with table rendering. Don't know whether it's a bug or I'm missing something. Grepping the web for an answer showed nothing, except https://github.com/jgm/pandoc/issues/2669. Your help will be greatly appreciated.Case 1
LyX-generated
.tex
file.Case 2
LyX-generated
.tex
file with\tabularnewline
command manually replaced with\\
System