diff options
author | Karl Berry <karl@freefriends.org> | 2023-10-25 20:01:02 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-10-25 20:01:02 +0000 |
commit | bdfd3e10292fbde581e71feb6e4057a05c6786e6 (patch) | |
tree | 2bf3b2bb307fc47ae0ba72431f196cb441f70c67 | |
parent | eeeaa712403b4b33c98e379baaed783175a751c6 (diff) |
ctanbib (25oct23)
git-svn-id: svn://tug.org/texlive/trunk@68650 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Build/source/texk/texlive/linked_scripts/ctanbib/ctanbib | 62 | ||||
-rw-r--r-- | Master/texmf-dist/doc/man/man1/ctanbib.1 | 37 | ||||
-rw-r--r-- | Master/texmf-dist/doc/man/man1/ctanbib.man1.pdf | bin | 20210 -> 21412 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.pdf | bin | 37822 -> 39862 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.tex | 53 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/ctanbib/ctanbib | 62 |
6 files changed, 153 insertions, 61 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/ctanbib/ctanbib b/Build/source/texk/texlive/linked_scripts/ctanbib/ctanbib index a97819ab86b..dbb54d5bff7 100755 --- a/Build/source/texk/texlive/linked_scripts/ctanbib/ctanbib +++ b/Build/source/texk/texlive/linked_scripts/ctanbib/ctanbib @@ -21,21 +21,31 @@ local bibtype = "manual" local pkgurl = false local msg = [[ctanbib - convert ctan package information to bibtex format Usage: -ctanbib [options] name1 name2 ... +ctanbib [options] PKGNAME1 PKGNAME2 ... + +Look up the Catalogue entry for each PKGNAME on CTAN (at +https://ctan.org/xml/2.0/pkg/PKGNAME), and convert relevant information +to a BibTeX entry. + +By default, the url field in the output entry is the package's home +field value if that is specified in the Catalogue entry; if it isn't, +https://ctan.org/pkg/PKGNAME is used. + Available options: - -c,--ctan Use CTAN URL instead of the package homepage - -C,--ctanpath Use package's CTAN path as URL + -c,--ctan Always use CTAN /pkg/ url instead of the package homepage + -C,--ctanpath Use the package's CTAN path as url (e.g.: /support/ctanbib) -e,--entrytype (default manual) Change entry type -h,--help Print this message - -p,--pkgname Put the package name in a \ctanbibpkgname command + -p,--pkgname Wrap the package name in a \ctanbibpkgname command -v,--version Print version info - ]] + +ctanbib package page: https://ctan.org/pkg/ctanbib]] local args = lapp(msg) if args.help then print(msg) os.exit(0) elseif args.version then - print "ctanbib version 0.2c" + print "ctanbib version 0.2d" os.exit(0) elseif args.ctan then pkgurl = true @@ -58,20 +68,20 @@ if not pkgname then end local authors_url = "https://ctan.org/xml/2.0/authors" -local license_url = "http://www.ctan.org/xml/2.0/licenses" +local license_url = "https://www.ctan.org/xml/2.0/licenses" -- change that for different title scheme local titleformat = "The %s package" local bibtexformat = [[ @manual{$package, -title = {$title}, -subtitle = {$subtitle}, -author = {$author}, -url = {$url}, -urldate = {$urldate}, -date = {$date}, -version = {$version}, + title = {$title}, + subtitle = {$subtitle}, + author = {$author}, + url = {$url}, + urldate = {$urldate}, + date = {$date}, + version = {$version}, } ]] @@ -159,6 +169,10 @@ local get_authors = function(a) for _, author in ipairs(a) do table.insert(retrieved_authors, get_author(author)) end + -- CTAN returns authors in the random order. to fix that, we sort them. + -- I know that it is not a good solution for non-latin and accented names. + -- We could use Lua-UCA for the sorting, but I feel it is a bit of overkill. + table.sort(retrieved_authors) return table.concat(retrieved_authors," and ") end @@ -199,6 +213,23 @@ local get_version = function(record) end end + +local get_copyright_date = function(record) + -- we must get the latest <copyright>, because it contains the latest date + local copyright_tbl = record:query_selector("copyright") + local copyright = copyright_tbl[#copyright_tbl] + if copyright then + local year = copyright:get_attribute("year") + if year then + -- year can hold a range of year. we will chose the newest date + return year:match("(%d+)$") + end + + end + +end + + local ctan_url = function(record, pkgname) return "https://ctan.org/pkg/"..pkgname end @@ -244,6 +275,9 @@ for _, pkgname in ipairs(args) do e.url = ctan_path(record) end e.version, e.date = get_version(record) + if not e.date then + e.date = get_copyright_date(record) + end e.urldate = os.date("%Y-%m-%d") local result = compile(bibtexformat, e) diff --git a/Master/texmf-dist/doc/man/man1/ctanbib.1 b/Master/texmf-dist/doc/man/man1/ctanbib.1 index 246583a9d88..398919679bc 100644 --- a/Master/texmf-dist/doc/man/man1/ctanbib.1 +++ b/Master/texmf-dist/doc/man/man1/ctanbib.1 @@ -1,6 +1,6 @@ .\" Manpage for ctanbib. .\" Contact michal.h21@gmail.com to correct errors or typos. -.TH ctanbib 1 "18 Sep 2023" "0.2c" "ctanbib man page" +.TH ctanbib 1 "25 Oct 2023" "0.2d" "ctanbib man page" .SH NAME ctanbib \- retrieve bibliographic information for packages hosted on CTAN. @@ -9,17 +9,28 @@ ctanbib <options> [package name] .SH DESCRIPTION This command can retrieve bibliographic information for TeX packages hosted on CTAN in the BibTeX format. + + +Look up the Catalogue entry for each PKGNAME on CTAN (at +https://ctan.org/xml/2.0/pkg/PKGNAME), and convert relevant information +to a BibTeX entry. + +By default, the url field in the output entry is the package's home +field value if that is specified in the Catalogue entry; if it isn't, +https://ctan.org/pkg/PKGNAME is used. + .SH OPTIONS .IP -c,--ctan -use @ctan type instead of @manual. The difference between the two is that the -url field contains package CTAN path, instead of link to the package. +Always use CTAN /pkg/ url instead of the package homepage .IP -C,--CTAN -like --ctan option, but use original url instead of CTAN path. +Use the package's CTAN path as url (e.g.: /support/ctanbib) +.IP -e,--entrytype +(default manual) Change entry type .IP -h,--help print the help message. .IP -p,--pkgname -put the package name in a \ctanbibpkgname command. This command can be -redefined in the document for the desired formatting. +Wrap the package name in a \ctanbibpkgname command +This command can be redefined in the document for the desired formatting. .IP -v,--version print the version info. .SH EXAMPLES @@ -32,13 +43,13 @@ This invocation will print data in the BibLaTeX format to the standard output: .nf .ft CW @manual{latex, -title = {The Latex package}, -subtitle = {A TeX macro package that defines LaTeX}, -author = {Lamport, Leslie and The LaTeX Team}, -url = {http://www.latex-project.org/}, -urldate = {2018-08-23}, -date = {2018-04-01}, -version = {PL 5} + title = {The Latex package}, + subtitle = {A TeX macro package that defines LaTeX}, + author = {Lamport, Leslie and The LaTeX Team}, + url = {http://www.latex-project.org/}, + urldate = {2018-08-23}, + date = {2018-04-01}, + version = {PL 5} } .ft R .fi diff --git a/Master/texmf-dist/doc/man/man1/ctanbib.man1.pdf b/Master/texmf-dist/doc/man/man1/ctanbib.man1.pdf Binary files differindex 557a152c38d..2dd75d9cd68 100644 --- a/Master/texmf-dist/doc/man/man1/ctanbib.man1.pdf +++ b/Master/texmf-dist/doc/man/man1/ctanbib.man1.pdf diff --git a/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.pdf b/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.pdf Binary files differindex 9ea133ce088..6ce79e042cd 100644 --- a/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.pdf +++ b/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.pdf diff --git a/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.tex b/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.tex index 9f7ce00b8be..c13d62564be 100644 --- a/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.tex +++ b/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.tex @@ -1,4 +1,4 @@ -\documentclass{ltxdoc} +\documentclass[11pt]{ltxdoc} \newcommand\package[1]{\texttt{#1}} \usepackage{longtable} \usepackage{tabularx} @@ -18,6 +18,13 @@ \section{Introduction} This package provides script named \package{ctanbib} which can be used for retrieving of the bibliographic information for packages hosted on CTAN. +It looks up the Catalogue entry for each PKGNAME on CTAN (at +\url{https://ctan.org/xml/2.0/pkg/PKGNAME}), and convert relevant information +to a BibTeX entry. + +By default, the url field in the output entry is the package's home +field value if that is specified in the Catalogue entry; if it isn't, +\url{https://ctan.org/pkg/PKGNAME is used}. \section{Usage} @@ -37,11 +44,11 @@ The \texttt{curl} utility needs to be installed on the user's system in order to \section{Available options} \begin{description} - \item[-c,-\/-ctan] use the CTAN package entry as package URL instead of URL provided by the package. - \item[-C,-\/-ctanpath] use package's CTAN path as URL + \item[-c,-\/-ctan] always use CTAN /pkg/ url instead of the package homepage + \item[-C,-\/-ctanpath] use the package's CTAN path as url (e.g.: /support/ctanbib) \item[-e,-\/-entrypoint] explicitly set the Bib\TeX\ entry type. \item[-h,-\/-help] print the help message. - \item[-p,-\/-pkgname] Put the package name in a \verb|\ctanbibpkgname| command. + \item[-p,-\/-pkgname] wrap the package name in a \verb|\ctanbibpkgname| command. \item[-v,-\/-version] print the version info. \end{description} @@ -53,17 +60,17 @@ ctanbib latex \end{verbatim} -\noindent This invocation will print data in the Bib\LaTeX\ format to the standard output: +\noindent This invocation will print data in the Bib(La)\TeX\ format to the standard output: \begin{verbatim} @manual{latex, -title = {The latex package}, -subtitle = {A TeX macro package that defines LaTeX}, -author = {{The LaTeX Team} and Lamport, Leslie}, -url = {http://www.latex-project.org/}, -urldate = {2021-06-26}, -date = {}, -version = {2021-06-01}, + title = {The latex package}, + subtitle = {A TeX macro package that defines LaTeX}, + author = {{The LaTeX Team} and Lamport, Leslie}, + url = {http://www.latex-project.org/}, + urldate = {2021-06-26}, + date = {}, + version = {2021-06-01}, } \end{verbatim} @@ -79,10 +86,10 @@ instead of the original package URL. \begin{verbatim} @manual{latex, -title = {The latex package}, -... -url = {https://ctan.org/pkg/latex}, -... + title = {The latex package}, + ... + url = {https://ctan.org/pkg/latex}, + ... } \end{verbatim} @@ -96,9 +103,9 @@ ctanbib -C biblatex \begin{verbatim} @manual{biblatex, -... -url = {/macros/latex/contrib/biblatex}, -... + ... + url = {/macros/latex/contrib/biblatex}, + ... } \end{verbatim} @@ -114,7 +121,7 @@ ctanbib -e ctan latex \begin{verbatim} @ctan{latex, -... + ... } \end{verbatim} @@ -154,6 +161,12 @@ and leaving package names uncapitalized. \section{Changelog} \begin{changelog} + \change{2023-10-25}{Version 0.2d released} + \change{2023-10-20}{Sort authors alphabetically} + \change{2023-10-19}{Updated the \verb|--help| message} + \change{2023-10-16}{Use larger font in the documentation} + \change{2023-10-16}{Indent the Bib\TeX\ entry by two spaces} + \change{2023-10-08}{Get date from the copyright field if we cannot retrieve it from version} \change{2023-09-18}{Version 0.2c released} \change{2023-09-14}{Renamed the \verb|--tugboat| option to \verb|--pkgname|} \change{2023-09-12}{Don't capitalize package names} diff --git a/Master/texmf-dist/scripts/ctanbib/ctanbib b/Master/texmf-dist/scripts/ctanbib/ctanbib index a97819ab86b..dbb54d5bff7 100755 --- a/Master/texmf-dist/scripts/ctanbib/ctanbib +++ b/Master/texmf-dist/scripts/ctanbib/ctanbib @@ -21,21 +21,31 @@ local bibtype = "manual" local pkgurl = false local msg = [[ctanbib - convert ctan package information to bibtex format Usage: -ctanbib [options] name1 name2 ... +ctanbib [options] PKGNAME1 PKGNAME2 ... + +Look up the Catalogue entry for each PKGNAME on CTAN (at +https://ctan.org/xml/2.0/pkg/PKGNAME), and convert relevant information +to a BibTeX entry. + +By default, the url field in the output entry is the package's home +field value if that is specified in the Catalogue entry; if it isn't, +https://ctan.org/pkg/PKGNAME is used. + Available options: - -c,--ctan Use CTAN URL instead of the package homepage - -C,--ctanpath Use package's CTAN path as URL + -c,--ctan Always use CTAN /pkg/ url instead of the package homepage + -C,--ctanpath Use the package's CTAN path as url (e.g.: /support/ctanbib) -e,--entrytype (default manual) Change entry type -h,--help Print this message - -p,--pkgname Put the package name in a \ctanbibpkgname command + -p,--pkgname Wrap the package name in a \ctanbibpkgname command -v,--version Print version info - ]] + +ctanbib package page: https://ctan.org/pkg/ctanbib]] local args = lapp(msg) if args.help then print(msg) os.exit(0) elseif args.version then - print "ctanbib version 0.2c" + print "ctanbib version 0.2d" os.exit(0) elseif args.ctan then pkgurl = true @@ -58,20 +68,20 @@ if not pkgname then end local authors_url = "https://ctan.org/xml/2.0/authors" -local license_url = "http://www.ctan.org/xml/2.0/licenses" +local license_url = "https://www.ctan.org/xml/2.0/licenses" -- change that for different title scheme local titleformat = "The %s package" local bibtexformat = [[ @manual{$package, -title = {$title}, -subtitle = {$subtitle}, -author = {$author}, -url = {$url}, -urldate = {$urldate}, -date = {$date}, -version = {$version}, + title = {$title}, + subtitle = {$subtitle}, + author = {$author}, + url = {$url}, + urldate = {$urldate}, + date = {$date}, + version = {$version}, } ]] @@ -159,6 +169,10 @@ local get_authors = function(a) for _, author in ipairs(a) do table.insert(retrieved_authors, get_author(author)) end + -- CTAN returns authors in the random order. to fix that, we sort them. + -- I know that it is not a good solution for non-latin and accented names. + -- We could use Lua-UCA for the sorting, but I feel it is a bit of overkill. + table.sort(retrieved_authors) return table.concat(retrieved_authors," and ") end @@ -199,6 +213,23 @@ local get_version = function(record) end end + +local get_copyright_date = function(record) + -- we must get the latest <copyright>, because it contains the latest date + local copyright_tbl = record:query_selector("copyright") + local copyright = copyright_tbl[#copyright_tbl] + if copyright then + local year = copyright:get_attribute("year") + if year then + -- year can hold a range of year. we will chose the newest date + return year:match("(%d+)$") + end + + end + +end + + local ctan_url = function(record, pkgname) return "https://ctan.org/pkg/"..pkgname end @@ -244,6 +275,9 @@ for _, pkgname in ipairs(args) do e.url = ctan_path(record) end e.version, e.date = get_version(record) + if not e.date then + e.date = get_copyright_date(record) + end e.urldate = os.date("%Y-%m-%d") local result = compile(bibtexformat, e) |