texlive[59718] trunk: ctanbib (26jun21)

commits+karl at tug.org commits+karl at tug.org
Sat Jun 26 22:36:50 CEST 2021


Revision: 59718
          http://tug.org/svn/texlive?view=revision&revision=59718
Author:   karl
Date:     2021-06-26 22:36:50 +0200 (Sat, 26 Jun 2021)
Log Message:
-----------
ctanbib (26jun21)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/ctanbib/ctanbib
    trunk/Build/source/texk/texlive/linked_scripts/ptex-fontmaps/kanji-config-updmap.pl
    trunk/Build/source/texk/texlive/linked_scripts/ptex-fontmaps/kanji-fontmap-creator.pl
    trunk/Master/texmf-dist/doc/man/man1/ctanbib.man1.pdf
    trunk/Master/texmf-dist/doc/support/ctanbib/README.md
    trunk/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.pdf
    trunk/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.tex
    trunk/Master/texmf-dist/scripts/ctanbib/ctanbib

Modified: trunk/Build/source/texk/texlive/linked_scripts/ctanbib/ctanbib
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/ctanbib/ctanbib	2021-06-26 16:04:37 UTC (rev 59717)
+++ trunk/Build/source/texk/texlive/linked_scripts/ctanbib/ctanbib	2021-06-26 20:36:50 UTC (rev 59718)
@@ -1,7 +1,7 @@
 #!/usr/bin/env texlua
 kpse.set_program_name("luatex")
 -- ctanbib -- export ctan entries to bib format
--- Copyright: Michal Hoftich <michal.h21 at gmail.com> (2014-2018)
+-- Copyright: Michal Hoftich <michal.h21 at gmail.com> (2014-2021)
 --
 -- This work may be distributed and/or modified under the
 -- conditions of the LaTeX Project Public License, either version 1.3
@@ -15,40 +15,48 @@
 -- 
 -- The Current Maintainer of this work is Michal Hoftich
 
+local lapp = require "lapp-mk4"
+
 local bibtype = "manual"
 local pkgurl = false
-if #arg < 1 or arg[1]=="--help" or arg[1]=="-h" then
-  print([[ctanbib - convert ctan package information to bibtex format
+local msg = [[ctanbib - convert ctan package information to bibtex format
 Usage:
-ctanbib [options] <package name>
+ctanbib [options] name1 name2 ...
 Available options:
-  -c,--ctan       Use @ctan type instead of @manual and long url
-  -C,--CTAN       Use @ctan type and short ... /pkg/url
+  -c,--ctan       Use CTAN URL instead of the package homepage 
+  -e,--entrytype  (default manual)  Change entry type
   -h,--help       Print this message
   -v,--version    Print version info
-  ]])
+  ]]
+local args = lapp(msg)
+if args.help then
+  print(msg)
   os.exit(0)
-elseif arg[1]=="--version" or arg[1]=="-v" then
-  print "ctanbib version 0.1e"
+elseif args.version then
+  print "ctanbib version 0.2"
   os.exit(0)
-elseif arg[1]=="--ctan" or arg[1]=="-c" then
-  table.remove(arg, 1)
-  bibtype = "ctan"
-elseif arg[1]=="--CTAN" or arg[1]=="-C" then
-  table.remove(arg, 1)
-  bibtype = "ctan"
+elseif args.ctan then
   pkgurl = true
 end
 
-local pkgname = arg[1]
+-- manual is set by default in --entrytype, we don't want it to override the --ctan option
+if args.entrytype~="manual" then
+  bibtype = args.entrytype
+end
 
+
+
+
+local pkgname = args[1]
+
 if not pkgname then 
   print "[ctanbib] Error: missing package name"
+  print(msg)
   os.exit(1)
 end
 
-local url = "https://ctan.org/xml/2.0/pkg/" .. pkgname .. "?author-name=true"
 local authors_url = "https://ctan.org/xml/2.0/authors"
+local license_url = "http://www.ctan.org/xml/2.0/licenses"
 
 -- change that for different title scheme
 local titleformat = "The %s package"
@@ -61,7 +69,7 @@
 url = {$url},
 urldate = {$urldate}, 
 date = {$date},
-version = {$version}
+version = {$version},
 }
 ]]
 
