latex3 / lua-uni-algos

Unicode algorithms for use by LuaLaTeX packages
2 stars 4 forks source link

Always explicitly load the `kpse` module #3

Open Witiko opened 1 year ago

Witiko commented 1 year ago

The lua-uni-algos library uses the kpse global in two files: lua-uni-normalize.lua and lua-uni-parse.lua. This works out in a format such as LaTeX, where kpse has already been loaded. However, in ConTeXt MkIV and LMTX, kpse is a library stub that causes a fatal error when find_file and other methods are called.

Consider the following document example.tex with an MWE for ConTeXt MkIV:

\starttext
\directlua{
  local uni_case = require'lua-uni-case'
  tex.print(uni_case.casefold('Straße', true, false))
}
\stoptext

Typesetting the MWE with the context example command produces the following error:

fatal error: kpse library is accessed (key: find_file)

We can replace the stub library by explicitly loading the external kpse library:

\starttext
\directlua{
  kpse = require'kpse'
  kpse.set_program_name'kpsewhich'
  local uni_case = require'lua-uni-case'
  tex.print(uni_case.casefold('Straße', true, false))
}
\stoptext

Running context example again will produce a PDF document example.pdf with the expected output:

strasse