fchauvel / flap

Flattening LaTeX projects
https://fchauvel.github.io/flap
GNU General Public License v3.0
17 stars 2 forks source link

wrong \input resolution order #33

Open Ohjeah opened 6 years ago

Ohjeah commented 6 years ago
15:12 $ flap tex/main.tex compressed -v
FLaP 0.5.0
File                            Line Column LaTeX Command                      
-------------------------------------------------------------------------------
main.tex                           6      1 \input{misc/header.tex}            
main.tex                          13      1 \input{content/abstract.tex}       
main.tex                          14      1 \input{misc/frontmatter.tex}       
main.tex                          15      1 \input{content/introduction.tex}   
main.tex                          16      1 \input{content/sota.tex}           
main.tex                          17      1 \input{content/methods.tex}        
content/methods.tex               17      5 \includegraphics[width=\columnwi...
content/methods.tex               73      5 \includegraphics[width=\columnwi...
main.tex                          18      1 \input{content/results.tex}        
content/results.tex               12      1 \input{"../tables/grid.tex"}       
Traceback (most recent call last):
  File "/home/mq/.miniconda/bin/flap", line 11, in <module>
    sys.exit(main())
  File "/home/mq/.miniconda/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/mq/.miniconda/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/mq/.miniconda/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mq/.miniconda/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/ui.py", line 102, in main
    Controller(OSFileSystem(), Display(sys.stdout, verbose)).run(tex_file, output)
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/ui.py", line 43, in run
    request.execute()
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/engine.py", line 79, in execute
    flattened = self._rewrite(self.read_root_tex, str(self.root_tex_file.resource()))
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/engine.py", line 88, in _rewrite
    return parser.rewrite()
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/latex/parser.py", line 78, in rewrite
    result += self._rewrite_one()
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/latex/parser.py", line 86, in _rewrite_one
    return self._evaluate_one()
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/latex/parser.py", line 138, in _evaluate_one
    return self.evaluate_command(str(self._next_token))
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/latex/parser.py", line 164, in evaluate_command
    return macro.invoke(self)
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/latex/macros.py", line 124, in invoke
    return self._execute(parser, invocation)
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/latex/macros.py", line 317, in _execute
    return parser._spawn(parser._create.as_tokens(content, link), dict()).rewrite()
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/latex/parser.py", line 78, in rewrite
    result += self._rewrite_one()
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/latex/parser.py", line 86, in _rewrite_one
    return self._evaluate_one()
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/latex/parser.py", line 138, in _evaluate_one
    return self.evaluate_command(str(self._next_token))
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/latex/parser.py", line 164, in evaluate_command
    return macro.invoke(self)
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/latex/macros.py", line 124, in invoke
    return self._execute(parser, invocation)
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/latex/macros.py", line 314, in _execute
    content = self._flap.content_of(link, invocation)
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/engine.py", line 118, in content_of
    file = self._find(location, [self.root_directory], ["tex"], TexFileNotFound(None))
  File "/home/mq/.miniconda/lib/python3.6/site-packages/flap/engine.py", line 175, in _find
    raise error
flap.engine.TexFileNotFound: None

The file structure is:

tables
figures
tex
|___main.tex
|___content
    |___results.tex

results.tex has the\input{../tables/grid.tex} command.

It compiles just fine, but I think flap resolves the inner most input first, hence the file cannot be found.

Ohjeah commented 6 years ago

Found the error, I actually wrote\input{"../tables/grid.tex"} which apparently causes an error.

fchauvel commented 6 years ago

Hi,

Sorry for this late reply and thanks for the feedback.

I suppose that the file “grid.tex” contains some sort of complex LaTeX tables. Would you get the same error if you try flattening an empty LaTeX document that contains only this table (or this erroneous input directive)?

On Tue, 20 Feb 2018 at 23:54, Markus Quade notifications@github.com wrote:

Found the error, I actually wrote\input{"../tables/grid.tex"} which apparently causes an error.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fchauvel/flap/issues/33#issuecomment-367149778, or mute the thread https://github.com/notifications/unsubscribe-auth/AA74eFb_myLsZnAthE6YqxBAresjnwgVks5tW00HgaJpZM4SIZEm .

Ohjeah commented 6 years ago

Yes, that file contains a complex, auto-generated table. It works just fine if I don't use quotes or place it so that I don't have to use the "..".

Btw, I get a similar issue with figures.

\includegraphics{"../figures/figure1.pdf"}

is translated to ".._figures_figure1.pdf". The file get's copied but pdflatex cannot handle such a filename.