Witiko / markdown

:notebook_with_decorative_cover: A package for converting and rendering markdown documents in TeX
http://ctan.org/pkg/markdown
LaTeX Project Public License v1.3c
328 stars 31 forks source link

script file `./markdown1.luabridge.lua` not found #457

Closed hongy19 closed 2 months ago

hongy19 commented 3 months ago

markdown works well before but I met following mistake after upgrading.

markdown1.log Screenshot 2024-06-30 195329

I use latex with latexmk and I could see markdown1.luabridge.lua in latex.out folder. I guess texlua should use latex.out/markdown1.luabridge.lua? but texlua is trying to use ./markdown1.luabridge.lua. I has configured "\def\markdownOptionOutputDir{latex.out}" to indicate output folder but seems texlua doesn't notice it.

(|texlua ./markdown1.luabridge.lua)
\markdownInputFileStream=\read2

here comes my .latexmkrc content:

$pdf_mode = 5;

$pdflatex = "pdflatex -file-line-error -halt-on-error -interaction=nonstopmode -synctex=1 %O %S";
$xelatex = "xelatex --shell-escape -file-line-error -halt-on-error -interaction=nonstopmode -no-pdf -synctex=1 %O %S";
$xdvipdfmx = "xdvipdfmx -E -o %D %O %S";

$out_dir="latex.out";
#$aux_dir="latex.out";

#$preview_mode = 1;
#$pdf_previewer="~/bin/pdf.sh";
#$pdf_previewer="/usr/bin/mupdf";
$pdf_previewer="start mupdf";

$clean_ext = "hd nav snm synctex.gz xdv";

$do_cd=1;

# How to make the PDF viewer update its display when the PDF file changes.  See the man page for a description of each method.
$pdf_update_method=2;
#
# # When PDF update method 2 is used, the number of the Unix signal to send
$pdf_update_signal='SIGHUP'
Witiko commented 3 months ago

I ha[ve] configured "\def\markdownOptionOutputDir{latex.out}" to indicate output folder but seems texlua doesn't notice it.

@hongy19: Hey there, thanks for reaching out!

The option \markdownOptionOutputDir has been deprecated in version 3.4.1 (2024-02-16). Instead, the output directory is automatically determined based on the parameter -output-directory of XeTeX. You should be able to remove \def\markdownOptionOutputDir{latex.out} from file markdown1.tex and achieve the same result. This won't solve your issue but will make your file tidier.

Here is what seems to be the cause of your issue:

  1. The library lt3luabridge that we use to execute texlua does not automatically determine the output directory based on the parameter -output-directory, see https://github.com/Witiko/lt3luabridge/issues/26.
  2. We do not pass the value of \markdownOptionOutputDir to the library lt3luabridge either.

You can fix your issue by adding the following code before \usepackage{markdown} in file markdown1.tex:

\def\markdownOptionOutputDir{latex.out}
\ExplSyntaxOn
\str_new:N
  \g_luabridge_output_dirname_str
\str_gset:NV
  \g_luabridge_output_dirname_str
  \markdownOptionOutputDir
\ExplSyntaxOff

After I have fixed both causes in the next release, you should be able to remove the above code from file markdown1.tex.

Please, let me know if this solved your issue, so that I know that I am on the right track!

hongy19 commented 3 months ago

@Witiko thanks for your feedback

I got following error with your suggestion, Latex log: markdown.log

| LaTeX Error: Control sequence \g_luabridge_output_dirname_str already defined.   
\documentclass{article}
\usepackage{markdown}
\def\markdownOptionOutputDir{latex.out}
\ExplSyntaxOn
\str_new:N
  \g_luabridge_output_dirname_str
\str_gset:NV
  \g_luabridge_output_dirname_str
  \markdownOptionOutputDir
\ExplSyntaxOff

\begin{document}
\begin{markdown}

- item1
  - item11
  - item12
- item2
    - item21
    - item22

\end{markdown}

\end{document}
Witiko commented 3 months ago

LaTeX Error: Control sequence \g_luabridge_output_dirname_str already defined.

Does it help if you move \usepackage{markdown} below the code, i.e. between \ExplSyntaxOff and \begin{document}?

hongy19 commented 3 months ago

LaTeX Error: Control sequence \g_luabridge_output_dirname_str already defined.

Does it help if you move \usepackage{markdown} below the code, i.e. between \ExplSyntaxOff and \begin{document}?

Thanks so much! it works

\documentclass{article}

\def\markdownOptionOutputDir{latex.out}
\ExplSyntaxOn
\str_new:N
  \g_luabridge_output_dirname_str
\str_gset:NV
  \g_luabridge_output_dirname_str
  \markdownOptionOutputDir
\ExplSyntaxOff
\usepackage{markdown}

\begin{document}
\begin{markdown}

- item1
  - item11
  - item12
- item2
    - item21
    - item22

\end{markdown}

\end{document}
Witiko commented 3 months ago

I am glad that worked! I plan to look at fixing this issue in the package later today. In addition to the issues from https://github.com/Witiko/markdown/issues/457#issuecomment-2203637382, we need a better tests for -output-directory, so that we don't see similar silent regressions in the future.