@@ -77,7 +85,7 @@
   if string.len(info) == 0 then
     return false
   end
-  return dom.parse(info)
+  return dom.parse(info ), info
 end
 
 local bibtex_escape = function(a)
@@ -149,8 +157,13 @@
   return string.format(titleformat, bibtex_escape(title))
 end
 
+local function verify_record(record)
+  -- verify that we found a package
+  if not record then return false end
+  return #record:query_selector("name") > 0
+end
 
-local get_url = function(record)
+local get_url = function(record,pkgname)
   local home = record:query_selector("home")[1]
   if home then return home:get_attribute("href") end
   return "https://ctan.org/pkg/"..pkgname
@@ -169,12 +182,8 @@
   end
 end
 
-local ctan_url = 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
+local ctan_url = function(record, pkgname)
+  return "https://ctan.org/pkg/"..pkgname
 end
 
 
@@ -184,32 +193,35 @@
   end)
 end
 
-local record = load_xml(url)
+for _, pkgname in ipairs(args) do
+  local url = "https://ctan.org/xml/2.0/pkg/" .. pkgname .. "?author-name=true"
+  local record, info = load_xml(url)
 
-if not record then
-  print("Cannot find entry for package "..pkgname)
-  os.exit(1)
-end
+  if not verify_record(record) then
+    print("% Cannot find entry for package "..pkgname)
+    break
+  end
 
--- root element is also saved, so we use this trick 
--- local record = entry.entry
+  -- root element is also saved, so we use this trick 
+  -- local record = entry.entry
 
-local e = {}
+  local e = {}
 
-e.author = get_authors(record:query_selector("authorref"))
-e.package = pkgname
-e.title = get_title(record)
-e.subtitle = get_caption(record)
-e.url = get_url(record)
--- use the CTAN path as url for the CTAN type
-if (bibtype == "ctan") and not pkgurl then
-  e.url = ctan_url(record)
-end
-e.version, e.date = get_version(record)
-e.urldate = os.date("%Y-%m-%d")
+  e.author = get_authors(record:query_selector("authorref"))
+  e.package = pkgname
+  e.title = get_title(record)
+  e.subtitle = get_caption(record)
+  e.url = get_url(record, pkgname)
+  -- use the CTAN path as url for the CTAN type
+  if pkgurl then
+    e.url = ctan_url(record, pkgname)
+  end
+  e.version, e.date = get_version(record)
+  e.urldate = os.date("%Y-%m-%d")
 
-local result = compile(bibtexformat, e)
--- update the bibliography type
-result = result:gsub("^@manual", "@" .. bibtype)
+  local result = compile(bibtexformat, e)
+  -- update the bibliography type
+  result = result:gsub("^@manual", "@" .. bibtype)
 
-print(result)
+  print(result)
+end

Modified: trunk/Build/source/texk/texlive/linked_scripts/ptex-fontmaps/kanji-config-updmap.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/ptex-fontmaps/kanji-config-updmap.pl	2021-06-26 16:04:37 UTC (rev 59717)
+++ trunk/Build/source/texk/texlive/linked_scripts/ptex-fontmaps/kanji-config-updmap.pl	2021-06-26 20:36:50 UTC (rev 59718)
@@ -1,12 +1,12 @@
 #!/usr/bin/env perl
 # kanji-config-updmap: setup Japanese font embedding
-# Version 20201227.0
+# Version 20210625.0
 #
 # formerly known as updmap-setup-kanji
 #
 # Copyright 2004-2006 by KOBAYASHI R. Taizo for the shell version (updmap-otf)
-# Copyright 2011-2020 by PREINING Norbert
-# Copyright 2016-2020 by Japanese TeX Development Community
+# Copyright 2011-2021 by PREINING Norbert
+# Copyright 2016-2021 by Japanese TeX Development Community
 #
 # This file is licensed under GPL version 3 or any later version.
 # For copyright statements see end of file.
@@ -22,7 +22,7 @@
 use strict;
 
 my $prg = "kanji-config-updmap";
-my $version = '20201227.0';
+my $version = '20210625.0';
 
 my $updmap_real = "updmap";
 my $updmap = $updmap_real;
