jperon / lyluatex

Alternative à lilypond-book pour lualatex
MIT License
56 stars 11 forks source link

Remove trailing \n from \lyluatexmanualdate #274

Closed uliska closed 4 years ago

uliska commented 5 years ago

The latest version of luaotfload changed handling of "missing characters", (as per https://github.com/u-fischer/luaotfload/blob/2943dbd326481a2359b18a5be958dcd852b0f064/NEWS#L5 and https://github.com/u-fischer/luaotfload/issues/65). When compiled with an up-to-date TeX Live the lyluatex manual now also shows this behaviour:

grafik

Investigation revealed that the issue is a traling \n character returned by io.popen('git log -n1 --date=short --format='..PC..'"ad"', 'r'), but I have no clue how to trim that within the \directlua context. All attempts that work in plain Lua or in a separate Lua file simply don't do so in the actual context.

uliska commented 5 years ago

Basically what would be necessary is

local git
if p then
    git = p:read('*a')
    git = git:match("(.-)\n")
    if p then p:close() end
end

But I have no idea how to produce that newline character in the match expression so it works in directlua as well. All attempts resulted either in the match resulting in nil or in some failure preventing the thing to execute at all.