michal-h21 / make4ht

Build system for tex4ht
131 stars 15 forks source link

Error copying files when using build-dir and output-dir #149

Closed Danie-1 closed 2 weeks ago

Danie-1 commented 2 weeks ago

Create the following files: mwe.tex:

\documentclass{article}
\usepackage{styles}
\begin{document}
\end{document}

styles.sty (empty file) styles.4ht:

\Configure{AddCss}{styles.css}

styles.css (empty file)

Then run the following command: make4ht mwe.tex -B "builddir" -d "outdir".

I get the error cp: cannot stat 'builddir/styles.css': No such file or directory. I'm not sure if this is considered a bug, and I'm not too sure how to fix it. The same problem is also present when using tex4ebooks. I think the issue could be fixed for both make4ht and tex4ebook by modifying the copy or cp functions in mkutils.lua. Maybe the line saying kpse.find_file(src) would be a good place to add some more code. The thing that makes me a bit uncertain though is that I want to run another attempt where we remove the builddir from the beginning, but I can't do this because I don't know how to get the builddir from inside the cp function.

michal-h21 commented 2 weeks ago

I think this issue should be fixed in the development version: https://github.com/michal-h21/make4ht/commit/af9cfa3d050c8bc2551217d31d54e3fd745b59dd

The fix is in parse_lg function in mkutils.lua, where we check if the file referenced by the File: directive in the .lg file exists in the build dir. If it doesn't exist, the original path of the file is used.

Danie-1 commented 2 weeks ago

Thanks! I should've checked that the bug was still present on the latest version. I've tested again with the newer version and the bug isn't present anymore.