diff options
author | Karl Berry <karl@freefriends.org> | 2024-09-01 20:46:02 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-09-01 20:46:02 +0000 |
commit | ba22db1db9d53e12dff193c5ec6c02eeeacefc77 (patch) | |
tree | fb415e9ff2de570b8d22c76d10caaf1792fd6f71 /Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua | |
parent | 47033713446d65fe218881cd26bfa2880601864d (diff) |
citation-style-language (1sep24)
git-svn-id: svn://tug.org/texlive/trunk@72157 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua')
-rw-r--r-- | Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua | 143 |
1 files changed, 77 insertions, 66 deletions
diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua index 4bfab23c4ad..0f5e35c385d 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua @@ -53,9 +53,20 @@ local Position = util.Position ---@alias ItemId string | number ---@alias NoteIndex integer ---@alias ChapterIndex number ----@alias CitationData {citationID: CitationId, citationItems: CitationItem[], properties: CitationProperties, citation_index: integer} ----@alias CitationProperties { noteIndex: NoteIndex, chapterIndex: ChapterIndex, mode: string? } +---@class CitationData +---@field citationID CitationId +---@field citationItems CitationItem[] +---@field properties CitationProperties +---@field citation_index integer + +---@class CitationProperties +---@field noteIndex NoteIndex, +---@field chapterIndex ChapterIndex, +---@field mode string? +---@field prefix string? +---@field suffix string? + ---@class NameVariable ---@field family string? @@ -94,15 +105,22 @@ local Registry = {} ---@class CiteProc ---@field style Style ----@field sys any ----@field locales Locale[] ----@field system_locales Locale[] ----@field lang string +---@field sys CiteProcSys +---@field locales table<LanguageCode, Locale> +---@field system_locales table<LanguageCode, Locale> +---@field lang LanguageCode ---@field output_format OutputFormat ---@field opt table ---@field registry Registry ---@field cite_first_note_numbers table<ItemId, NoteIndex> ----@field locale_tags_info_dict {[LanguageCode]: table} +---@field cite_last_note_numbers table<ItemId, NoteIndex> +---@field note_citations_map table<NoteIndex, CitationId[]> +---@field tainted_item_ids table<ItemId, boolean> +---@field disam_irs IrNode[] +---@field cite_irs_by_output table<string, IrNode[]> +---@field person_names PersonNameIr[] +---@field person_names_by_output table<string, PersonNameIr[]> +---@field locale_tags_info_dict table<LanguageCode, table> local CiteProc = {} ---@class CiteProcSys @@ -125,64 +143,61 @@ function CiteProc.new(sys, style, lang, force_lang) if sys.retrieveItem == nil then error("\"citeprocSys.retrieveItem\" required") end - ---@type CiteProc - local o = {} - - o.style = Style:parse(style) - - o.sys = sys - o.locales = {} - o.system_locales = {} - - o.lang = o.style.default_locale - if not o.lang or force_lang then - o.lang = lang or "en-US" + local parsed_style = Style:parse(style) + local engine_lang = parsed_style.default_locale + if not engine_lang or force_lang then + engine_lang = lang or "en-US" end - - o.output_format = LatexWriter:new() - - o.opt = { - -- Similar to citeproc-js's development_extensions.wrap_url_and_doi - wrap_url_and_doi = false, - citation_link = false, - title_link = false, - } - - o.registry = { - citations_by_id = {}, -- A map - citation_list = {}, -- A list - citations_by_item_id = {}, -- A map from item id to a map of citations - registry = {}, -- A map of bibliographic meta data - reflist = {}, -- list of cited ids - uncited_list = {}, - previous_citation = nil, - requires_sorting = false, - widest_label = "", - maxoffset = 0, + ---@type CiteProc + local o = { + style = parsed_style, + sys = sys, + locales = {}, + system_locales = {}, + lang = engine_lang, + output_format = LatexWriter:new(), + opt = { + -- Similar to citeproc-js's development_extensions.wrap_url_and_doi + wrap_url_and_doi = false, + citation_link = false, + title_link = false, + }, + registry = { + citations_by_id = {}, -- A map + citation_list = {}, -- A list + citations_by_item_id = {}, -- A map from item id to a map of citations + registry = {}, -- A map of bibliographic meta data + reflist = {}, -- list of cited ids + uncited_list = {}, + previous_citation = nil, + requires_sorting = false, + widest_label = "", + maxoffset = 0, + }, + + cite_first_note_numbers = {}, + cite_last_note_numbers = {}, + note_citations_map = {}, + + tainted_item_ids = {}, + + disam_irs = {}, + -- { <ir1>, <ir2>, ... } + + cite_irs_by_output = {}, + -- { + -- ["Roe, J"] = {<ir1>}, + -- ["Doe, J"] = {<ir2>, <ir3>}, + -- ["Doe, John"] = {<ir2>}, + -- ["Doe, Jack"] = {<ir2>}, + -- } + + person_names = {}, + person_names_by_output = {}, + + locale_tags_info_dict = {}, } - o.cite_first_note_numbers = {} - o.cite_last_note_numbers = {} - o.note_citations_map = {} - - o.tainted_item_ids = {} - - o.disam_irs = {} - -- { <ir1>, <ir2>, ... } - - o.cite_irs_by_output = {} - -- { - -- ["Roe, J"] = {<ir1>}, - -- ["Doe, J"] = {<ir2>, <ir3>}, - -- ["Doe, John"] = {<ir2>}, - -- ["Doe, Jack"] = {<ir2>}, - -- } - - o.person_names = {} - o.person_names_by_output = {} - - o.locale_tags_info_dict = {} - setmetatable(o, { __index = CiteProc }) return o end @@ -444,15 +459,11 @@ function CiteProc:normalize_cite_item(cite_item) -- Assert CSL rich-text or HTML-like tagged string if cite_item.prefix == "" then cite_item.prefix = nil - else - cite_item.prefix_inlines = InlineElement:parse(cite_item.prefix, the_context, true) end end if cite_item.suffix then if cite_item.suffix == "" then cite_item.suffix = nil - else - cite_item.suffix_inlines = InlineElement:parse(cite_item.suffix, the_context, true) end end |