diff options
Diffstat (limited to 'Master/texmf-dist/scripts/citation-style-language/citeproc-latex.lua')
-rw-r--r-- | Master/texmf-dist/scripts/citation-style-language/citeproc-latex.lua | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-latex.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-latex.lua index 4b17ce35efc..6f521488f4e 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-latex.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-latex.lua @@ -1,5 +1,5 @@ -- --- Copyright (c) 2021-2022 Zeping Lee +-- Copyright (c) 2021-2023 Zeping Lee -- Released under the MIT license. -- Repository: https://github.com/zepinglee/citeproc-lua -- @@ -10,6 +10,7 @@ local citeproc = require("citeproc") local util = citeproc.util require("lualibs") local core = require("citeproc-latex-core") +local latex_parser = require("citeproc-latex-parser") csl.initialized = "false" @@ -38,10 +39,10 @@ function csl.init(style_name, bib_files, lang) csl.engine:updateItems(csl.id_list) if core.uncite_all_items then - for id, _ in pairs(core.bib) do - if not csl.uncited_id_map[id] then - table.insert(csl.uncited_id_list, id) - csl.uncited_id_map[id] = true + for _, item in ipairs(core.item_list) do + if not csl.uncited_id_map[item.id] then + table.insert(csl.uncited_id_list, item.id) + csl.uncited_id_map[item.id] = true end end end @@ -85,14 +86,17 @@ function csl.enable_linking() end +---comment +---@param citation_info string function csl.cite(citation_info) -- "citationID={ITEM-UNAVAILABLE@1},citationItems={{id={ITEM-UNAVAILABLE}}},properties={noteIndex={1}}" if not csl.engine then csl.error("CSL engine is not initialized.") end - -- util.debub(citation_info) + -- util.debug(citation_info) local citation = core.make_citation(citation_info) + -- util.debug(citation) local citation_str if csl.preview_mode then @@ -102,8 +106,8 @@ function csl.cite(citation_info) else citation_str = csl.engine:process_citation(citation) end - -- util.debug(citation_str) + -- tex.sprint(citation_str) -- tex.setcatcode(35, 12) -- # -- tex.setcatcode(37, 12) -- % @@ -118,7 +122,7 @@ function csl.nocite(ids_string) for _, uncited_id in ipairs(uncited_ids) do if uncited_id == "*" then if csl.engine then - for id, _ in pairs(core.bib) do + for id, _ in pairs(core.item_dict) do if not csl.uncited_id_map[id] then table.insert(csl.uncited_id_list, id) csl.uncited_id_map[id] = true @@ -141,13 +145,14 @@ function csl.nocite(ids_string) end -function csl.bibliography() +function csl.bibliography(filter_str) if not csl.engine then util.error("CSL engine is not initialized.") return end - local result = core.make_bibliography(csl.engine) + -- util.debug(filter) + local result = core.make_bibliography(csl.engine, filter_str) -- util.debug(result) -- token.set_macro("g__csl_bibliography_tl", result) @@ -156,4 +161,9 @@ function csl.bibliography() end +function csl.set_categories(categories_str) + core.set_categories(csl.engine, categories_str) +end + + return csl |