Skip to content

Commit

Permalink
refactor(packages): Move CSL support module unter bibtex package
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Nov 23, 2024
1 parent d4b0e7f commit cc581e2
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 25 deletions.
10 changes: 5 additions & 5 deletions csl/spec/csl_spec.lua → packages/bibtex/csl/csl_spec.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
SILE = require("core.sile")

local CslLocale = require("csl.core.locale").CslLocale
local CslStyle = require("csl.core.style").CslStyle
local CslEngine = require("csl.core.engine").CslEngine
local CslLocale = require("packages.bibtex.csl.locale")
local CslStyle = require("packages.bibtex.csl.style")
local CslEngine = require("packages.bibtex.csl.engine")

describe("CSL engine", function ()
local locale, err1 = CslLocale.read("csl/locales/locales-en-US.xml")
local style, err2 = CslStyle.read("csl/styles/chicago-author-date.csl")
local locale, err1 = CslLocale.read("packages/bibtex/csl/locales/locales-en-US.xml")
local style, err2 = CslStyle.read("packages/bibtex/csl/styles/chicago-author-date.csl")

-- The expected internal representation of the CSL entry is similar to CSL-JSON
-- but with some differences:
Expand Down
8 changes: 3 additions & 5 deletions csl/core/engine.lua → packages/bibtex/csl/engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
--
-- luacheck: no unused args

local CslLocale = require("csl.core.locale").CslLocale
local CslLocale = require("packages.bibtex.csl.locale")

local superfolding = require("csl.core.utils.superfolding")
local superfolding = require("packages.bibtex.csl.utils.superfolding")
local endash = luautf8.char(0x2013)
local emdash = luautf8.char(0x2014)

Expand Down Expand Up @@ -1505,6 +1505,4 @@ function CslEngine:reference (entries)
return self:_process(entries, "bibliography")
end

return {
CslEngine = CslEngine,
}
return CslEngine
8 changes: 3 additions & 5 deletions csl/core/locale.lua → packages/bibtex/csl/locale.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
-- - CslLocale:case(text, textCase) -> string
--

local casing = require("csl.core.utils.casing")
local casing = require("packages.bibtex.csl.utils.casing")
local xmlparser = require("packages.bibtex.csl.utils.xmlparser")

local xmlparser = require("csl.core.utils.xmlparser")
local parse = xmlparser.parse
local rules = {
prefix = "cs:",
Expand Down Expand Up @@ -241,6 +241,4 @@ function CslLocale.read (filename)
return CslLocale.parse(doc)
end

return {
CslLocale = CslLocale,
}
return CslLocale
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions csl/core/style.lua → packages/bibtex/csl/style.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
-- - (static method) CslStyle.read(filename) -> CslStyle
--

local xmlparser = require("csl.core.utils.xmlparser")
local xmlparser = require("packages.bibtex.csl.utils.xmlparser")

local parse = xmlparser.parse
local rules = {
prefix = "cs:",
Expand Down Expand Up @@ -95,6 +96,4 @@ function CslStyle.read (filename)
return CslStyle.parse(doc)
end

return {
CslStyle = CslStyle,
}
return CslStyle
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions packages/bibtex/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ local loadkit = require("loadkit")
local cslStyleLoader = loadkit.make_loader("csl")
local cslLocaleLoader = loadkit.make_loader("xml")

local CslLocale = require("csl.core.locale").CslLocale
local CslStyle = require("csl.core.style").CslStyle
local CslEngine = require("csl.core.engine").CslEngine
local CslLocale = require("packages.bibtex.csl.locale")
local CslStyle = require("packages.bibtex.csl.style")
local CslEngine = require("packages.bibtex.csl.engine")

local function loadCslLocale (name)
local filename = SILE.resolveFile("csl/locales/locales-" .. name .. ".xml")
or cslLocaleLoader("csl.locales.locales-" .. name)
local filename = SILE.resolveFile("packages/bibtex/csl/locales/locales-" .. name .. ".xml")
or cslLocaleLoader("packages.bibtex.csl.locales.locales-" .. name)
if not filename then
SU.error("Could not find CSL locale '" .. name .. "'")
end
Expand All @@ -22,7 +22,7 @@ local function loadCslLocale (name)
return locale
end
local function loadCslStyle (name)
local filename = SILE.resolveFile("csl/styles/" .. name .. ".csl") or cslStyleLoader("csl.styles." .. name)
local filename = SILE.resolveFile("packages/bibtex/csl/styles/" .. name .. ".csl") or cslStyleLoader("packages.bibtex.csl.styles." .. name)
if not filename then
SU.error("Could not find CSL style '" .. name .. "'")
end
Expand Down

0 comments on commit cc581e2

Please sign in to comment.