lvjr / tabularray

Typeset tabulars and arrays with LaTeX3
https://ctan.org/pkg/tabularray
247 stars 22 forks source link

Improve docs for `booktabs` lib #443

Closed muzimuzhi closed 4 months ago

muzimuzhi commented 8 months ago

Main changes

WARNING

tabularray.tex is not updated, due to EOL issue previously encountered and discussed in https://github.com/lvjr/tabularray/pull/385#issuecomment-1474807700.

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.

lvjr commented 5 months ago

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
muzimuzhi commented 4 months ago

I dropped patch to ReadFile() in manual.lua, and added #478 for EOL normalization issue.

lvjr commented 4 months ago

I think we can keep those extra spaces in testfiles/table-010.tex file, because it may be useful in the far future (see #13 and #305).

muzimuzhi commented 4 months ago

I think we can keep those extra spaces in testfiles/table-010.tex file, because it may be useful in the far future (see #13 and #305).

I'm not convinced. That example in table-010.tex tests against #32 specifically. New feature, when added, can be tested with new examples. https://github.com/lvjr/tabularray/blob/54cceacaa5a951189e13d220014b4852598f0f75/testfiles/table-010.tex#L21-L27

I agree that minimal and integrated test examples are both needed in some extent, so feel free to restore changes in table-010.tex if that's the way you prefer.