latex3 / l3build

A testing and building system for LaTeX
LaTeX Project Public License v1.3c
84 stars 14 forks source link

Version of Lua module is not normalized #354

Closed Udi-Fogiel closed 1 month ago

Udi-Fogiel commented 2 months ago

The version of Lua modules is displayed in the log of test files, can that be normalized?

josephwright commented 2 months ago

Can you provide a short demo? This is not something I've seen in our .tlg files.

Udi-Fogiel commented 2 months ago

Sure, sorry for not doing already, I just got out of home and did not want to forget to report. I'll add an example when I'll return to my computer.

If you don't want to wait, you can look at https://github.com/reutenauer/polyglossia/commit/ce56af747e794f9bf38f21f48aad8cf43836b046

Udi-Fogiel commented 2 months ago

This is build.lua

bundle = ""
module = "foo"
checkengines = {"luatex"}

In the testfiles directory a test with

\input{regression-test.tex}
\START
\directlua{require'foo'}
\END

and in the testfiles/support there is a file foo.lua which contains

local module = {
    name          = "foo",
    version       = "this is the version",
    date          = "2024/05/09"
}

luatexbase.provides_module(module)

the .tlg is

This is a generated file for the l3build validation system.
Don't change this file in any respect.
Lua module: foo ....-..-.. this is the version
josephwright commented 2 months ago

We already normalise things that 'look like' version strings: this isn't dependent on being from a Lua module. The current patterns cover classical LaTeX-like version strings (vX.Ya) and semantic versioning like (vX.Y.Z). The issue with the one you've pointed to is there's no indicator it's a version string: no leading v :(

Udi-Fogiel commented 2 months ago

Is it more appropriate that I'll ask from the fontspec maintainer to use version tags that fall under this scheme?

josephwright commented 2 months ago

@Udi-Fogiel I wonder if this would be better addressed in ltluatex? It would be easy to check if the version string starts with v and print it if not, so that there is consistency in how they are logged.

Udi-Fogiel commented 2 months ago

OK, let's keep this ticket open until it is addressed somewhere else?

muzimuzhi commented 2 months ago

In the LaTeX2e module ltluatex.dtx, currently the optional version field is loosely documented as a (lua) string and it happens both fontspec and polyglossia provide the version without leading v.

image

Maybe the luatexbase.provides_module() in ltluatex.dtx can add a leading v if version doesn't start with it.

Implementation of luatexbase.provides_module(), LaTeX2e 2023-11-01 Patch level 1

https://github.com/latex3/latex2e/blob/7cac63f1fa933a4bc643d934feca3407133ab698/base/ltluatex.dtx#L1011-L1026 ```lua local function provides_module(info) if not (info and info.name) then luatexbase_error("Missing module name for provides_module") end local function spaced(text) return text and (" " .. text) or "" end luatexbase_log( "Lua module: " .. info.name .. spaced(info.date) .. spaced(info.version) .. spaced(info.description) ) modules[info.name] = info end luatexbase.provides_module = provides_module ```

josephwright commented 2 months ago

@muzimuzhi Yes, I was thinking about something as simple as

spaced(string.gsub(info.version,"^(%d)","v%1"))
Udi-Fogiel commented 1 month ago

currently the optional version field is loosely documented as a (lua) string and it happens both fontspec and polyglossia provide the version without leading v.

Yes, the version of polyglossia.lua was not updated since 2013/05/11, which was probably before this convention, and probably should be changed :)

I addressed this in https://github.com/latex3/latex2e/issues/1364, so I'm closing here. Thanks for the help!