Skip to content

Instantly share code, notes, and snippets.

@h20y6m
Created July 11, 2023 11:44
Show Gist options
  • Save h20y6m/6a263f72389b31aad47c518f248929b7 to your computer and use it in GitHub Desktop.
Save h20y6m/6a263f72389b31aad47c518f248929b7 to your computer and use it in GitHub Desktop.
TeX Live 2023 06-01以降の環境でl3buildでpLaTeXのテストをするためのやつ
-- File: build-platex-on-euptex.lua
--
-- usage:
-- ```build.lua
-- kpse.set_program_name("kpsewhich")
-- ...
-- dofile("build-platex-on-euptex.lua")
-- ```
-- Check if a file contains lines matching a pattern
local function check_pattern_in_file(filename, pattern)
local f = io.open(filename, "r")
if f then
for line in f:lines() do
if string.match(line, pattern) then
f:close()
return true
end
end
f:close()
return false
else
return false
end
end
-- Check if platex based on e-upTeX
local function is_platex_euptex()
local fmtutil_cnf = kpse.lookup("fmtutil.cnf")
return check_pattern_in_file(fmtutil_cnf, "^platex%s+euptex%s+")
end
-- get platex's default internal kanji encoding
local function get_platex_kanji()
if os.type == "windows" then
return "sjis"
else
return "euc"
end
end
-- overwrite platex format if platex based on e-upTeX.
if is_platex_euptex() then
kanji = get_platex_kanji()
specialformats = {
latex = {
ptex = {binary = "euptex", format = "platex", options = "-kanji-internal="..kanji}
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment