Skip to content
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

Version of Lua module is not normalized #354

Closed
Udi-Fogiel opened this issue May 9, 2024 · 10 comments
Closed

Version of Lua module is not normalized #354

Udi-Fogiel opened this issue May 9, 2024 · 10 comments

Comments

@Udi-Fogiel
Copy link

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

@josephwright
Copy link
Member

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

@Udi-Fogiel
Copy link
Author

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 reutenauer/polyglossia@ce56af7

@Udi-Fogiel
Copy link
Author

Udi-Fogiel commented May 9, 2024

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
Copy link
Member

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
Copy link
Author

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

@josephwright
Copy link
Member

@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
Copy link
Author

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

@muzimuzhi
Copy link
Contributor

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

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
Copy link
Member

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

spaced(string.gsub(info.version,"^(%d)","v%1"))

@Udi-Fogiel
Copy link
Author

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 latex3/latex2e#1364, so I'm closing here.
Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants