diff options
author | Norbert Preining <norbert@preining.info> | 2023-11-19 03:01:17 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-11-19 03:01:17 +0000 |
commit | aa94b613f51dfa2b65c607585727b66875e765d8 (patch) | |
tree | 5628f2c082b66f54a44ba8064fcc0203823b9c92 /support | |
parent | bcd1a2a7dfe36b38f10a8fa23b4b6f0c325ca899 (diff) |
CTAN sync 202311190301
Diffstat (limited to 'support')
-rw-r--r-- | support/TeX4ht/source/ChangeLog | 11 | ||||
-rw-r--r-- | support/TeX4ht/source/tex4ht-4ht.tex | 7 | ||||
-rw-r--r-- | support/TeX4ht/source/tex4ht-fonts-noncjk.tex | 127 | ||||
-rw-r--r-- | support/cluttex/CHANGELOG.md | 12 | ||||
-rw-r--r-- | support/cluttex/Makefile | 16 | ||||
-rw-r--r-- | support/cluttex/README.md | 2 | ||||
-rw-r--r-- | support/cluttex/VERSION_0_6 | 0 | ||||
-rwxr-xr-x | support/cluttex/bin/cluttex | 96 | ||||
-rw-r--r-- | support/cluttex/bin/cluttex.bat | 96 | ||||
-rw-r--r-- | support/cluttex/doc/Makefile | 7 | ||||
-rw-r--r-- | support/cluttex/doc/cluttex-ja.pdf | bin | 152472 -> 153918 bytes | |||
-rw-r--r-- | support/cluttex/doc/cluttex-ja.tex | 25 | ||||
-rw-r--r-- | support/cluttex/doc/cluttex.1 | 144 | ||||
-rw-r--r-- | support/cluttex/doc/cluttex.pdf | bin | 193671 -> 193818 bytes | |||
-rw-r--r-- | support/cluttex/doc/cluttex.tex | 7 | ||||
-rw-r--r-- | support/cluttex/src/cluttex.lua | 61 | ||||
-rw-r--r-- | support/cluttex/src/texrunner/handleoption.lua | 20 | ||||
-rw-r--r-- | support/cluttex/src/texrunner/luatexinit.lua | 15 |
18 files changed, 523 insertions, 123 deletions
diff --git a/support/TeX4ht/source/ChangeLog b/support/TeX4ht/source/ChangeLog index 34703e1eac..22759f725d 100644 --- a/support/TeX4ht/source/ChangeLog +++ b/support/TeX4ht/source/ChangeLog @@ -1,3 +1,14 @@ +2023-11-17 Michal Hoftich <michal.h21@gmail.com> + + * tex4ht-fonts-noncjk.tex ( + ./tex4ht.dir/texmf/tex4ht/ht-fonts/unicode/latex/lasy.htf + ): updated lasy.htf and + Thanks to Arkady Benediktov + +2023-11-12 Karl Berry <karl@freefriends.org> + + * tex4ht-4ht.tex (array.4ht): write version. + 2023-11-10 Michal Hoftich <michal.h21@gmail.com> * tex4ht-4ht.tex (usepackage.4ht, accessibility-hooks.4ht, diff --git a/support/TeX4ht/source/tex4ht-4ht.tex b/support/TeX4ht/source/tex4ht-4ht.tex index dc39ccea90..bc5e473986 100644 --- a/support/TeX4ht/source/tex4ht-4ht.tex +++ b/support/TeX4ht/source/tex4ht-4ht.tex @@ -10076,10 +10076,9 @@ A border is set if the parameter request a drawing of a line. Good sample: tabsatz.tex \<array.4ht\><<< -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% array.4ht |version % -% Copyright (C) |CopyYear.1997. Eitan M. Gurari % -|<TeX4ht copyright|> +% array.4ht (|version), generated from |jobname.tex +% Copyright (C) |CopyYear.1997. Eitan M. Gurari +|<TeX4ht copywrite|> |<array hooks|> \Hinput{array} \endinput diff --git a/support/TeX4ht/source/tex4ht-fonts-noncjk.tex b/support/TeX4ht/source/tex4ht-fonts-noncjk.tex index 14766b8bd3..58e6cf94fc 100644 --- a/support/TeX4ht/source/tex4ht-fonts-noncjk.tex +++ b/support/TeX4ht/source/tex4ht-fonts-noncjk.tex @@ -1,4 +1,4 @@ -% $Id: tex4ht-fonts-noncjk.tex 1351 2023-07-28 18:19:42Z michal_h21 $ +% $Id: tex4ht-fonts-noncjk.tex 1410 2023-11-17 14:54:32Z michal_h21 $ % tex tex4ht-fonts-noncjk % or ht tex tex4ht-fonts-noncjk % @@ -12428,68 +12428,69 @@ lcircle 0 126 \<lasy-uni\><<< lasy 1 61 -'' '' 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -'⊲' ''trianlleft 2 % lasy.htf `version % -'⊴' ''trianlleft =3 % Copyright `CopyYear.2000. Eitan M. Gurari % -'⊳' ''trianglright 4 `<version 2`> -'⊵' ''trianglright=5 `<version 3`> -'' '' 6 `<version 4`> -'' '' 7 `<version 5`> -'' '' 8 `<version 6`> -'' '' 9 `<version 7`> -'' '' 10 `<version 8`> -'' '' 11 `<version 9`> -'' '' 12 `<version 10`> -'' '' 13 `<version 11`> -'' '' 14 `<version 12`> -'' '' 15 `<version 13`> -'' '' 16 `<version 14`> -'' '' 17 `<version 15`> -'' '' 18 `<version 16`> -'' '' 19 `<version 17`> -'' '' 20 `<version 18`> -'' '' 21 -'' '' 22 -'' '' 23 -'' '' 24 -'' '' 25 -'' '' 26 -'' '' 27 -'' '' 28 -'' '' 29 -'' '' 30 -'' '' 31 -'' '' 32 -'' '' 33 --- -- 34 -'' '' 35 -'' '' 36 -'' '' 37 -'' '' 38 --- -- 39 -'﹤' '' 40 -'﹥' '' 41 -'⌭' '' 42 -'⌬' '' 43 -'' '' 44 -'' '' 45 -'' '' 46 -'' '' 47 -'℧' ''omega 48 -'⋈' ''tie 49 -'□' ''sqr 50 -'◊' ''diamond 51 -'' '' 52 -'' '' 53 -'' '' 54 -'' '' 55 -'' '' 56 -'' '' 57 -'∼' '' 58 -'↝' '' 59 -'⊏' '' 60 -'⊐' '' 61 -lasy 1 61>>> +'⊲' '' trianlleft 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +'⊴' '' trianlleft 2 % lasy.htf `version % +'⊳' '' trianglright =3 % Copyright `CopyYear.2000. Eitan M. Gurari % +'⊵' '' trianglright 4 `<version 2`> +'' '' =5 `<version 3`> +'' '' 6 `<version 4`> +'' '' 7 `<version 5`> +'' '' 8 `<version 6`> +'' '' 9 `<version 7`> +'' '' 10 `<version 8`> +'' '' 11 `<version 9`> +'' '' 12 `<version 10`> +'' '' 13 `<version 11`> +'' '' 14 `<version 12`> +'' '' 15 `<version 13`> +'' '' 16 `<version 14`> +'' '' 17 `<version 15`> +'' '' 18 `<version 16`> +'' '' 19 `<version 17`> +'' '' 20 `<version 18`> +'' '' 21 +'' '' 22 +'' '' 23 +'' '' 24 +'' '' 25 +'' '' 26 +'' '' 27 +'' '' 28 +'' '' 29 +'' '' 30 +'' '' 31 +'' '' 32 +'' '' 33 +'' '' 34 +'' '' 35 +'' '' 36 +'' '' 37 +'' '' 38 +'' '' 39 +'˂' '' 40 % These are arrowheads (there are no special curved arrowheads in Unicode, so using these); see lasy.mf for details +'˃' '' 41 +'˄' '' 42 +'˅' '' 43 +'' '' 44 +'' '' 45 +'' '' 46 +'' '' 47 +'℧' '' invtd Ohm 48 +'⋈' '' bowtie 49 +'□' '' sqaure 50 +'◇' '' diamond 51 % Changed from 25CA (which was, in fact, the Lozenge symbol); see lasy.mf for details +'' '' 52 +'' '' 53 +'' '' 54 +'' '' 55 +'' '' 56 +'' '' 57 +'∼' '' 58 % This is an extension of the \leadsto (is end-to-end inside its glyph box; see lasy.mf), but there is no special Unicode point for this +'↝' '' leadsto 59 % tutorialspoint.com/tex_commands/ defines it as 21DD, which is a squiggle arrow, but there are dedicated squiggle arrows in TeX, so keep it as 219D +'⊏' '' 60 +'⊐' '' 61 +lasy 1 61 +>>> \AddFont{lasy-uni}{unicode/latex/lasy} diff --git a/support/cluttex/CHANGELOG.md b/support/cluttex/CHANGELOG.md index d73f9ea107..a2b857fbd6 100644 --- a/support/cluttex/CHANGELOG.md +++ b/support/cluttex/CHANGELOG.md @@ -1,3 +1,15 @@ +Version 0.6 (2023-11-18) +----- + +Changes: + +* Fix "arg" table in luatexinit to support luamplib +* Handle the combination of `--output-directory` and `--change-directory` properly ([Issue #7](https://github.com/minoki/cluttex/issues/7), thanks to @atticus-sullivan) +* Change `LUAINPUTS` environment variable to find Lua files if `--change-directory` is used ([PR #11](https://github.com/minoki/cluttex/pull/11), thanks to @atticus-sullivan) +* Watch engine can be selected via an optional argument to `--watch` ([PR #10](https://github.com/minoki/cluttex/pull/10), thanks to @atticus-sullivan) +* Decrease `max_print_line` to avoid issue with BibTeX from TeX Live 2023. +* Rerun biber if bib files are updated ([PR #12](https://github.com/minoki/cluttex/pull/12), thanks to @atticus-sullivan) + Version 0.5.1 (2021-11-04) ----- diff --git a/support/cluttex/Makefile b/support/cluttex/Makefile index 1fbf0fd55a..b6a00f5276 100644 --- a/support/cluttex/Makefile +++ b/support/cluttex/Makefile @@ -1,6 +1,6 @@ all: bin/cluttex bin/cluttex.bat -.PHONY: all archive +.PHONY: all archive check-version sources= \ src/texrunner/pathutil.lua \ @@ -35,6 +35,18 @@ bin/cluttex.bat: $(sources) build.lua lua build.lua --windows-batchfile $@ lua checkglobal.lua $@ -archive: all +version_file=$(shell bin/cluttex --version 2>&1 | grep --only-matching -E 'v\d+(\.\d+)*' | sed 's/^v/VERSION_/;s/\./_/g') + +check-version: all + @bin/cluttex --version + grep VERSION src/cluttex.lua + grep VERSION bin/cluttex + grep VERSION bin/cluttex.bat + grep -i VERSION doc/cluttex.tex + grep -i VERSION doc/cluttex-ja.tex + +archive: all check-version + @bin/cluttex --version git archive --format=tar --prefix=cluttex/ -o cluttex.tar HEAD + mkdir -p cluttex && touch cluttex/$(version_file) && tar -r -f cluttex.tar cluttex/$(version_file) gzip -k9 cluttex.tar diff --git a/support/cluttex/README.md b/support/cluttex/README.md index 80acb125ab..3ef64fd568 100644 --- a/support/cluttex/README.md +++ b/support/cluttex/README.md @@ -60,7 +60,7 @@ Command-line Options \[default: 3\] * `--[no-]change-directory` Change the current working directory to the output directory when running TeX. -* `--watch` +* `--watch[=ENGINE]` Watch input files for change. Requires [fswatch](http://emcrisostomo.github.io/fswatch/) program or `inotifywait` program to be installed on Unix systems. * `--color[=WHEN]` diff --git a/support/cluttex/VERSION_0_6 b/support/cluttex/VERSION_0_6 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/support/cluttex/VERSION_0_6 diff --git a/support/cluttex/bin/cluttex b/support/cluttex/bin/cluttex index ef8488c83e..fee0322268 100755 --- a/support/cluttex/bin/cluttex +++ b/support/cluttex/bin/cluttex @@ -1272,6 +1272,21 @@ texio.write = function(...) return texio_write(...) end ]==]) + + -- Fix "arg" to make luamplib work + initscript:write([==[ +if string.match(arg[0], "^%-%-lua=") then + local minindex = 0 + while arg[minindex - 1] ~= nil do + minindex = minindex - 1 + end + local arg2 = {} + for i = 0, #arg - minindex do + arg2[i] = arg[i + minindex] + end + arg = arg2 +end +]==]) initscript:close() end @@ -1369,7 +1384,7 @@ return { end package.preload["texrunner.handleoption"] = function(...) local COPYRIGHT_NOTICE = [[ -Copyright (C) 2016-2021 ARATA Mizuki +Copyright (C) 2016-2023 ARATA Mizuki This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1417,8 +1432,9 @@ Options: cross-references. [default: 3] --start-with-draft Start with draft mode. --[no-]change-directory Change directory before running TeX. - --watch Watch input files for change. Requires fswatch - program to be installed. + --watch[=ENGINE] Watch input files for change. Requires fswatch + or inotifywait to be installed. ENGINE is one of + `fswatch', `inotifywait' or `auto' [default: `auto'] --tex-option=OPTION Pass OPTION to TeX as a single option. --tex-options=OPTIONs Pass OPTIONs to TeX as multiple options. --dvipdfmx-option[s]=OPTION[s] Same for dvipdfmx. @@ -1492,6 +1508,8 @@ local option_spec = { }, { long = "watch", + param = true, + default = "auto", }, { short = "h", @@ -1682,7 +1700,7 @@ local function handle_cluttex_options(arg) elseif name == "watch" then assert(options.watch == nil, "multiple --watch options") - options.watch = true + options.watch = param elseif name == "help" then usage(arg) @@ -1840,6 +1858,15 @@ local function handle_cluttex_options(arg) set_default_values(options) + -- parameter validy check TODO should this be organized as function like + -- set_default_values and with a key in the option spec (list or function)? + if options.watch then + if options.watch ~= "fswatch" and options.watch ~= "inotifywait" then + message.error("Unknown wait engine '", options.watch, "'.") + os.exit(1) + end + end + if options.output_format == "pdf" then if options.check_driver ~= nil then error("--check-driver can only be used when the output format is DVI.") @@ -2933,7 +2960,7 @@ return { } end --[[ - Copyright 2016-2021 ARATA Mizuki + Copyright 2016-2023 ARATA Mizuki This file is part of ClutTeX. @@ -2951,7 +2978,7 @@ end along with ClutTeX. If not, see <http://www.gnu.org/licenses/>. ]] -CLUTTEX_VERSION = "v0.5.1" +CLUTTEX_VERSION = "v0.6" -- Standard libraries local coroutine = coroutine @@ -3051,9 +3078,13 @@ end local original_wd = filesys.currentdir() if options.change_directory then local TEXINPUTS = os.getenv("TEXINPUTS") or "" - filesys.chdir(options.output_directory) + local LUAINPUTS = os.getenv("LUAINPUTS") or "" + assert(filesys.chdir(options.output_directory)) options.output = pathutil.abspath(options.output, original_wd) os.setenv("TEXINPUTS", original_wd .. pathsep .. TEXINPUTS) + os.setenv("LUAINPUTS", original_wd .. pathsep .. LUAINPUTS) + -- after changing the pwd, '.' is always the output_directory (needed for some path generation) + options.output_directory = "." end if options.bibtex or options.biber then local BIBINPUTS = os.getenv("BIBINPUTS") or "" @@ -3063,14 +3094,15 @@ end -- Set `max_print_line' environment variable if not already set. if os.getenv("max_print_line") == nil then - os.setenv("max_print_line", "65536") + os.setenv("max_print_line", "16384") end --- TODO: error_line, half_error_line --[[ According to texmf.cnf: 45 < error_line < 255, 30 < half_error_line < error_line - 15, 60 <= max_print_line. + + On TeX Live 2023, (u)(p)bibtex fails if max_print_line >= 20000. ]] local function path_in_output_directory(ext) @@ -3104,6 +3136,11 @@ if engine.is_luatex then tex_options.lua_initialization_script = initscriptfile end +-- handle change_directory properly (needs to be after initscript gen) +if options.change_directory then + tex_options.output_directory = nil +end + -- Run TeX command (*tex, *latex) -- should_rerun, newauxstatus = single_run([auxstatus]) -- This function should be run in a coroutine. @@ -3299,7 +3336,7 @@ local function single_run(auxstatus, iteration) bibtex_aux_hash2 = md5.sum(table.concat(biblines2, "\n")) end local output_bbl = path_in_output_directory("bbl") - if bibtex_aux_hash ~= bibtex_aux_hash2 or reruncheck.comparefiletime(mainauxfile, output_bbl, auxstatus) then + if bibtex_aux_hash ~= bibtex_aux_hash2 or reruncheck.comparefiletime(pathutil.abspath(mainauxfile), output_bbl, auxstatus) then -- The input for BibTeX command has changed... local bibtex_command = { "cd", shellutil.escape(options.output_directory), "&&", @@ -3318,18 +3355,41 @@ local function single_run(auxstatus, iteration) end elseif options.biber then for _,file in ipairs(filelist) do + -- usual compilation with biber + -- tex -> pdflatex tex -> aux,bcf,pdf,run.xml + -- bcf -> biber bcf -> bbl + -- tex,bbl -> pdflatex tex -> aux,bcf,pdf,run.xml if pathutil.ext(file.path) == "bcf" then -- Run biber if the .bcf file is new or updated local bcffileinfo = {path = file.path, abspath = file.abspath, kind = "auxiliary"} local output_bbl = pathutil.replaceext(file.abspath, "bbl") - if reruncheck.comparefileinfo({bcffileinfo}, auxstatus) or reruncheck.comparefiletime(file.abspath, output_bbl, auxstatus) then - local bbl_dir = pathutil.dirname(file.abspath) + local updated_dot_bib = false + -- get the .bib files, the bcf uses as input + for l in io.lines(file.abspath) do + local bib = l:match("<bcf:datasource .*>(.*)</bcf:datasource>") -- might be unstable if biblatex adds e.g. a linebreak + if bib then + local bibfile = pathutil.join(original_wd, bib) + local succ, err = io.open(bibfile, "r") -- check if file is present, don't use touch to avoid triggering a rerun + if succ then + succ:close() + local updated_dot_bib_tmp = not reruncheck.comparefiletime(pathutil.abspath(mainauxfile), bibfile, auxstatus) + if updated_dot_bib_tmp then + message.info(bibfile.." is newer than aux") + end + updated_dot_bib = updated_dot_bib_tmp or updated_dot_bib + else + message.warn(bibfile .. " is not accessible (" .. err .. ")") + end + end + end + if updated_dot_bib or reruncheck.comparefileinfo({bcffileinfo}, auxstatus) or reruncheck.comparefiletime(file.abspath, output_bbl, auxstatus) then local biber_command = { options.biber, -- Do not escape options.biber to allow additional options "--output-directory", shellutil.escape(options.output_directory), pathutil.basename(file.abspath) } coroutine.yield(table.concat(biber_command, " ")) + -- watch for changes in the bbl table.insert(filelist, {path = output_bbl, abspath = output_bbl, kind = "auxiliary"}) else local succ, err = filesys.touch(output_bbl) @@ -3492,7 +3552,7 @@ if options.watch then watcher:close() return true end - elseif shellutil.has_command("fswatch") then + elseif shellutil.has_command("fswatch") and (options.watch == "auto" or options.watch == "fswatch") then if CLUTTEX_VERBOSITY >= 2 then message.info("Using `fswatch' command") end @@ -3516,7 +3576,7 @@ if options.watch then end return false end - elseif shellutil.has_command("inotifywait") then + elseif shellutil.has_command("inotifywait") and (options.watch == "auto" or options.watch == "inotifywait") then if CLUTTEX_VERBOSITY >= 2 then message.info("Using `inotifywait' command") end @@ -3541,7 +3601,13 @@ if options.watch then return false end else - message.error("Could not watch files because neither `fswatch' nor `inotifywait' was installed.") + if options.watch == "auto" then + message.error("Could not watch files because neither `fswatch' nor `inotifywait' was installed.") + elseif options.watch == "fswatch" then + message.error("Could not watch files because your selected engine `fswatch' was not installed.") + elseif options.watch == "inotifywait" then + message.error("Could not watch files because your selected engine `inotifywait' was not installed.") + end message.info("See ClutTeX's manual for details.") os.exit(1) end diff --git a/support/cluttex/bin/cluttex.bat b/support/cluttex/bin/cluttex.bat index 8d72a6c6c0..d54f0769bc 100644 --- a/support/cluttex/bin/cluttex.bat +++ b/support/cluttex/bin/cluttex.bat @@ -1275,6 +1275,21 @@ texio.write = function(...) return texio_write(...) end ]==]) + + -- Fix "arg" to make luamplib work + initscript:write([==[ +if string.match(arg[0], "^%-%-lua=") then + local minindex = 0 + while arg[minindex - 1] ~= nil do + minindex = minindex - 1 + end + local arg2 = {} + for i = 0, #arg - minindex do + arg2[i] = arg[i + minindex] + end + arg = arg2 +end +]==]) initscript:close() end @@ -1372,7 +1387,7 @@ return { end package.preload["texrunner.handleoption"] = function(...) local COPYRIGHT_NOTICE = [[ -Copyright (C) 2016-2021 ARATA Mizuki +Copyright (C) 2016-2023 ARATA Mizuki This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1420,8 +1435,9 @@ Options: cross-references. [default: 3] --start-with-draft Start with draft mode. --[no-]change-directory Change directory before running TeX. - --watch Watch input files for change. Requires fswatch - program to be installed. + --watch[=ENGINE] Watch input files for change. Requires fswatch + or inotifywait to be installed. ENGINE is one of + `fswatch', `inotifywait' or `auto' [default: `auto'] --tex-option=OPTION Pass OPTION to TeX as a single option. --tex-options=OPTIONs Pass OPTIONs to TeX as multiple options. --dvipdfmx-option[s]=OPTION[s] Same for dvipdfmx. @@ -1495,6 +1511,8 @@ local option_spec = { }, { long = "watch", + param = true, + default = "auto", }, { short = "h", @@ -1685,7 +1703,7 @@ local function handle_cluttex_options(arg) elseif name == "watch" then assert(options.watch == nil, "multiple --watch options") - options.watch = true + options.watch = param elseif name == "help" then usage(arg) @@ -1843,6 +1861,15 @@ local function handle_cluttex_options(arg) set_default_values(options) + -- parameter validy check TODO should this be organized as function like + -- set_default_values and with a key in the option spec (list or function)? + if options.watch then + if options.watch ~= "fswatch" and options.watch ~= "inotifywait" then + message.error("Unknown wait engine '", options.watch, "'.") + os.exit(1) + end + end + if options.output_format == "pdf" then if options.check_driver ~= nil then error("--check-driver can only be used when the output format is DVI.") @@ -2936,7 +2963,7 @@ return { } end --[[ - Copyright 2016-2021 ARATA Mizuki + Copyright 2016-2023 ARATA Mizuki This file is part of ClutTeX. @@ -2954,7 +2981,7 @@ end along with ClutTeX. If not, see <http://www.gnu.org/licenses/>. ]] -CLUTTEX_VERSION = "v0.5.1" +CLUTTEX_VERSION = "v0.6" -- Standard libraries local coroutine = coroutine @@ -3054,9 +3081,13 @@ end local original_wd = filesys.currentdir() if options.change_directory then local TEXINPUTS = os.getenv("TEXINPUTS") or "" - filesys.chdir(options.output_directory) + local LUAINPUTS = os.getenv("LUAINPUTS") or "" + assert(filesys.chdir(options.output_directory)) options.output = pathutil.abspath(options.output, original_wd) os.setenv("TEXINPUTS", original_wd .. pathsep .. TEXINPUTS) + os.setenv("LUAINPUTS", original_wd .. pathsep .. LUAINPUTS) + -- after changing the pwd, '.' is always the output_directory (needed for some path generation) + options.output_directory = "." end if options.bibtex or options.biber then local BIBINPUTS = os.getenv("BIBINPUTS") or "" @@ -3066,14 +3097,15 @@ end -- Set `max_print_line' environment variable if not already set. if os.getenv("max_print_line") == nil then - os.setenv("max_print_line", "65536") + os.setenv("max_print_line", "16384") end --- TODO: error_line, half_error_line --[[ According to texmf.cnf: 45 < error_line < 255, 30 < half_error_line < error_line - 15, 60 <= max_print_line. + + On TeX Live 2023, (u)(p)bibtex fails if max_print_line >= 20000. ]] local function path_in_output_directory(ext) @@ -3107,6 +3139,11 @@ if engine.is_luatex then tex_options.lua_initialization_script = initscriptfile end +-- handle change_directory properly (needs to be after initscript gen) +if options.change_directory then + tex_options.output_directory = nil +end + -- Run TeX command (*tex, *latex) -- should_rerun, newauxstatus = single_run([auxstatus]) -- This function should be run in a coroutine. @@ -3302,7 +3339,7 @@ local function single_run(auxstatus, iteration) bibtex_aux_hash2 = md5.sum(table.concat(biblines2, "\n")) end local output_bbl = path_in_output_directory("bbl") - if bibtex_aux_hash ~= bibtex_aux_hash2 or reruncheck.comparefiletime(mainauxfile, output_bbl, auxstatus) then + if bibtex_aux_hash ~= bibtex_aux_hash2 or reruncheck.comparefiletime(pathutil.abspath(mainauxfile), output_bbl, auxstatus) then -- The input for BibTeX command has changed... local bibtex_command = { "cd", shellutil.escape(options.output_directory), "&&", @@ -3321,18 +3358,41 @@ local function single_run(auxstatus, iteration) end elseif options.biber then for _,file in ipairs(filelist) do + -- usual compilation with biber + -- tex -> pdflatex tex -> aux,bcf,pdf,run.xml + -- bcf -> biber bcf -> bbl + -- tex,bbl -> pdflatex tex -> aux,bcf,pdf,run.xml if pathutil.ext(file.path) == "bcf" then -- Run biber if the .bcf file is new or updated local bcffileinfo = {path = file.path, abspath = file.abspath, kind = "auxiliary"} local output_bbl = pathutil.replaceext(file.abspath, "bbl") - if reruncheck.comparefileinfo({bcffileinfo}, auxstatus) or reruncheck.comparefiletime(file.abspath, output_bbl, auxstatus) then - local bbl_dir = pathutil.dirname(file.abspath) + local updated_dot_bib = false + -- get the .bib files, the bcf uses as input + for l in io.lines(file.abspath) do + local bib = l:match("<bcf:datasource .*>(.*)</bcf:datasource>") -- might be unstable if biblatex adds e.g. a linebreak + if bib then + local bibfile = pathutil.join(original_wd, bib) + local succ, err = io.open(bibfile, "r") -- check if file is present, don't use touch to avoid triggering a rerun + if succ then + succ:close() + local updated_dot_bib_tmp = not reruncheck.comparefiletime(pathutil.abspath(mainauxfile), bibfile, auxstatus) + if updated_dot_bib_tmp then + message.info(bibfile.." is newer than aux") + end + updated_dot_bib = updated_dot_bib_tmp or updated_dot_bib + else + message.warn(bibfile .. " is not accessible (" .. err .. ")") + end + end + end + if updated_dot_bib or reruncheck.comparefileinfo({bcffileinfo}, auxstatus) or reruncheck.comparefiletime(file.abspath, output_bbl, auxstatus) then local biber_command = { options.biber, -- Do not escape options.biber to allow additional options "--output-directory", shellutil.escape(options.output_directory), pathutil.basename(file.abspath) } coroutine.yield(table.concat(biber_command, " ")) + -- watch for changes in the bbl table.insert(filelist, {path = output_bbl, abspath = output_bbl, kind = "auxiliary"}) else local succ, err = filesys.touch(output_bbl) @@ -3495,7 +3555,7 @@ if options.watch then watcher:close() return true end - elseif shellutil.has_command("fswatch") then + elseif shellutil.has_command("fswatch") and (options.watch == "auto" or options.watch == "fswatch") then if CLUTTEX_VERBOSITY >= 2 then message.info("Using `fswatch' command") end @@ -3519,7 +3579,7 @@ if options.watch then end return false end - elseif shellutil.has_command("inotifywait") then + elseif shellutil.has_command("inotifywait") and (options.watch == "auto" or options.watch == "inotifywait") then if CLUTTEX_VERBOSITY >= 2 then message.info("Using `inotifywait' command") end @@ -3544,7 +3604,13 @@ if options.watch then return false end else - message.error("Could not watch files because neither `fswatch' nor `inotifywait' was installed.") + if options.watch == "auto" then + message.error("Could not watch files because neither `fswatch' nor `inotifywait' was installed.") + elseif options.watch == "fswatch" then + message.error("Could not watch files because your selected engine `fswatch' was not installed.") + elseif options.watch == "inotifywait" then + message.error("Could not watch files because your selected engine `inotifywait' was not installed.") + end message.info("See ClutTeX's manual for details.") os.exit(1) end diff --git a/support/cluttex/doc/Makefile b/support/cluttex/doc/Makefile index 0685cc8c58..2260a0079a 100644 --- a/support/cluttex/doc/Makefile +++ b/support/cluttex/doc/Makefile @@ -1,4 +1,4 @@ -all: cluttex.pdf cluttex-ja.pdf +all: cluttex.pdf cluttex-ja.pdf lint-manual cluttex.pdf: cluttex.tex cluttex -e pdflatex -o $@ --make-depends=cluttex.pdf.dep $< @@ -10,7 +10,10 @@ clean-outdir: -rm -rf $(shell cluttex -e pdflatex --print-output-directory cluttex.tex) -rm -rf $(shell cluttex -e lualatex --print-output-directory cluttex-ja.tex) -.PHONY: all clean-outdir +lint-manual: + mandoc -Tlint cluttex.1 + +.PHONY: all clean-outdir lint-manual -include cluttex.pdf.dep -include cluttex-ja.pdf.dep diff --git a/support/cluttex/doc/cluttex-ja.pdf b/support/cluttex/doc/cluttex-ja.pdf Binary files differindex c9f0750252..d8b98c15c9 100644 --- a/support/cluttex/doc/cluttex-ja.pdf +++ b/support/cluttex/doc/cluttex-ja.pdf diff --git a/support/cluttex/doc/cluttex-ja.tex b/support/cluttex/doc/cluttex-ja.tex index b4742ee4ee..3e79bccb8c 100644 --- a/support/cluttex/doc/cluttex-ja.tex +++ b/support/cluttex/doc/cluttex-ja.tex @@ -11,9 +11,27 @@ \crefformat{section}{#2セクション#1#3} \crefformat{subsection}{#2サブセクション#1#3} -\title{\ClutTeX{}マニュアル\\(バージョン0.5.1)} +\ltjsetparameter{ + alxspmode={`\-,allow}, + alxspmode={`\\,allow}, + alxspmode={`\.,allow}, + alxspmode={`\{,preonly}, + alxspmode={`\},postonly}, + alxspmode={`\_,allow}, + alxspmode={`\$,allow}, + alxspmode={`\!,allow}, + alxspmode={`\*,allow}, + alxspmode={`\^,allow}, + alxspmode={`\:,allow}, + alxspmode={`\#,allow}, + alxspmode={`\/,allow}, + alxspmode={`\<,preonly}, + alxspmode={`\>,postonly}, +} + +\title{\ClutTeX{}マニュアル\\(バージョン0.6)}%VERSION \author{ARATA Mizuki} -\date{2021年11月4日} +\date{2023年11月18日} \begin{document} \maketitle @@ -72,7 +90,7 @@ \item[\texttt{--max-iterations=\metavar{N}}] 相互参照の解決等のために最大何回処理を行うかを指定する。 デフォルト:3 -\item[\texttt{--watch}] +\item[\texttt{--watch[=\metavar{ENGINE}]}] 入力ファイルを監視する。 別途、\texttt{fswatch}プログラムまたは\texttt{inotifywait}プログラムが必要となる場合がある。 詳しくは\cref{sec:watch-mode}を参照。 @@ -162,6 +180,7 @@ Windows上では、\ClutTeX{}単体でファイルシステムの監視を行う。 一方で、それ以外のOS(Unix系)では、\texttt{fswatch}\footnote{\url{http://emcrisostomo.github.io/fswatch/}}プログラムまたは\texttt{inotifywait}プログラムが予めインストールされている必要がある。 +補助プログラムは自動検出されるが、\metavar{ENGINE}引数で明示的に指定することもできる。 \section{MakeIndexや\BibTeX} MakeIndexや\BibTeX を使って処理を行う場合は、\texttt{--makeindex}や\texttt{--bibtex}等のオプションを指定する。 diff --git a/support/cluttex/doc/cluttex.1 b/support/cluttex/doc/cluttex.1 new file mode 100644 index 0000000000..ab6c60f19d --- /dev/null +++ b/support/cluttex/doc/cluttex.1 @@ -0,0 +1,144 @@ +.Dd November 18, 2023 +.Dt CLUTTEX 1 +.Os +.Sh NAME +.Nm cluttex +.Nd a tool for processing TeX files +.Sh SYNOPSIS +.Nm +.Fl e +.Ar ENGINE +.Op options +.Op Fl \- +.Ar FILE.tex +.Sh DESCRIPTION +Process TeX files without cluttering your working directory. +.Pp +The following options are accepted: +.Bl -tag -width Ds +.It Fl e , Fl \-engine Ns = Ns Ar ENGINE +Specify which TeX engine to use. +.Ar ENGINE +is one of the following: +pdflatex, pdftex, +lualatex, luatex, luajittex, +xelatex, xetex, latex, etex, tex, +platex, eptex, ptex, +uplatex, euptex, uptex, +.It Fl \-engine\-executable Ns = Ns Ar COMMAND+OPTIONs +The actual TeX command to use. +[default: +.Ar ENGINE ] +.It Fl o , Fl \-output Ns = Ns Ar FILE +The name of output file. +[default: +.Ar JOBNAME Ns +\&.pdf or +.Ar JOBNAME Ns +\&.dvi] +.It Fl \-fresh +Clean intermediate files before running TeX. +Cannot be used with --output-directory. +.It Fl \-max-iterations Ns = Ns Ar N +Maximum number of running TeX to resolve cross-references. +[default: 3] +.It Fl \-start-with-draft +Start with draft mode. +.It Fl \-change-directory , Fl \-no-change-directory +Change directory before running TeX. +[default: no] +.It Fl \-watch Ns Op = Ns Ar ENGINE +Watch input files for change. +Requires fswatch or inotifywait to be installed. +.Ar ENGINE +is one of +.Sq fswatch , +.Sq inotifywait +or +.Sq auto . +[default: auto] +.It Fl \-tex-option Ns = Ns Ar OPTION +Pass +.Ar OPTION +to TeX as a single option. +.It Fl \-tex-options Ns = Ns Ar OPTIONs +Pass +.Ar OPTIONs +to TeX as multiple options. +.It Fl \-dvipdfmx-option Ns = Ns Ar OPTION , Fl \-dvipdfmx-options Ns = Ns Ar OPTIONs +Same for dvipdfmx. +.It Fl \-makeindex Ns = Ns Ar COMMAND+OPTIONs +Command to generate index, such as +.Sq makeindex +or +.Sq mendex . +.It Fl \-bibtex Ns = Ns Ar COMMAND+OPTIONs +Command for BibTeX, such as +.Sq bibtex +or +.Sq pbibtex . +.It Fl \-biber Ns Op = Ns Ar COMMAND+OPTIONs +Command for Biber. +.It Fl \-makeglossaries Ns Op = Ns Ar COMMAND+OPTIONs +Command for makeglossaries. +.It Fl h , Fl \-help +Print this message and exit. +.It Fl v , Fl \-version +Print version information and exit. +.It Fl V , Fl \-verbose +Be more verbose. +.It Fl \-color Ns Op = Ns Ar WHEN +Make ClutTeX's message more colorful. +.Ar WHEN +is one of +.Sq always , +.Sq auto , +or +.Sq never . +[default: +.Sq auto +if Fl \-color is omitted, +.Sq always +if +.Ar WHEN +is omitted] +.It Fl \-includeonly Ns = Ns Ar NAMEs +Insert +.Sq \eincludeonly{ Ns Ar NAMEs Ns } . +.It Fl \-make-depends Ns = Ns Ar FILE +Write dependencies as a Makefile rule. +.It Fl \-print\-output\-directory +Print the output directory and exit. +.It Fl \-package\-support Ns = Ns Ar PKG1 Ns Op , Ns Ar PKG2 Ns ,... +Enable special support for some shell-escaping packages. +Currently supported: minted, epstopdf. +.It Fl \-check\-driver Ns = Ns Ar DRIVER +Check that the correct driver file is loaded. +.Ar DRIVER +is one of +.Sq dvipdfmx , +.Sq dvips , +.Sq dvisvgm . +.It Fl \-shell-escape , Fl \-no-shell-escape +.It Fl \-shell-restricted +.It Fl \-synctex Ns = Ns Ar NUMBER +.It Fl \-fmt Ns = Ns Ar FMTNAME +.It Fl \-file-line-error , Fl \-no-file-line-error +[default: yes] +.It Fl \-halt-on-error , Fl \-no-halt-on-error +[default: yes] +.It Fl \-interaction Ns = Ns Ar STRING +[default: nonstopmode] +.It Fl \-jobname Ns = Ns Ar STRING +.It Fl \-output-directory Ns = Ns Ar DIR +[default: somewhere in the temporary directory] +.It Fl \-output-format Ns = Ns Ar FORMAT +.Ar FORMAT +is +.Sq pdf +or +.Sq dvi . +[default: pdf] +.El +.Sh EXIT STATUS +.Ex -std diff --git a/support/cluttex/doc/cluttex.pdf b/support/cluttex/doc/cluttex.pdf Binary files differindex 2d49565b10..d290b54384 100644 --- a/support/cluttex/doc/cluttex.pdf +++ b/support/cluttex/doc/cluttex.pdf diff --git a/support/cluttex/doc/cluttex.tex b/support/cluttex/doc/cluttex.tex index ae3bc01b67..2666ff44c9 100644 --- a/support/cluttex/doc/cluttex.tex +++ b/support/cluttex/doc/cluttex.tex @@ -8,9 +8,9 @@ \newcommand\texpkg[1]{\texttt{#1}} \newcommand\metavar[1]{\textnormal{\textsf{#1}}} -\title{\ClutTeX\ manual\\(Version 0.5.1)} +\title{\ClutTeX\ manual\\(Version 0.6)} \author{ARATA Mizuki} -\date{2021-11-04} +\date{2023-11-18} \begin{document} \maketitle @@ -66,7 +66,7 @@ Basic options: \item[\texttt{--max-iterations=\metavar{N}}] Set maximum number of run, for resolving cross-references and etc. Default: 3 -\item[\texttt{--watch}] +\item[\texttt{--watch[=\metavar{ENGINE}]}] Watch input files for change. May need an external program to be available. See \autoref{sec:watch-mode} for details. @@ -155,6 +155,7 @@ If \texttt{--watch} option is given, \ClutTeX\ enters \emph{watch mode} after pr On Windows, a built-in filesystem watcher is implemented. On other platforms, an auxiliary program \texttt{fswatch}\footnote{\url{http://emcrisostomo.github.io/fswatch/}} or \texttt{inotifywait} needs to be installed. +The auxiliary program will be detected automatically, but it could also be specified by the \metavar{ENGINE} argument. \section{MakeIndex and \BibTeX} If you want to generate index or bibliography, using MakeIndex or \BibTeX, set \texttt{--makeindex}, \texttt{--bibtex}, or \texttt{--biber} option. diff --git a/support/cluttex/src/cluttex.lua b/support/cluttex/src/cluttex.lua index d7875c0ab1..065d7fcc54 100644 --- a/support/cluttex/src/cluttex.lua +++ b/support/cluttex/src/cluttex.lua @@ -1,6 +1,6 @@ #!/usr/bin/env texlua --[[ - Copyright 2016-2021 ARATA Mizuki + Copyright 2016-2023 ARATA Mizuki This file is part of ClutTeX. @@ -18,7 +18,7 @@ along with ClutTeX. If not, see <http://www.gnu.org/licenses/>. ]] -CLUTTEX_VERSION = "v0.5.1" +CLUTTEX_VERSION = "v0.6" -- Standard libraries local table = table @@ -123,9 +123,13 @@ end local original_wd = filesys.currentdir() if options.change_directory then local TEXINPUTS = os.getenv("TEXINPUTS") or "" - filesys.chdir(options.output_directory) + local LUAINPUTS = os.getenv("LUAINPUTS") or "" + assert(filesys.chdir(options.output_directory)) options.output = pathutil.abspath(options.output, original_wd) os.setenv("TEXINPUTS", original_wd .. pathsep .. TEXINPUTS) + os.setenv("LUAINPUTS", original_wd .. pathsep .. LUAINPUTS) + -- after changing the pwd, '.' is always the output_directory (needed for some path generation) + options.output_directory = "." end if options.bibtex or options.biber then local BIBINPUTS = os.getenv("BIBINPUTS") or "" @@ -135,14 +139,15 @@ end -- Set `max_print_line' environment variable if not already set. if os.getenv("max_print_line") == nil then - os.setenv("max_print_line", "65536") + os.setenv("max_print_line", "16384") end --- TODO: error_line, half_error_line --[[ According to texmf.cnf: 45 < error_line < 255, 30 < half_error_line < error_line - 15, 60 <= max_print_line. + + On TeX Live 2023, (u)(p)bibtex fails if max_print_line >= 20000. ]] local function path_in_output_directory(ext) @@ -176,6 +181,11 @@ if engine.is_luatex then tex_options.lua_initialization_script = initscriptfile end +-- handle change_directory properly (needs to be after initscript gen) +if options.change_directory then + tex_options.output_directory = nil +end + -- Run TeX command (*tex, *latex) -- should_rerun, newauxstatus = single_run([auxstatus]) -- This function should be run in a coroutine. @@ -371,7 +381,7 @@ local function single_run(auxstatus, iteration) bibtex_aux_hash2 = md5.sum(table.concat(biblines2, "\n")) end local output_bbl = path_in_output_directory("bbl") - if bibtex_aux_hash ~= bibtex_aux_hash2 or reruncheck.comparefiletime(mainauxfile, output_bbl, auxstatus) then + if bibtex_aux_hash ~= bibtex_aux_hash2 or reruncheck.comparefiletime(pathutil.abspath(mainauxfile), output_bbl, auxstatus) then -- The input for BibTeX command has changed... local bibtex_command = { "cd", shellutil.escape(options.output_directory), "&&", @@ -390,18 +400,41 @@ local function single_run(auxstatus, iteration) end elseif options.biber then for _,file in ipairs(filelist) do + -- usual compilation with biber + -- tex -> pdflatex tex -> aux,bcf,pdf,run.xml + -- bcf -> biber bcf -> bbl + -- tex,bbl -> pdflatex tex -> aux,bcf,pdf,run.xml if pathutil.ext(file.path) == "bcf" then -- Run biber if the .bcf file is new or updated local bcffileinfo = {path = file.path, abspath = file.abspath, kind = "auxiliary"} local output_bbl = pathutil.replaceext(file.abspath, "bbl") - if reruncheck.comparefileinfo({bcffileinfo}, auxstatus) or reruncheck.comparefiletime(file.abspath, output_bbl, auxstatus) then - local bbl_dir = pathutil.dirname(file.abspath) + local updated_dot_bib = false + -- get the .bib files, the bcf uses as input + for l in io.lines(file.abspath) do + local bib = l:match("<bcf:datasource .*>(.*)</bcf:datasource>") -- might be unstable if biblatex adds e.g. a linebreak + if bib then + local bibfile = pathutil.join(original_wd, bib) + local succ, err = io.open(bibfile, "r") -- check if file is present, don't use touch to avoid triggering a rerun + if succ then + succ:close() + local updated_dot_bib_tmp = not reruncheck.comparefiletime(pathutil.abspath(mainauxfile), bibfile, auxstatus) + if updated_dot_bib_tmp then + message.info(bibfile.." is newer than aux") + end + updated_dot_bib = updated_dot_bib_tmp or updated_dot_bib + else + message.warn(bibfile .. " is not accessible (" .. err .. ")") + end + end + end + if updated_dot_bib or reruncheck.comparefileinfo({bcffileinfo}, auxstatus) or reruncheck.comparefiletime(file.abspath, output_bbl, auxstatus) then local biber_command = { options.biber, -- Do not escape options.biber to allow additional options "--output-directory", shellutil.escape(options.output_directory), pathutil.basename(file.abspath) } coroutine.yield(table.concat(biber_command, " ")) + -- watch for changes in the bbl table.insert(filelist, {path = output_bbl, abspath = output_bbl, kind = "auxiliary"}) else local succ, err = filesys.touch(output_bbl) @@ -564,7 +597,7 @@ if options.watch then watcher:close() return true end - elseif shellutil.has_command("fswatch") then + elseif shellutil.has_command("fswatch") and (options.watch == "auto" or options.watch == "fswatch") then if CLUTTEX_VERBOSITY >= 2 then message.info("Using `fswatch' command") end @@ -588,7 +621,7 @@ if options.watch then end return false end - elseif shellutil.has_command("inotifywait") then + elseif shellutil.has_command("inotifywait") and (options.watch == "auto" or options.watch == "inotifywait") then if CLUTTEX_VERBOSITY >= 2 then message.info("Using `inotifywait' command") end @@ -613,7 +646,13 @@ if options.watch then return false end else - message.error("Could not watch files because neither `fswatch' nor `inotifywait' was installed.") + if options.watch == "auto" then + message.error("Could not watch files because neither `fswatch' nor `inotifywait' was installed.") + elseif options.watch == "fswatch" then + message.error("Could not watch files because your selected engine `fswatch' was not installed.") + elseif options.watch == "inotifywait" then + message.error("Could not watch files because your selected engine `inotifywait' was not installed.") + end message.info("See ClutTeX's manual for details.") os.exit(1) end diff --git a/support/cluttex/src/texrunner/handleoption.lua b/support/cluttex/src/texrunner/handleoption.lua index 8d44567b46..937d4d5a57 100644 --- a/support/cluttex/src/texrunner/handleoption.lua +++ b/support/cluttex/src/texrunner/handleoption.lua @@ -1,5 +1,5 @@ local COPYRIGHT_NOTICE = [[ -Copyright (C) 2016-2021 ARATA Mizuki +Copyright (C) 2016-2023 ARATA Mizuki This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -47,8 +47,9 @@ Options: cross-references. [default: 3] --start-with-draft Start with draft mode. --[no-]change-directory Change directory before running TeX. - --watch Watch input files for change. Requires fswatch - program to be installed. + --watch[=ENGINE] Watch input files for change. Requires fswatch + or inotifywait to be installed. ENGINE is one of + `fswatch', `inotifywait' or `auto' [default: `auto'] --tex-option=OPTION Pass OPTION to TeX as a single option. --tex-options=OPTIONs Pass OPTIONs to TeX as multiple options. --dvipdfmx-option[s]=OPTION[s] Same for dvipdfmx. @@ -122,6 +123,8 @@ local option_spec = { }, { long = "watch", + param = true, + default = "auto", }, { short = "h", @@ -312,7 +315,7 @@ local function handle_cluttex_options(arg) elseif name == "watch" then assert(options.watch == nil, "multiple --watch options") - options.watch = true + options.watch = param elseif name == "help" then usage(arg) @@ -470,6 +473,15 @@ local function handle_cluttex_options(arg) set_default_values(options) + -- parameter validy check TODO should this be organized as function like + -- set_default_values and with a key in the option spec (list or function)? + if options.watch then + if options.watch ~= "fswatch" and options.watch ~= "inotifywait" then + message.error("Unknown wait engine '", options.watch, "'.") + os.exit(1) + end + end + if options.output_format == "pdf" then if options.check_driver ~= nil then error("--check-driver can only be used when the output format is DVI.") diff --git a/support/cluttex/src/texrunner/luatexinit.lua b/support/cluttex/src/texrunner/luatexinit.lua index 0135673787..d2c1701cb2 100644 --- a/support/cluttex/src/texrunner/luatexinit.lua +++ b/support/cluttex/src/texrunner/luatexinit.lua @@ -93,6 +93,21 @@ texio.write = function(...) return texio_write(...) end ]==]) + + -- Fix "arg" to make luamplib work + initscript:write([==[ +if string.match(arg[0], "^%-%-lua=") then + local minindex = 0 + while arg[minindex - 1] ~= nil do + minindex = minindex - 1 + end + local arg2 = {} + for i = 0, #arg - minindex do + arg2[i] = arg[i + minindex] + end + arg = arg2 +end +]==]) initscript:close() end |