From f18baaf545c73262376befaccac7fda005b26975 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 30 Jun 2021 21:19:31 +0000 Subject: ctanbib (30jun21) git-svn-id: svn://tug.org/texlive/trunk@59782 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/ctanbib/ctanbib | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Master/texmf-dist/scripts') diff --git a/Master/texmf-dist/scripts/ctanbib/ctanbib b/Master/texmf-dist/scripts/ctanbib/ctanbib index f54e1691ca2..70b31badbac 100755 --- a/Master/texmf-dist/scripts/ctanbib/ctanbib +++ b/Master/texmf-dist/scripts/ctanbib/ctanbib @@ -24,6 +24,7 @@ Usage: ctanbib [options] name1 name2 ... Available options: -c,--ctan Use CTAN URL instead of the package homepage + -C,--ctanpath Use package's CTAN path as URL -e,--entrytype (default manual) Change entry type -h,--help Print this message -v,--version Print version info @@ -33,7 +34,7 @@ if args.help then print(msg) os.exit(0) elseif args.version then - print "ctanbib version 0.2" + print "ctanbib version 0.2a" os.exit(0) elseif args.ctan then pkgurl = true @@ -186,6 +187,14 @@ local ctan_url = function(record, pkgname) return "https://ctan.org/pkg/"..pkgname end +local ctan_path = function(record) + local ctan = record:query_selector("ctan")[1] + -- some package don't contain the CTAN path + if not ctan then return get_url(record) end + local path = ctan:get_attribute("path") + return path +end + local compile = function(template, records) return template:gsub("$([a-z]+)", function(a) @@ -215,6 +224,8 @@ for _, pkgname in ipairs(args) do -- use the CTAN path as url for the CTAN type if pkgurl then e.url = ctan_url(record, pkgname) + elseif args.ctanpath then + e.url = ctan_path(record) end e.version, e.date = get_version(record) e.urldate = os.date("%Y-%m-%d") -- cgit v1.2.3