michal-h21 / LuaXML

Fork of LuaXML (originally Paul Chakravarti)
14 stars 9 forks source link

Release to luarocks #4

Closed zepinglee closed 3 weeks ago

zepinglee commented 1 year ago

I received a request to release the citeproc-lua package to luarocks (https://github.com/zepinglee/citeproc-lua/issues/35#issuecomment-1458026164) and it requiresluaxml and lua-uca. Are you interested in uploading them to luarocks? Or can I upload them instead?

I've resolved the dependencies for luarocks in citeproc-lua-dev-1.rockspec and it has passed the tests with Lua 5.3 & 5.4. As the path finding method in standard Lua is different from luatex (kpse), I've modified the requires in luaxml (see https://github.com/zepinglee/LuaXML/commit/48ffe3a6687b3564d5a6edf9e8b18ae29dd6a39b). The require "lua-uca.lua-uca-*" in lua-uca also works.

michal-h21 commented 1 year ago

It would be nice to release both packages to Luarocks. I've never done it, mainly because of the filenames issue, as LuaTeX requires non-standard naming because of kpse. Does the method from https://github.com/zepinglee/LuaXML/commit/48ffe3a6687b3564d5a6edf9e8b18ae29dd6a39b really work? Shouldn't it be rather something like:

local parse_query
if kpse then
  parse_query = require("luaxml-parse-query")
else
  parse_query = require("luaxml.luaxml-parse-query")
end
zepinglee commented 1 year ago

The file structure in the installed rock package is customizable in the .rockspec file. https://github.com/zepinglee/citeproc-lua/blob/7caf480e8a289c9781d73fcf4d05e33e8342c54c/citeproc-lua-dev-1.rockspec#L68-L78

      ["luaxml.cssquery"] = "submodules/luaxml/luaxml-cssquery.lua",
      ["luaxml.domobject"] = "submodules/luaxml/luaxml-domobject.lua",
      ["luaxml.entities"] = "submodules/luaxml/luaxml-entities.lua",
      ["luaxml.mod-handler"] = "submodules/luaxml/luaxml-mod-handler.lua",
      ["luaxml.mod-xml"] = "submodules/luaxml/luaxml-mod-xml.lua",
      ["luaxml.namedentities"] = "submodules/luaxml/luaxml-namedentities.lua",
      ["luaxml.parse-query"] = "submodules/luaxml/luaxml-parse-query.lua",
      ["luaxml.pretty"] = "submodules/luaxml/luaxml-pretty.lua",
      ["luaxml.stack"] = "submodules/luaxml/luaxml-stack.lua",
      ["luaxml.testxml"] = "submodules/luaxml/luaxml-testxml.lua",
      ["luaxml.transform"] = "submodules/luaxml/luaxml-transform.lua",

The installed tree after luarocks build:

➜  ~ tree ~/.luarocks/share/lua/5.3/luaxml
/Users/zepinglee/.luarocks/share/lua/5.3/luaxml
├── cssquery.lua
├── domobject.lua
├── entities.lua
├── mod-handler.lua
├── mod-xml.lua
├── namedentities.lua
├── parse-query.lua
├── pretty.lua
├── stack.lua
├── testxml.lua
└── transform.lua

With this structure the require("luaxml.domobject") works fine and it looks more natural to me. It's up to you to choose the paths and I'll adapt to them.

michal-h21 commented 1 year ago

Ah, I missed this detail. It looks nice. Do you want to make a pull request with these changes?

zepinglee commented 1 year ago

Sure. But here is already a luaxml package in luarocks (https://luarocks.org/modules/djerius/luaxml) and it should conflict with this. Would you pick another name?

michal-h21 commented 1 year ago

Ah, yes, I think there are several versions of this library that originated from the same source, but then diverged. I think https://luarocks.org/modules/manoelcampos/xml2lua is another one. My main contribution is the DOM library, it is not part of the original version.

I am not sure what a good name could be? Something like MHLuaXML, or LuaTeXML? I am not really good at inventing names.

zepinglee commented 1 year ago

Ummm... Neither am I. I picked MHLuaXML and made #5.

zepinglee commented 1 year ago

I've also made a PR for lua-uca (https://github.com/michal-h21/lua-uca/pull/5). You can then follow the guide in https://github.com/luarocks/luarocks/wiki/Creating-a-rock#submitting-a-rockspec-for-inclusion-in-the-rocks-server or https://luarocks.org/upload to upload both these packages to luarocks.

michal-h21 commented 1 year ago

I've just uploaded both packages to Luarocks. Thank you for your assistance, it really helped me.