From ac0b1e4e2f568701beefb9a8482f6fad024e4250 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 23 Nov 2024 23:23:03 +0300 Subject: [PATCH] refactor(packages): Move CSL support module unter bibtex package --- {csl/spec => packages/bibtex/csl}/csl_spec.lua | 10 +++++----- {csl/core => packages/bibtex/csl}/engine.lua | 8 +++----- {csl/core => packages/bibtex/csl}/locale.lua | 8 +++----- {csl => packages/bibtex/csl}/locales/README.md | 0 .../bibtex/csl}/locales/locales-en-US.xml | 0 .../bibtex/csl}/locales/locales-fr-FR.xml | 0 {csl/core => packages/bibtex/csl}/style.lua | 7 +++---- {csl => packages/bibtex/csl}/styles/README.md | 0 .../bibtex/csl}/styles/chicago-author-date-fr.csl | 0 .../bibtex/csl}/styles/chicago-author-date.csl | 0 {csl/core => packages/bibtex/csl}/utils/casing.lua | 0 .../bibtex/csl}/utils/superfolding.lua | 0 .../bibtex/csl}/utils/xmlparser.lua | 0 packages/bibtex/init.lua | 13 +++++++------ 14 files changed, 21 insertions(+), 25 deletions(-) rename {csl/spec => packages/bibtex/csl}/csl_spec.lua (85%) rename {csl/core => packages/bibtex/csl}/engine.lua (99%) rename {csl/core => packages/bibtex/csl}/locale.lua (98%) rename {csl => packages/bibtex/csl}/locales/README.md (100%) rename {csl => packages/bibtex/csl}/locales/locales-en-US.xml (100%) rename {csl => packages/bibtex/csl}/locales/locales-fr-FR.xml (100%) rename {csl/core => packages/bibtex/csl}/style.lua (97%) rename {csl => packages/bibtex/csl}/styles/README.md (100%) rename {csl => packages/bibtex/csl}/styles/chicago-author-date-fr.csl (100%) rename {csl => packages/bibtex/csl}/styles/chicago-author-date.csl (100%) rename {csl/core => packages/bibtex/csl}/utils/casing.lua (100%) rename {csl/core => packages/bibtex/csl}/utils/superfolding.lua (100%) rename {csl/core => packages/bibtex/csl}/utils/xmlparser.lua (100%) diff --git a/csl/spec/csl_spec.lua b/packages/bibtex/csl/csl_spec.lua similarity index 85% rename from csl/spec/csl_spec.lua rename to packages/bibtex/csl/csl_spec.lua index a374263e4..e08b2ac7d 100644 --- a/csl/spec/csl_spec.lua +++ b/packages/bibtex/csl/csl_spec.lua @@ -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: diff --git a/csl/core/engine.lua b/packages/bibtex/csl/engine.lua similarity index 99% rename from csl/core/engine.lua rename to packages/bibtex/csl/engine.lua index aa7239240..013f2d9fb 100644 --- a/csl/core/engine.lua +++ b/packages/bibtex/csl/engine.lua @@ -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) @@ -1505,6 +1505,4 @@ function CslEngine:reference (entries) return self:_process(entries, "bibliography") end -return { - CslEngine = CslEngine, -} +return CslEngine diff --git a/csl/core/locale.lua b/packages/bibtex/csl/locale.lua similarity index 98% rename from csl/core/locale.lua rename to packages/bibtex/csl/locale.lua index 162f055b7..98944b434 100644 --- a/csl/core/locale.lua +++ b/packages/bibtex/csl/locale.lua @@ -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:", @@ -241,6 +241,4 @@ function CslLocale.read (filename) return CslLocale.parse(doc) end -return { - CslLocale = CslLocale, -} +return CslLocale diff --git a/csl/locales/README.md b/packages/bibtex/csl/locales/README.md similarity index 100% rename from csl/locales/README.md rename to packages/bibtex/csl/locales/README.md diff --git a/csl/locales/locales-en-US.xml b/packages/bibtex/csl/locales/locales-en-US.xml similarity index 100% rename from csl/locales/locales-en-US.xml rename to packages/bibtex/csl/locales/locales-en-US.xml diff --git a/csl/locales/locales-fr-FR.xml b/packages/bibtex/csl/locales/locales-fr-FR.xml similarity index 100% rename from csl/locales/locales-fr-FR.xml rename to packages/bibtex/csl/locales/locales-fr-FR.xml diff --git a/csl/core/style.lua b/packages/bibtex/csl/style.lua similarity index 97% rename from csl/core/style.lua rename to packages/bibtex/csl/style.lua index f3c0b681d..4ccbed5b6 100644 --- a/csl/core/style.lua +++ b/packages/bibtex/csl/style.lua @@ -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:", @@ -95,6 +96,4 @@ function CslStyle.read (filename) return CslStyle.parse(doc) end -return { - CslStyle = CslStyle, -} +return CslStyle diff --git a/csl/styles/README.md b/packages/bibtex/csl/styles/README.md similarity index 100% rename from csl/styles/README.md rename to packages/bibtex/csl/styles/README.md diff --git a/csl/styles/chicago-author-date-fr.csl b/packages/bibtex/csl/styles/chicago-author-date-fr.csl similarity index 100% rename from csl/styles/chicago-author-date-fr.csl rename to packages/bibtex/csl/styles/chicago-author-date-fr.csl diff --git a/csl/styles/chicago-author-date.csl b/packages/bibtex/csl/styles/chicago-author-date.csl similarity index 100% rename from csl/styles/chicago-author-date.csl rename to packages/bibtex/csl/styles/chicago-author-date.csl diff --git a/csl/core/utils/casing.lua b/packages/bibtex/csl/utils/casing.lua similarity index 100% rename from csl/core/utils/casing.lua rename to packages/bibtex/csl/utils/casing.lua diff --git a/csl/core/utils/superfolding.lua b/packages/bibtex/csl/utils/superfolding.lua similarity index 100% rename from csl/core/utils/superfolding.lua rename to packages/bibtex/csl/utils/superfolding.lua diff --git a/csl/core/utils/xmlparser.lua b/packages/bibtex/csl/utils/xmlparser.lua similarity index 100% rename from csl/core/utils/xmlparser.lua rename to packages/bibtex/csl/utils/xmlparser.lua diff --git a/packages/bibtex/init.lua b/packages/bibtex/init.lua index f46f13d56..070cecc49 100644 --- a/packages/bibtex/init.lua +++ b/packages/bibtex/init.lua @@ -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 @@ -22,7 +22,8 @@ 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