Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass \markdownOptionOutputDir to lt3luabridge and better test support for the -output-directory option of TeX engines #459

Merged
merged 3 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Fixes:
(#453, #456, reported by @nopria, contributed by @lostenderman)
- Fix the interplay between lists and citations.
(witiko/expltools#3, #460, #461, contributed by @lostenderman)
- Do not override the `outputDir` option if if has been defined
before loading the package and pass it to lt3luabridge library.
(#457, #459)

Documentation:

Expand All @@ -18,6 +21,10 @@ Continuous Integration:

- Only test latest TeX Live in pull requests. (81927ca1)

Unit Tests:

- Test the `outputDir` plain TeX option. (#457, #459)

Libraries:

- Update `tinyyaml` to v0.4.4-1-g197632c. (1e83ac94)
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ARG DEPENDENCIES="\
poppler-utils \
python3-pygments \
python3-venv \
rename \
retry \
unzip \
wget \
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ EXAMPLES=examples/context-mkiv.pdf \
examples/latex-tex4ht.html examples/latex-tex4ht.css \
examples/optex.pdf
TESTS=tests/test.sh tests/test.py tests/requirements.txt tests/support/*.tex \
tests/templates/*/*/head.tex tests/templates/*/*/body.tex.m4 \
tests/templates/*/*/foot.tex tests/templates/*/COMMANDS.m4 tests/testfiles/*/*/*.test
tests/templates/*/*/head.tex.m4 tests/templates/*/*/body.tex.m4 \
tests/templates/*/*/foot.tex.m4 tests/templates/*/COMMANDS.m4 tests/testfiles/*/*/*.test
MAKES=Makefile $(addsuffix /Makefile, $(SUBDIRECTORIES)) latexmkrc
ROOT_README=README.md markdown.png
READMES=$(ROOT_README) LICENSE examples/README.md tests/README.md \
Expand Down
113 changes: 65 additions & 48 deletions markdown.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -11987,47 +11987,10 @@ For more information, see the examples for the \Opt{finalizeCache} option.
%
% \end{markdown}
% \begin{macrocode}
\cs_generate_variant:Nn
\@@_add_plain_tex_option:nnn
{ nnV }
% \end{macrocode}
% \begin{markdown}
%
% Use the \pkg{lt3luabridge} library to determine the default value of the
% \mref{markdownOptionOutputDir} macro by using the environmental variable
% `TEXMF_OUTPUT_DIRECTORY` that is available since TeX~Live 2024.
%
% \end{markdown}
% \begin{macrocode}
\ExplSyntaxOff
\input lt3luabridge.tex
\ExplSyntaxOn
\bool_if:nTF
{
\cs_if_exist_p:N
\luabridge_tl_set:Nn &&
(
\int_compare_p:nNn
{ \g_luabridge_method_int }
=
{ \c_luabridge_method_directlua_int } ||
\sys_if_shell_unrestricted_p:
)
}
{
\luabridge_tl_set:Nn
\l_tmpa_tl
{ print(os.getenv("TEXMF_OUTPUT_DIRECTORY") or ".") }
}
{
\tl_set:Nn
\l_tmpa_tl
{ . }
}
\@@_add_plain_tex_option:nnV
\@@_add_plain_tex_option:nnn
{ outputDir }
{ path }
\l_tmpa_tl
{ . }
% \end{macrocode}
% \iffalse
%</tex>
Expand Down Expand Up @@ -12303,22 +12266,73 @@ A PDF document named `document.pdf` should be produced and contain the text
% \end{macrocode}
% \begin{markdown}
%
% Do not override options defined before loading the package.
% Use the \pkg{lt3luabridge} library to determine the default value of the
% \mref{markdownOptionOutputDir} macro by using the environmental variable
% `TEXMF_OUTPUT_DIRECTORY` that is available since TeX~Live 2024.
%
% \end{markdown}
% \begin{macrocode}
\@@_option_tl_to_csname:nN
\str_if_eq:nnTF
{ #1 }
\l_tmpa_tl
\cs_if_exist:cF
{ \l_tmpa_tl }
{ outputDir }
{ \@@_define_option_command_output_dir: }
{
\@@_get_default_option_value:nN
{ #1 }
\l_tmpa_tl
\@@_set_option_value:nV
% \end{macrocode}
% \begin{markdown}
%
% Do not override options defined before loading the package.
%
% \end{markdown}
% \begin{macrocode}
\@@_option_tl_to_csname:nN
{ #1 }
\l_tmpa_tl
\cs_if_exist:cF
{ \l_tmpa_tl }
{
\@@_get_default_option_value:nN
{ #1 }
\l_tmpa_tl
\@@_set_option_value:nV
{ #1 }
\l_tmpa_tl
}
}
}
\ExplSyntaxOff
\input lt3luabridge.tex
\ExplSyntaxOn
\cs_new:Nn
\@@_define_option_command_output_dir:
{
\cs_if_free:NT
\markdownOptionOutputDir
{
\bool_if:nTF
{
\cs_if_exist_p:N
\luabridge_tl_set:Nn &&
(
\int_compare_p:nNn
{ \g_luabridge_method_int }
=
{ \c_luabridge_method_directlua_int } ||
\sys_if_shell_unrestricted_p:
)
}
{
\luabridge_tl_set:Nn
\l_tmpa_tl
{ print(os.getenv("TEXMF_OUTPUT_DIRECTORY") or ".") }
\tl_gset:NV
\markdownOptionOutputDir
\l_tmpa_tl
}
{
\tl_gset:Nn
\markdownOptionOutputDir
{ . }
}
}
}
\cs_new:Nn
Expand Down Expand Up @@ -34293,6 +34307,9 @@ end
}
}
}
\str_gset:NV
\g_luabridge_output_dirname_str
\markdownOptionOutputDir
\luabridge_now:e
{ #1 }
}
Expand Down
10 changes: 5 additions & 5 deletions tests/support/keyval-setup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@
lineBlock(Begin|End) = {%
\TYPE{#0}},
inputVerbatim = {%
\TYPE{#0: #1}},
\TYPE{#0: \NORMALIZEPATH{#1}}},
inputFencedCode = {%
\TYPE{BEGIN fencedCode}%
\TYPE{- src: #1}%
\TYPE{- src: \NORMALIZEPATH{#1}}%
\TYPE{- infostring: #3}%
\TYPE{END fencedCode}},
heading* = {%
Expand All @@ -144,7 +144,7 @@
inlineHtml(Comment|Tag) = {%
\TYPE{#0: #1}},
inputBlockHtmlElement = {%
\TYPE{#0: #1}},
\TYPE{#0: \NORMALIZEPATH{#1}}},
(ticked|halfTicked|unticked)Box = {%
\TYPE{#0}},
jekyllData(Boolean|Number|String) = {%
Expand Down Expand Up @@ -173,12 +173,12 @@
\TYPE{#0: #1}},
inputRawInline = {%
\TYPE{BEGIN rawInline}%
\TYPE{- src: #1}%
\TYPE{- src: \NORMALIZEPATH{#1}}%
\TYPE{- raw attribute: #2}%
\TYPE{END rawInline}},
inputRawBlock = {%
\TYPE{BEGIN rawBlock}%
\TYPE{- src: #1}%
\TYPE{- src: \NORMALIZEPATH{#1}}%
\TYPE{- raw attribute: #2}%
\TYPE{END rawBlock}},
replacementCharacter = {%
Expand Down
20 changes: 20 additions & 0 deletions tests/support/setup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,23 @@
\CITATIONSCOUNTER=1%
\def\CITATIONSTOTAL{#2}%
\DOCITATIONS{#1}}%

% Normalize pathnames by stripping all but the last fragment.
\ExplSyntaxOn
\cs_new:Npn
\NORMALIZEPATH
#1
{
\DONORMALIZEPATH
#1 / /
}
\cs_new:Npn
\DONORMALIZEPATH
#1 / #2 /
{
\tl_if_empty:nTF
{ #2 }
{ #1 }
{ \DONORMALIZEPATH #2 / }
}
\ExplSyntaxOff
16 changes: 9 additions & 7 deletions tests/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ This directory contains subdirectories, which correspond to individual TeX
formats. These subdirectories contain subdirectories with TeX source code
templates and a file named `COMMANDS.m4`.

The TeX source code templates contain three documents: `head.tex`,
`body.tex.m4`, and `foot.m4`. First, the file `body.tex.m4` is preprocessed by
The TeX source code templates contain three documents: `head.tex.m4`,
`body.tex.m4`, and `foot.tex.m4`. First, these files are preprocessed by
the m4 macro preprocessor with the following macro definitions:

1. `TEST_SETUP_FILENAME` corresponds to the name of the file containing the
test setup TeX source code.
2. `TEST_INPUT_FILENAME` corresponds to the name of the file containing the
test markdown source code.
1. `OUTPUT_DIRECTORY` corresponds to the name of the TeX output directory.
2. `TEST_SETUP_FILENAME` corresponds to the name of the file containing the
test setup TeX source code. This macro is only available in `body.tex.m4`.
3. `TEST_INPUT_FILENAME` corresponds to the name of the file containing the
test markdown source code. This macro is only available in `body.tex.m4`.

Then, the file `head.tex`, the preprocessing results of `body.tex.m4`, and the
file `foot.tex` are concatenated. Finally, the concatenation result is typeset.
Expand All @@ -18,5 +19,6 @@ The `COMMANDS.m4` file contains a newline-separated list of commands that will
be used to typeset the pre-processed TeX source code templates. Before use,
the commands will preprocessed with the following macro definitions:

1. `TEST_FILENAME` corresponds to the name of the pre-processed TeX source
1. `OUTPUT_DIRECTORY` corresponds to the name of the TeX output directory.
2. `TEST_FILENAME` corresponds to the name of the pre-processed TeX source
code template that is being typeset.
2 changes: 1 addition & 1 deletion tests/templates/context-mkiv/COMMANDS.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
context --once --luatex --nonstopmode TEST_FILENAME
context --result=OUTPUT_DIRECTORY`___'TEST_BASENAME --once --luatex --nonstopmode TEST_FILENAME && rename 's/___/\//' OUTPUT_DIRECTORY`___'TEST_BASENAME*
4 changes: 2 additions & 2 deletions tests/templates/latex/COMMANDS.m4
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pdflatex --shell-escape --interaction=nonstopmode TEST_FILENAME
lualatex --interaction=nonstopmode TEST_FILENAME
pdflatex -shell-escape -output-directory OUTPUT_DIRECTORY -interaction=nonstopmode TEST_FILENAME
lualatex -output-directory OUTPUT_DIRECTORY -interaction=nonstopmode TEST_FILENAME
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

% Load the support files.
\markdownSetup{
outputDir = OUTPUT_DIRECTORY,
import = {
witiko/markdown/test = snippet as testSnippet,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

% Load the support files.
\markdownSetup{
outputDir = OUTPUT_DIRECTORY,
import = {
witiko/markdown/test = snippet as testSnippet,
}
Expand Down
4 changes: 2 additions & 2 deletions tests/templates/plain/COMMANDS.m4
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pdftex --shell-escape --interaction=nonstopmode TEST_FILENAME
luatex --interaction=nonstopmode TEST_FILENAME
pdftex -shell-escape -output-directory OUTPUT_DIRECTORY -interaction=nonstopmode TEST_FILENAME
luatex -output-directory OUTPUT_DIRECTORY -interaction=nonstopmode TEST_FILENAME
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

% Load the support files.
\markdownSetup{
outputDir = OUTPUT_DIRECTORY,
import = {
witiko/markdown/test = snippet as testSnippet,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

% Load the support files.
\markdownSetup{
outputDir = OUTPUT_DIRECTORY,
import = {
witiko/markdown/test = snippet as testSnippet,
}
Expand Down
Loading