diff options
Diffstat (limited to 'biblio/citation-style-language/citeproc-cli.lua')
-rw-r--r-- | biblio/citation-style-language/citeproc-cli.lua | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/biblio/citation-style-language/citeproc-cli.lua b/biblio/citation-style-language/citeproc-cli.lua index 97a51d724c..a199c8e68c 100644 --- a/biblio/citation-style-language/citeproc-cli.lua +++ b/biblio/citation-style-language/citeproc-cli.lua @@ -10,6 +10,7 @@ local cli = {} require("lualibs") local citeproc = require("citeproc") +local bibtex -- = require("citeproc-bibtex") -- load on demand local util = require("citeproc-util") local core = require("citeproc-latex-core") @@ -67,13 +68,17 @@ end local function convert_bib(path, output_path) local contents = util.read_file(path) - local bib = citeproc.parse_bib(contents) + bibtex = bibtex or require("citeproc-bibtex") + local data = bibtex.parse(contents) if not output_path then output_path = string.gsub(path, "%.bib$", ".json") end local file = io.open(output_path, "w") - file:write(utilities.json.tojson(bib)) - file:write('\n') + if not file then + util.error(string.format('Cannot write "%s".', output_path)) + return + end + file:write(utilities.json.tojson(data) .. "\n") file:close() end @@ -87,7 +92,7 @@ local function read_aux_file(aux_file) local file = io.open(aux_file, "r") if not file then - error(string.format('Failed to open "%s"', aux_file)) + error(string.format('Cannot read "%s"', aux_file)) return end for line in file:lines() do |