-
Notifications
You must be signed in to change notification settings - Fork 32
Enable LuaMetaTeX in ConTeXt tests and examples #557
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
base: main
Are you sure you want to change the base?
Conversation
600a7fc
to
40aa8a2
Compare
8c981c0
to
98e0b37
Compare
98e0b37
to
c8aba5e
Compare
I wanted to test the new support for ConTeXt LMTX but I am still seeing some issues, namely the lack of support for the KPathSea library in LMTX, even in TeX Live, see the CI failure from this PR:
Looking into the file
This is perhaps to be expected: Even if KPathSea is available for LuaMetaTeX in TeX Live, we apparently need to use the predefined object |
@andreiborisov: Can you please test that you can compile the example file \startluacode
local kpse = require("kpse")
kpse.set_program_name("luatex")
\stopluacode Furthermore, you will also need to copy all dependencies to the directory
Please, let me know how that goes! If you manage to compile the example document, I will use your feedback to hopefully have the CI running the LMTX tests and compiling the LMTX examples in the next version, to be released by the end of March at the latest. 🤞 |
97ee0f0
to
4902747
Compare
Incidentally, I am currently in the process in removing the dependency on |
Sure, but that's starting from 'we are working in Lua'. For The NFD part is relatively small - so if push comes to shove I could find a way to pre-digest, or most likely parsing in Lua just for this would work. |
I'd say that really the time hit here is pretty small - most realistic documents for me take a lot longer to compile than the start-up time here. That said, I also do aim to support ConTeXt as best I can (despite the fact that in user terms it is smaller than LaTeX) - so I will look again at this, likely after a couple of meetings at the start of September. I am sure we can find an accommodation - even if I can't make things as fast as LaTeX (where we don't have to worry about reading time as that's all mopped up in the format-building process). |
I've put 'Unicode data' on the agenda for today's LaTeX team meeting - I'll report back on ideas. |
58506c0
to
2f7bf8c
Compare
I adapted your hack for ConTeXt MkIV, since we want fast format loading for both LuaTeX ( In commit 18d8b8c, I added the adapted code to our However, the sad news is that it currently doesn't seem to work. Let me demonstrate:
The processing is snappy but including expl3 in the format seems to break some parts of it like |
Hmm, probably has something to do with the fact that you can't dump Lua state into a format. Looks like this is specifically called out in the expl3 documentation as a potential issue with ConTeXt: You should ““just”” need to provide a suitable definition for |
Thanks for the directions, @gucci-on-fleek!
Besides the format file We might be able to achieve this without updating LaTeX3 by extending the hack from commit 18d8b8c with a file |
After ~4 months, the PR #569 is done and was released earlier today as a part of the Markdown package v3.11.5. The minimal set of remaining tasks for this PR is just the following, as outlined in #557 (comment):
This seems easy enough to finish in time for the next release v3.11.6, planned for September. To close #436, the following tasks also need to be finished:
If we can figure out how to store expl3's Lua state in a ConTeXt format, as discussed in #557 (comment), then we should also be able to include this change in v3.11.6. To close #402, the following tasks also need to be finished:
This is just some copy-editing. We should be able to close #402 together with #436. |
If you upload the Markdown package (and expl3) to https://modules.contextgarden.net/, you can just point people to this Wiki page. Otherwise, the instructions are:
I don't think that it's a good idea to recommend to users that they should build expl3 into their ConTeXt formats. Inside the Docker images, that's fairly safe to do so, since (1) anyone using the But outside of a container, things are different because (1) most ConTeXt users probably care more about their entire ConTeXt installation than the Markdown package, and (2) if something breaks, the entire ConTeXt installation could get broken, and they can't just pull an older container image to fix it. And by the way, thank you for the sponsorship! |
Thanks, that's useful!
I am not sure how reasonable it would be to distribute the Markdown package together with expl3. I'd be more in favor of keeping it as an external dependency that ConTeXt Standalone users have to install manually.
I'd put that as a caveat in the instructions and let people decide for themselves. |
I appreciate your and @josephwright's help and I am happy to buy you a coffee for your trouble! |
@Witiko We have a plan in hand to speed up loading |
Meanwhile: latex3/latex3#1791 |
@josephwright: Thanks for the update! It sounds like ConTeXt users will be getting a nice speed boost soon, even without bundling expl3 into the ConTeXt formats. I still plan to look into that later this month, but it feels much less critical now. Am I reading PR latex3/latex3#1791 correctly that ConTeXt Standalone users will need to install not only expl3 but also lua-uni-algos? That's a bit ironic, given that we dropped the lua-uni-algos dependency in #569 in the previous release of the Markdown package. Of course, the work from #569 is still useful for people who only use the Lua side of the Markdown package and not expl3: plain TeX and OpTeX users, for instance. |
Yes - we need to put the code somewhere and really this is Lua generic support not limited to |
After the l3kernel update, I am seeing a >3× speed-up in our tests, as discussed in #584. This is very encouraging! |
While trying to get the test suite to work with ConTeXt LMTX, I discovered another issue with LMTX support in expl3, which I reported in latex3/latex3#1797. |
The file diff --git a/examples/context.tex b/examples/context.tex
index 34b6b350..6bdabe94 100644
--- a/examples/context.tex
+++ b/examples/context.tex
@@ -4,10 +4,6 @@
\setupexternalfigures[location={local,global,default}]
% Load the Markdown module.
-\startluacode
-local kpse = require("kpse")
-kpse.set_program_name("luatex")
-\stopluacode
\usemodule[t][markdown]
% Set options of the Markdown module.
diff --git a/markdown-parser.lua b/usr/local/texlive/texmf-local/tex/luatex/markdown/markdown-parser.lua
index 8211451e..52f5d485 100644
--- a/markdown-parser.lua
+++ b/markdown-parser.lua
@@ -72,14 +72,6 @@ if not modules then modules = { } end
modules['markdown'] = metadata
local lpeg = require("lpeg")
local md5 = require("md5")
-;(function() -- luacheck: ignore
- local should_initialize = package.loaded.kpse == nil
- or tex.initialize ~= nil
- kpse = require("kpse")
- if should_initialize then
- kpse.set_program_name("luatex")
- end
-end)()
local M = {metadata = metadata}
local walkable_syntax = {
Block = {
@@ -7217,8 +7209,7 @@ end
M.extensions.content_blocks = function(language_map)
local languages_json = (function()
local base, prev, curr
- for _, pathname in ipairs{kpse.lookup(language_map,
- {all=true})} do
+ for _, pathname in ipairs(resolvers.findfiles(language_map)) do
local file = io.open(pathname, "r")
if not file then goto continue end
local input = assert(file:read("*a"))
@@ -9165,7 +9156,7 @@ function M.new(options)
end
for _, user_extension_filename in ipairs(options.extensions) do
local user_extension = (function(filename)
- local pathname = assert(kpse.find_file(filename),
+ local pathname = assert(resolvers.findfile(filename),
[[Could not locate user-defined syntax extension "]]
.. filename)
local input_file = assert(io.open(pathname, "r"), Here is the typeset result: The changes to the file |
This PR enables LuaMetaTeX in ConTeXt tests and examples after #551.