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

texlua manual.lua not usable to non-Windows users #478

Open
muzimuzhi opened this issue Feb 21, 2024 · 0 comments
Open

texlua manual.lua not usable to non-Windows users #478

muzimuzhi opened this issue Feb 21, 2024 · 0 comments
Labels
devel tools Development tools

Comments

@muzimuzhi
Copy link
Collaborator

Here I have to apply patch

diff --git a/manual.lua b/manual.lua
index 1d6b44e..0abd3a9 100644
--- a/manual.lua
+++ b/manual.lua
@@ -7,7 +7,8 @@ local function ReadFile(input)
     print("Error in reading " .. input)
     return
   end
-  local text = f:read("*all")
+  -- normalize line endings, https://stackoverflow.com/a/20599512
+  local text = f:read("*all"):gsub('\r\n?', '\n')
   f:close()
   return text
 end

to overcome lua error

manual.lua:29: attempt to concatenate a nil value (local 'body')

thrown when executing texlua manual.lua. Even then, a Git warning

warning: in the working copy of 'tabularray.tex', LF will be replaced by CRLF the next time Git touches it

is encountered.

tabularray (and perhaps other open source repos by the same author) need a workflow to allow users on OS's using different EOL characters working together.

Originally posted by @muzimuzhi in #443 (comment)

I guess replacing "rb" and "wb" with "r' and "w" will solve eol problem among different operating systems, if we also modify MakeManual function below, adding some \r characters.

local function ReadFile(input)
  local f = io.open(input, "rb")
  if f == nil then
    print("Error in reading " .. input)
    return
  end
  local text = f:read("*all")
  f:close()
  return text
end

local function WriteFile(output, text)
  f = io.open(output, "wb")
  f:write(text)
  f:close()
end

Originally posted by @lvjr in #443 (comment)

@lvjr lvjr added the devel tools Development tools label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devel tools Development tools
Projects
None yet
Development

No branches or pull requests

2 participants