jgm / pandoc

Universal markup converter
https://pandoc.org
Other
33.89k stars 3.34k forks source link

Ability to set working directory #10020

Open scruel opened 1 month ago

scruel commented 1 month ago

Describe your proposed improvement and the problem it solves. Currently, pandoc can't parse the tex file which included other tex files:

scruel in pile-arxiv/tmp at JMUSE-AS-2124GQ-NART on  master [!?] via 🅒 arxiv …
➜ pandoc -s 2406.11068/main.tex -o out.md --wrap=none
[WARNING] Could not load include file sections/preamble.tex at 2406.11068/main.tex line 108 column 26
[WARNING] Could not load include file sections/abstract.tex at 2406.11068/main.tex line 116 column 26
[WARNING] Could not load include file sections/introduction.tex at 2406.11068/main.tex line 117 column 30
[WARNING] Could not load include file sections/related_work.tex at 2406.11068/main.tex line 118 column 30
[WARNING] Could not load include file sections/approach.tex at 2406.11068/main.tex line 119 column 26
[WARNING] Could not load include file sections/experiments.tex at 2406.11068/main.tex line 120 column 29
[WARNING] Could not load include file sections/conclusion.tex at 2406.11068/main.tex line 122 column 28
[WARNING] Could not load include file sections/acknowledgment.tex at 2406.11068/main.tex line 124 column 32

Even with --resource-path=2406.11068 or --resource-path=2406.11068/sections.

Describe alternatives you've considered. cd into the working dir, then re-executing the commands.

jgm commented 1 month ago

What version of pandoc?

It ought to be smarter; it knows the directory of the including file and could resolve the include relative to that.

scruel commented 1 month ago

$ pandoc --version pandoc 3.1.3 Features: +server +lua Scripting engine: Lua 5.4 User data directory: /home/scruel/.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

Same warning output with pandoc 3.2.1

TomBener commented 1 month ago

The issue cannot be reproduced with Pandoc 3.2.1 on my machine. I suspect it is the issue with your folder structure. I have uploaded a folder for your testing and diagnose. The files were copied from tuna/thuthesis.

test-10020.zip

scruel commented 1 month ago

@TomBener

wget https://arxiv.org/src/2406.11068
mkdir tmp
tar xf 2406.11068 -C tmp
pandoc -s tmp/main.tex -o out.md
jgm commented 1 month ago

How exactly does TeX resolve these? I note that tmp/sections/appendix.tex has \input{sections/tables/vip} and not \input{tables/vip} -- so are all input paths, no matter where they are specified, resolved relative to the main tex file? OR is there a more complicated algorithm/search path?