@@ -149,10 +149,10 @@
     $macos_ver_major =~ s/^(\d+)\.(\d+).*/$1/;
     my $macos_ver_minor = $macos_ver;
     $macos_ver_minor =~ s/^(\d+)\.(\d+).*/$2/;
-    if ($macos_ver_major==10) {
-      if ($macos_ver_minor>=11) {
-        return 1;
-      }
+    if ($macos_ver_major==10 && $macos_ver_minor>=11) {
+      return 1; # macOS 10.11 (El Capitan) or later
+    } elsif ($macos_ver_major>=11) {
+      return 1; # macOS 11.0 (Big Sur) or later
     }
   }
   return 0;

Modified: trunk/Build/source/texk/texlive/linked_scripts/ptex-fontmaps/kanji-fontmap-creator.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/ptex-fontmaps/kanji-fontmap-creator.pl	2021-06-26 16:04:37 UTC (rev 59717)
+++ trunk/Build/source/texk/texlive/linked_scripts/ptex-fontmaps/kanji-fontmap-creator.pl	2021-06-26 20:36:50 UTC (rev 59718)
@@ -2,7 +2,7 @@
 #
 # kanji-fontmap-creator
 # (c) 2012-2014 Norbert Preining
-# Version: 20201227.0
+# Version: 20210625.0
 # Licenced under the GPLv2 or any higher version
 #
 # gui to create map files for (kanji-config-)updmap
@@ -41,7 +41,7 @@
 my $opt_version = 0;
 
 my $prg = "kanji-fontmap-creator";
-my $version = "20201227.0";
+my $version = "20210625.0";
 
 #
 # global vars configuring operation

