jgm / pandoc

Universal markup converter
https://pandoc.org
Other
33.34k stars 3.31k forks source link

Footnote in Footnote (LaTeX) produces invalid output #6246

Open nxg opened 4 years ago

nxg commented 4 years ago

The following file produces invalid odt and docx output.

\documentclass{article}
\begin{document}
Hello, here is a footnote\footnote{Footnote\footnote{footnote2}}.    
\end{document}

I can convert this to OpenDocument and to Word, apparently successfully:

% pandoc -r latex -w odt -o try.odt try.tex
% pandoc -r latex -w docx -o try.docx try.tex

However when LibreOffice (6.4.2.2 on macOS 10.15) opens try.odt it reports ‘Format error discovered in the file in sub-document content.xml at 16,1(row,col)’ (which turns out to be the last line of the file), and when Pages opens try.docx it crashes. I don't know what Word does with try.docx.

Notes:

Footnotes-in-footnotes is generally a poor idea (cf discussion on #2053), but it shouldn't result in an invalid document. A warning or error would be better, or even, in extremis, XXX UNSUPPORTED in the output.

The standard LaTeX document classes don't support footnote-in-footnote without additional packages (the article class doesn't fail, but it simply drops the second footnote text), so I'm not arguing that this should be supported (I discovered this via a document where I'd accidentally put the second footnote inside the first, rather than just after it).

Issue #276 contains other discussion of this, which points to changes in the AST that any support for this would require.

$ pandoc --version
pandoc 2.7.3
Compiled with pandoc-types 1.17.6.1, texmath 0.11.3, skylighting 0.8.2.1
Default user data directory: /Users/norman/.local/share/pandoc or /Users/norman/.pandoc
Copyright (C) 2006-2019 John MacFarlane
Web:  http://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.

...installed on macOS 10.15 by nix-pkgs.

mb21 commented 4 years ago

I assume it's the same with the newest pandoc version?

nxg commented 4 years ago

I haven't tried with any more recent version, I'm afraid.

It would be good if I did, I know. I have in the past installed pandoc in a variety of different ways, not always successfully, and have become a positive Fan of nixpkgs both for the ease of installation (it works 90%+ of the time) and, crucially for me personally, the trivial ease of uninstallation. This is to the extent that I'm now generally reluctant to install things by other routes unless there's a strong reason to do so.

I can install the latest version if you really think it necessary, but I hope that the snippet included will allow someone to reproduce/verify the issue.

jgm commented 4 years ago

Not necessary, nothing has changed relevant to this.

We could have these writers (and others) check footnotes for footnotes, and, if present, replace them with '*' or something and issue a warning.