summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-22 03:01:01 +0000
committerNorbert Preining <norbert@preining.info>2019-09-22 03:01:01 +0000
commit77cef1d14e947b4899f54ca0311ca5ce9d253164 (patch)
treeb641044ef8a3372df30ea6e27d7c822bccc58cb0 /support
parent31d764f773a47d4d8cfa2cd2c0c3a4d5a7dff3e6 (diff)
CTAN sync 201909220301
Diffstat (limited to 'support')
-rwxr-xr-xsupport/ctanbib/ctanbib57
-rw-r--r--support/ctanbib/ctanbib-doc.pdfbin34395 -> 34681 bytes
-rw-r--r--support/ctanbib/ctanbib-doc.tex2
3 files changed, 48 insertions, 11 deletions
diff --git a/support/ctanbib/ctanbib b/support/ctanbib/ctanbib
index 10666696b5..21adfd4679 100755
--- a/support/ctanbib/ctanbib
+++ b/support/ctanbib/ctanbib
@@ -27,7 +27,7 @@ Available options:
]])
os.exit(1)
elseif arg[1]=="--version" or arg[1]=="-v" then
- print "ctanbib version v0.1c"
+ print "ctanbib version 0.1d"
os.exit(1)
elseif arg[1]=="--ctan" or arg[1]=="-c" then
table.remove(arg, 1)
@@ -35,7 +35,8 @@ elseif arg[1]=="--ctan" or arg[1]=="-c" then
end
local pkgname = arg[1]
-local url = "https://www.ctan.org/xml/pkg/" .. pkgname
+local url = "https://www.ctan.org/xml/2.0/pkg/" .. pkgname .. "?author-name=true"
+local authors_url = "https://ctan.org/xml/2.0/authors"
-- change that for different title scheme
local titleformat = "The %s package"
@@ -76,18 +77,52 @@ local bibtex_escape = function(a)
end)
end
+-- we need to use this method temporarily because of a bug in
+-- CTAN API
+local author_list
+local fetch_author_list = function()
+ if author_list then return author_list end
+ local authors = load_xml(authors_url)
+ author_list = {}
+ for _, author in ipairs(authors:query_selector("author")) do
+ -- save all authors under they ID
+ local id = author:get_attribute("id")
+ author_list[id] = author
+ end
+ return author_list
+end
+
+local process_author = function(author)
+ local current = {}
+ current[#current+1] = author:get_attribute("familyname")
+ current[#current+1] = author:get_attribute("givenname")
+ -- the author is an organization
+ if #current == 1 then
+ return "{" .. current[1] .. "}"
+ elseif #current > 1 then
+ return table.concat(current, ", ")
+ end
+ return nil -- no author
+end
+
+-- get the author name and surname
+local get_author = function(author)
+ local name = process_author(author)
+ if name then return name end
+ -- if the package XML doesn't contain author name,
+ -- we need to fetch the authors list from CTAN and find
+ -- it here
+ local author_list = fetch_author_list()
+ local id = author:get_attribute("id")
+ -- try to find the author id in list of authors
+ -- if everything fails, just return an empty group
+ return process_author(author_list[id]) or "{}"
+end
+
local get_authors = function(a)
local retrieved_authors = {}
for _, author in ipairs(a) do
- local current = {}
- current[#current+1] = author:get_attribute("familyname")
- current[#current+1] = author:get_attribute("givenname")
- -- the author is an organization
- if #current == 1 then
- table.insert(retrieved_authors, "{" .. current[1] .. "}")
- else
- table.insert(retrieved_authors, table.concat(current, ", "))
- end
+ table.insert(retrieved_authors, get_author(author))
end
return table.concat(retrieved_authors," and ")
end
diff --git a/support/ctanbib/ctanbib-doc.pdf b/support/ctanbib/ctanbib-doc.pdf
index f82b9bba95..b665ab7762 100644
--- a/support/ctanbib/ctanbib-doc.pdf
+++ b/support/ctanbib/ctanbib-doc.pdf
Binary files differ
diff --git a/support/ctanbib/ctanbib-doc.tex b/support/ctanbib/ctanbib-doc.tex
index 23a6525fd9..651d0058e6 100644
--- a/support/ctanbib/ctanbib-doc.tex
+++ b/support/ctanbib/ctanbib-doc.tex
@@ -99,6 +99,8 @@ it's eventual release on CTAN.
\section{Changelog}
\begin{changelog}
+ \change{2019-09-21}{Try to find the author in full CTAN author list if the author cannot be found in the package info}
+ \change{2019-09-16}{Use the CTAN API 2.0 to fetch the package info}
\change{2019-05-04}{Version 0.1c released}
\change{2019-05-04}{Use the \texttt{curl} command to download the package info}
\change{2019-05-04}{Added information about the need to have the \texttt{curl} command installed}