Modified: trunk/Master/texmf-dist/doc/man/man1/ctanbib.man1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/ctanbib/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/support/ctanbib/README.md	2021-06-26 16:04:37 UTC (rev 59717)
+++ trunk/Master/texmf-dist/doc/support/ctanbib/README.md	2021-06-26 20:36:50 UTC (rev 59718)
@@ -10,7 +10,7 @@
 More details can be found on [TeX.sx](https://tex.stackexchange.com/a/200856/2891)
 
 
-Copyright: 2019 Michal Hoftich
+Copyright: 2021 Michal Hoftich
 
 This work may be distributed and/or modified under the
 conditions of the LaTeX Project Public License, either version 1.3

Modified: trunk/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.tex	2021-06-26 16:04:37 UTC (rev 59717)
+++ trunk/Master/texmf-dist/doc/support/ctanbib/ctanbib-doc.tex	2021-06-26 20:36:50 UTC (rev 59718)
@@ -25,8 +25,12 @@
 It can be used in the following way:
 
 
-\noindent\package{ctanbib [options]  $\langle$packagename$\rangle$ > filename.bib}
+\medskip
 
+\noindent\package{ctanbib [options]  $\langle$packagename1$\rangle$ \ldots\ $\langle$packagenameX$\rangle$ > filename.bib}
+
+\medskip
+
 The \texttt{curl} utility needs to be installed on the user's system in order to support the package info download.
 
 
@@ -33,10 +37,8 @@
 \section{Available options}
 
 \begin{description}
-  \item[-c,-\/-ctan] use the \texttt{@ctan} type instead of \texttt{@manual}.
-    The difference between the two is that the url field contains packages CTAN
-    path, instead of a link to the package.
-  \item[-C,-\/-CTAN] like \verb|--ctan| option, but use original url instead of CTAN path.
+  \item[-c,-\/-ctan] use the CTAN package entry as package URL instead of URL provided by the package.
+  \item[-e,-\/-entrypoint] explicitly set the Bib\TeX\ entry type.
   \item[-h,-\/-help] print the help message.
   \item[-v,-\/-version] print the version info.
 \end{description}
@@ -55,35 +57,48 @@
 @manual{latex,
 title = {The Latex package},
 subtitle = {A TeX macro package that defines LaTeX},
-author = {Lamport, Leslie and The LaTeX Team},
+author = {{The LaTeX Team} and Lamport, Leslie},
 url = {http://www.latex-project.org/},
-urldate = {2018-08-23}, 
-date = {2018-04-01},
-version = {PL 5}
+urldate = {2021-06-26},
+date = {},
+version = {2021-06-01},
 }
 \end{verbatim}
 
-The \texttt{--ctan} option:
+\noindent The \texttt{--ctan} option:
 
 \begin{verbatim}
-ctanbib -c hyperref
+ctanbib -c latex
 \end{verbatim}
 
-\noindent This produces a bib record with the \texttt{@ctan} type:
+\noindent This produces a bib record that uses the CTAN package entry for the URL, 
+instead of the original package URL.
 
+
 \begin{verbatim}
- at ctan{hyperref,
-title = {The Hyperref package},
-subtitle = {Extensive support for hypertext in LaTeX},
-author = {Rahtz, Sebastian and Oberdiek, Heiko},
-url = {/macros/latex/contrib/hyperref},
-urldate = {2018-08-27}, 
-date = {},
-version = {6.86b}
+ at manual{latex,
+title = {The Latex package},
+...
+url = {https://ctan.org/pkg/latex},
+...
 }
 \end{verbatim}
 
+\noindent The \texttt{--entrytype} option:
 
+\begin{verbatim}
+ctanbib -e ctan latex
+\end{verbatim}
+
+\noindent It selects different entry type for the record:
+
+\begin{verbatim}
+ at ctan{latex,
+...
+}
+\end{verbatim}
+
+
 \section{License}
 
 Permission is granted to copy, distribute and/or modify this software
@@ -100,6 +115,13 @@
 \section{Changelog}
 
 \begin{changelog}
+  \change{2021-06-26}{Version 0.2 released}
+  \change{2021-06-26}{Removed the \verb|--CTAN| option, entry type can be set using \verb|--entrytype| and CTAN URL is requested using \verb|--ctan|}
+  \change{2021-06-26}{Added \verb|--entrytype| option for explicit specification of the Bib\TeX\ entry type}
+  \change{2021-06-26}{Fixed package name verification}
+  \change{2021-06-26}{Added support for multiple package names}
+  \change{2021-06-26}{Print \verb|https://www.ctan.org/pkg/<pkgname>| with the \texttt{-c} option}
+  \change{2021-06-20}{Version 0.1e released}
   \change{2021-06-20}{Added \verb|--CTAN| option, thanks to Herbert Voss}
   \change{2019-12-23}{Don't return non-zero exit codes for non-error runs}
   \change{2019-12-23}{Test for the packagename with the \texttt{-c} option}

Modified: trunk/Master/texmf-dist/scripts/ctanbib/ctanbib
===================================================================
--- trunk/Master/texmf-dist/scripts/ctanbib/ctanbib	2021-06-26 16:04:37 UTC (rev 59717)
+++ trunk/Master/texmf-dist/scripts/ctanbib/ctanbib	2021-06-26 20:36:50 UTC (rev 59718)
@@ -1,7 +1,7 @@
 #!/usr/bin/env texlua
 kpse.set_program_name("luatex")
 -- ctanbib -- export ctan entries to bib format
--- Copyright: Michal Hoftich <michal.h21 at gmail.com> (2014-2018)
+-- Copyright: Michal Hoftich <michal.h21 at gmail.com> (2014-2021)
 --
 -- This work may be distributed and/or modified under the
 -- conditions of the LaTeX Project Public License, either version 1.3
@@ -15,40 +15,48 @@
 -- 
 -- The Current Maintainer of this work is Michal Hoftich
 
+local lapp = require "lapp-mk4"
+
 local bibtype = "manual"
 local pkgurl = false
-if #arg < 1 or arg[1]=="--help" or arg[1]=="-h" then
-  print([[ctanbib - convert ctan package information to bibtex format
+local msg = [[ctanbib - convert ctan package information to bibtex format
 Usage:
-ctanbib [options] <package name>
+ctanbib [options] name1 name2 ...
 Available options:
-  -c,--ctan       Use @ctan type instead of @manual and long url
-  -C,--CTAN       Use @ctan type and short ... /pkg/url
+  -c,--ctan       Use CTAN URL instead of the package homepage 
+  -e,--entrytype  (default manual)  Change entry type
   -h,--help       Print this message
   -v,--version    Print version info
-  ]])
+  ]]
+local args = lapp(msg)
+if args.help then
+  print(msg)
   os.exit(0)
-elseif arg[1]=="--version" or arg[1]=="-v" then
-  print "ctanbib version 0.1e"
+elseif args.version then
+  print "ctanbib version 0.2"
   os.exit(0)
-elseif arg[1]=="--ctan" or arg[1]=="-c" then
-  table.remove(arg, 1)
-  bibtype = "ctan"
-elseif arg[1]=="--CTAN" or arg[1]=="-C" then
-  table.remove(arg, 1)
-  bibtype = "ctan"
+elseif args.ctan then
   pkgurl = true
 end
 
-local pkgname = arg[1]
+-- manual is set by default in --entrytype, we don't want it to override the --ctan option
+if args.entrytype~="manual" then
+  bibtype = args.entrytype
+end
 
+
+
+
+local pkgname = args[1]
+
 if not pkgname then 
   print "[ctanbib] Error: missing package name"
+  print(msg)
   os.exit(1)
 end
 
-local url = "https://ctan.org/xml/2.0/pkg/" .. pkgname .. "?author-name=true"
 local authors_url = "https://ctan.org/xml/2.0/authors"
+local license_url = "http://www.ctan.org/xml/2.0/licenses"
 
 -- change that for different title scheme
 local titleformat = "The %s package"
@@ -61,7 +69,7 @@
 url = {$url},
 urldate = {$urldate}, 
 date = {$date},
-version = {$version}
+version = {$version},
 }
 ]]
 
@@ -77,7 +85,7 @@
   if string.len(info) == 0 then
     return false
   end
-  return dom.parse(info)
+  return dom.parse(info ), info
 end
 
 local bibtex_escape = function(a)
@@ -149,8 +157,13 @@
   return string.format(titleformat, bibtex_escape(title))
 end
 
+local function verify_record(record)
+  -- verify that we found a package
+  if not record then return false end
+  return #record:query_selector("name") > 0
+end
 
-local get_url = function(record)
+local get_url = function(record,pkgname)
   local home = record:query_selector("home")[1]
   if home then return home:get_attribute("href") end
   return "https://ctan.org/pkg/"..pkgname
@@ -169,12 +182,8 @@
   end
 end
 
-local ctan_url = 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
+local ctan_url = function(record, pkgname)
+  return "https://ctan.org/pkg/"..pkgname
 end
 
 
@@ -184,32 +193,35 @@
   end)
 end
 
-local record = load_xml(url)
+for _, pkgname in ipairs(args) do
+  local url = "https://ctan.org/xml/2.0/pkg/" .. pkgname .. "?author-name=true"
+  local record, info = load_xml(url)
 
-if not record then
-  print("Cannot find entry for package "..pkgname)
-  os.exit(1)
-end
+  if not verify_record(record) then
+    print("% Cannot find entry for package "..pkgname)
+    break
+  end
 
--- root element is also saved, so we use this trick 
--- local record = entry.entry
+  -- root element is also saved, so we use this trick 
+  -- local record = entry.entry
 
-local e = {}
+  local e = {}
 
-e.author = get_authors(record:query_selector("authorref"))
-e.package = pkgname
-e.title = get_title(record)
-e.subtitle = get_caption(record)
-e.url = get_url(record)
--- use the CTAN path as url for the CTAN type
-if (bibtype == "ctan") and not pkgurl then
-  e.url = ctan_url(record)
-end
-e.version, e.date = get_version(record)
-e.urldate = os.date("%Y-%m-%d")
+  e.author = get_authors(record:query_selector("authorref"))
+  e.package = pkgname
+  e.title = get_title(record)
+  e.subtitle = get_caption(record)
+  e.url = get_url(record, pkgname)
+  -- use the CTAN path as url for the CTAN type
+  if pkgurl then
+    e.url = ctan_url(record, pkgname)
+  end
+  e.version, e.date = get_version(record)
+  e.urldate = os.date("%Y-%m-%d")
 
-local result = compile(bibtexformat, e)
--- update the bibliography type
-result = result:gsub("^@manual", "@" .. bibtype)
+  local result = compile(bibtexformat, e)
+  -- update the bibliography type
+  result = result:gsub("^@manual", "@" .. bibtype)
 
-print(result)
+  print(result)
+end



More information about the tex-live-commits mailing list.