texlive[68869] trunk: bibtexperllibs: ltx2unitxt as user-level script

commits+karl at tug.org commits+karl at tug.org
Thu Nov 16 19:39:13 CET 2023


Revision: 68869
          https://tug.org/svn/texlive?view=revision&revision=68869
Author:   karl
Date:     2023-11-16 19:39:12 +0100 (Thu, 16 Nov 2023)
Log Message:
-----------
bibtexperllibs: ltx2unitxt as user-level script

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/Makefile.am
    trunk/Build/source/texk/texlive/linked_scripts/Makefile.in
    trunk/Build/source/texk/texlive/linked_scripts/scripts.lst
    trunk/Master/tlpkg/libexec/ctan2tds
    trunk/Master/tlpkg/tlpsrc/bibtexperllibs.tlpsrc

Added Paths:
-----------
    trunk/Build/source/texk/texlive/linked_scripts/bibtexperllibs/
    trunk/Build/source/texk/texlive/linked_scripts/bibtexperllibs/ltx2unitxt
    trunk/Master/bin/aarch64-linux/ltx2unitxt
    trunk/Master/bin/amd64-freebsd/ltx2unitxt
    trunk/Master/bin/amd64-netbsd/ltx2unitxt
    trunk/Master/bin/armhf-linux/ltx2unitxt
    trunk/Master/bin/i386-freebsd/ltx2unitxt
    trunk/Master/bin/i386-linux/ltx2unitxt
    trunk/Master/bin/i386-netbsd/ltx2unitxt
    trunk/Master/bin/i386-solaris/ltx2unitxt
    trunk/Master/bin/universal-darwin/ltx2unitxt
    trunk/Master/bin/windows/ltx2unitxt.exe
    trunk/Master/bin/x86_64-cygwin/ltx2unitxt
    trunk/Master/bin/x86_64-darwinlegacy/ltx2unitxt
    trunk/Master/bin/x86_64-linux/ltx2unitxt
    trunk/Master/bin/x86_64-linuxmusl/ltx2unitxt
    trunk/Master/bin/x86_64-solaris/ltx2unitxt
    trunk/Master/texmf-dist/scripts/bibtexperllibs/ltx2unitxt

Removed Paths:
-------------
    trunk/Master/texmf-dist/source/support/bibtexperllibs/LaTeX-ToUnicode/script/ltx2unitxt

Modified: trunk/Build/source/texk/texlive/linked_scripts/Makefile.am
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/Makefile.am	2023-11-16 00:43:31 UTC (rev 68868)
+++ trunk/Build/source/texk/texlive/linked_scripts/Makefile.am	2023-11-16 18:39:12 UTC (rev 68869)
@@ -99,6 +99,7 @@
 	typeoutfileinfo/typeoutfileinfo.sh \
 	wordcount/wordcount.sh
 
+# 

 texmf_other_scripts = \
 	a2ping/a2ping.pl \
 	accfonts/mkt1font \
@@ -111,6 +112,7 @@
 	bib2gls/bib2gls.sh \
 	bib2gls/convertgls2bib.sh \
 	bibcop/bibcop.pl \
+	bibtexperllibs/ltx2unitxt \
 	bundledoc/arlatex \
 	bundledoc/bundledoc \
 	cachepic/cachepic.tlu \

Modified: trunk/Build/source/texk/texlive/linked_scripts/Makefile.in
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/Makefile.in	2023-11-16 00:43:31 UTC (rev 68868)
+++ trunk/Build/source/texk/texlive/linked_scripts/Makefile.in	2023-11-16 18:39:12 UTC (rev 68869)
@@ -315,6 +315,8 @@
 	typeoutfileinfo/typeoutfileinfo.sh \
 	wordcount/wordcount.sh
 
+
+# 

 texmf_other_scripts = \
 	a2ping/a2ping.pl \
 	accfonts/mkt1font \
@@ -327,6 +329,7 @@
 	bib2gls/bib2gls.sh \
 	bib2gls/convertgls2bib.sh \
 	bibcop/bibcop.pl \
+	bibtexperllibs/ltx2unitxt \
 	bundledoc/arlatex \
 	bundledoc/bundledoc \
 	cachepic/cachepic.tlu \

Added: trunk/Build/source/texk/texlive/linked_scripts/bibtexperllibs/ltx2unitxt
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/bibtexperllibs/ltx2unitxt	                        (rev 0)
+++ trunk/Build/source/texk/texlive/linked_scripts/bibtexperllibs/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1,169 @@
+#!/usr/bin/env perl
+# Use the LaTeX::ToUnicode module (also in the bibtexperllibs
+# repository/package, like this script) to convert LaTeX to Unicode.
+# 
+# We work on fragments of text, not whole documents, the goal being to
+# replace LaTeX commands and syntax with obvious plain text equivalents,
+# or remove them.
+
+use strict;
+use warnings;
+
+use Cwd;
+use File::Basename;
+use File::Spec;
+
+BEGIN {
+    # find files relative to our installed location within TeX Live
+    chomp(my $TLMaster = `kpsewhich -var-value=SELFAUTOPARENT`); # TL root
+    if (length($TLMaster)) {
+        unshift @INC, "$TLMaster/texmf-dist/scripts/bibtexperllibs";
+    }
+    # find development bibtexperllibs in sibling checkout to this script,
+    # even if $0 is a symlink. Irrelevant when using from an installation.
+    my $real0 = Cwd::abs_path($0);
+    my $scriptdir = File::Basename::dirname($real0);
+    my $dev_btxperllibs = Cwd::abs_path("$scriptdir/../..");
+
+    # we need the lib/ subdirectories inside ...
+    unshift (@INC, glob ("$dev_btxperllibs/*/lib")) if -d $dev_btxperllibs;
+
+}
+
+use LaTeX::ToUnicode;
+
+our %opts;
+local *OUT; # output filehandle
+
+exit(main());
+
+sub main {
+    init();
+
+    # by paragraph?
+    while (<>) {
+        print OUT (convert($_));
+    }
+
+    return 0;
+}
+
+sub convert {
+    my ($in) = @_;
+
+    my @args = (); # what we'll pass to the convert() fn.
+    #
+    if (defined(&{"LaTeX_ToUnicode_convert_hook"})) {
+      push (@args, "hook" => \&LaTeX_ToUnicode_convert_hook); }
+    if ($opts{e}) { push (@args, "entities" => 1); }
+    if ($opts{g}) { push (@args, "german" => 1); }
+    if ($opts{h}) { push (@args, "html" => 1); }
+
+    LaTeX::ToUnicode::debuglevel($opts{v});
+    my $out = LaTeX::ToUnicode::convert($in, @args);
+
+    #warn "out=$out";
+    return $out;
+}
+
+

+# Command line options, etc.
+# 
+sub init {
+    my $USAGE = <<END;
+Usage: $0 [-c CONFIG] [-o OUTPUT] [--html] [...] [INFILE]...
+
+Convert the LaTeX source in INFILE (or standard input) to plain text
+using Unicode code points for accents and other special characters; or,
+optionally, output HTML with simple translations for font changes and url
+commands.
+
+Common accent sequences, special characters, and simple markup commands
+are translated, but there is no attempt at completeness. Math, tables,
+figures, sectioning, etc., are not handled in any way, and mostly left
+in their TeX form in the output. The translations assume standard LaTeX
+meanings for characters and control sequences; macros in the input are
+not considered.
+
+The input can be a fragment of text, not a full document, as the purpose
+of this script was to handle bibliography entries and abstracts (for the
+ltx2crossrefxml script that is part of the crossrefware package).
+Patches to extend this script are welcome. It uses the LaTeX::ToUnicode
+Perl library for the conversion; see its documentation for details.
+
+Conversion is currently done line by line, so TeX constructs that cross
+multiple lines are not handled properly. If it turns out to be useful,
+conversion could be done by paragraph instead.
+
+The config file is read as a Perl source file. It can define a function
+`LaTeX_ToUnicode_convert_hook()' which will be called early; the value
+it returns (which must be a string) will then be subject to the standard
+conversion.
+
+For an example of using this script and associated code, see the TUGboat
+processing at
+https://github.com/TeXUsersGroup/tugboat/tree/trunk/capsules/crossref.
+
+Options:
+  -c, --config=FILE  read (Perl) config FILE for a hook, as explained above
+  -e, --entities     output entities &#xNNNN; instead of literal characters
+  -g, --german       handle some features of the german package
+  -h, --html         output simplistic HTML instead of plain text
+  -o, --output=FILE  output to FILE instead of stdout
+  -v, --verbose      be verbose
+  -V, --version      output version information and exit
+  -?, --help         display this help and exit
+
+Options can be abbreviated unambiguously, and start with either - or --.
+
+Dev sources, bug tracker: https://github.com/borisveytsman/bibtexperllibs
+Releases: https://ctan.org/pkg/bibtexperllibs
+END
+
+ my $VERSION = <<END;
+ltx2unitxt (bibtexperllibs) 0.51
+Copyright 2023 Karl Berry.
+This is free software: you can redistribute it and/or
+modify it under the same terms as Perl itself.
+END
+
+    use Getopt::Long qw(:config no_ignore_case); # otherwise v|V is the same
+
+    GetOptions(
+      "config|c=s" => \($opts{c}),
+      "entities|e" => \($opts{e}),
+      "german|g"   => \($opts{g}),
+      "html|h"     => \($opts{h}),
+      "output|o=s" => \($opts{o}),
+      "verbose|v"  => \($opts{v}),
+      "version|V"  => \($opts{V}),
+      "help|?"     => \($opts{help}))
+    || die "Try $0 --help for more information.\n";
+
+    if ($opts{help}) { print "$USAGE\n$VERSION"; exit 0; } 
+    if ($opts{V}) { print $VERSION; exit 0; } 
+
+    binmode(STDOUT, ":utf8");
+    *OUT = *STDOUT;
+
+    if (defined($opts{o})) {
+         open(OUT, ">$opts{o}") || die "open(>$opts{o}) failed: $!\n";
+        binmode(OUT, ":utf8")
+    }
+
+    if ($opts{c}) {
+        if (-r $opts{c}) {
+        # if config arg is absolute, fine; if not, prepend "./" as slightly
+          # less troublesome than putting "." in the @INC path.
+          my $rel = (File::Spec->file_name_is_absolute($opts{c}) ? "" : "./");
+          my $cnffile = "$rel$opts{c}";
+          verbose("requiring config file: $cnffile");
+          require $cnffile;
+        } else {
+          die "open config file ($opts{c}) for reading failed: $!\n";
+      }
+    }
+}
+
+

+sub verbose { print @_ if $::opts{v}; }


Property changes on: trunk/Build/source/texk/texlive/linked_scripts/bibtexperllibs/ltx2unitxt
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: trunk/Build/source/texk/texlive/linked_scripts/scripts.lst
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/scripts.lst	2023-11-16 00:43:31 UTC (rev 68868)
+++ trunk/Build/source/texk/texlive/linked_scripts/scripts.lst	2023-11-16 18:39:12 UTC (rev 68869)
@@ -53,6 +53,7 @@
 bib2gls/bib2gls.sh
 bib2gls/convertgls2bib.sh
 bibcop/bibcop.pl
+bibtexperllibs/ltx2unitxt
 bundledoc/arlatex
 bundledoc/bundledoc
 cachepic/cachepic.tlu

Added: trunk/Master/bin/aarch64-linux/ltx2unitxt
===================================================================
--- trunk/Master/bin/aarch64-linux/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/aarch64-linux/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/aarch64-linux/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/amd64-freebsd/ltx2unitxt
===================================================================
--- trunk/Master/bin/amd64-freebsd/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/amd64-freebsd/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/amd64-freebsd/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/amd64-netbsd/ltx2unitxt
===================================================================
--- trunk/Master/bin/amd64-netbsd/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/amd64-netbsd/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/amd64-netbsd/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/armhf-linux/ltx2unitxt
===================================================================
--- trunk/Master/bin/armhf-linux/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/armhf-linux/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/armhf-linux/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-freebsd/ltx2unitxt
===================================================================
--- trunk/Master/bin/i386-freebsd/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/i386-freebsd/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/i386-freebsd/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-linux/ltx2unitxt
===================================================================
--- trunk/Master/bin/i386-linux/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/i386-linux/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/i386-linux/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-netbsd/ltx2unitxt
===================================================================
--- trunk/Master/bin/i386-netbsd/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/i386-netbsd/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/i386-netbsd/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-solaris/ltx2unitxt
===================================================================
--- trunk/Master/bin/i386-solaris/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/i386-solaris/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/i386-solaris/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/universal-darwin/ltx2unitxt
===================================================================
--- trunk/Master/bin/universal-darwin/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/universal-darwin/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/universal-darwin/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/windows/ltx2unitxt.exe
===================================================================
(Binary files differ)

Index: trunk/Master/bin/windows/ltx2unitxt.exe
===================================================================
--- trunk/Master/bin/windows/ltx2unitxt.exe	2023-11-16 00:43:31 UTC (rev 68868)
+++ trunk/Master/bin/windows/ltx2unitxt.exe	2023-11-16 18:39:12 UTC (rev 68869)

Property changes on: trunk/Master/bin/windows/ltx2unitxt.exe
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Master/bin/x86_64-cygwin/ltx2unitxt
===================================================================
--- trunk/Master/bin/x86_64-cygwin/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/x86_64-cygwin/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/x86_64-cygwin/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/x86_64-darwinlegacy/ltx2unitxt
===================================================================
--- trunk/Master/bin/x86_64-darwinlegacy/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/x86_64-darwinlegacy/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/x86_64-darwinlegacy/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/x86_64-linux/ltx2unitxt
===================================================================
--- trunk/Master/bin/x86_64-linux/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/x86_64-linux/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/x86_64-linux/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/x86_64-linuxmusl/ltx2unitxt
===================================================================
--- trunk/Master/bin/x86_64-linuxmusl/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/x86_64-linuxmusl/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/x86_64-linuxmusl/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/x86_64-solaris/ltx2unitxt
===================================================================
--- trunk/Master/bin/x86_64-solaris/ltx2unitxt	                        (rev 0)
+++ trunk/Master/bin/x86_64-solaris/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt
\ No newline at end of file


Property changes on: trunk/Master/bin/x86_64-solaris/ltx2unitxt
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/texmf-dist/scripts/bibtexperllibs/ltx2unitxt
===================================================================
--- trunk/Master/texmf-dist/scripts/bibtexperllibs/ltx2unitxt	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/bibtexperllibs/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1,169 @@
+#!/usr/bin/env perl
+# Use the LaTeX::ToUnicode module (also in the bibtexperllibs
+# repository/package, like this script) to convert LaTeX to Unicode.
+# 
+# We work on fragments of text, not whole documents, the goal being to
+# replace LaTeX commands and syntax with obvious plain text equivalents,
+# or remove them.
+
+use strict;
+use warnings;
+
+use Cwd;
+use File::Basename;
+use File::Spec;
+
+BEGIN {
+    # find files relative to our installed location within TeX Live
+    chomp(my $TLMaster = `kpsewhich -var-value=SELFAUTOPARENT`); # TL root
+    if (length($TLMaster)) {
+        unshift @INC, "$TLMaster/texmf-dist/scripts/bibtexperllibs";
+    }
+    # find development bibtexperllibs in sibling checkout to this script,
+    # even if $0 is a symlink. Irrelevant when using from an installation.
+    my $real0 = Cwd::abs_path($0);
+    my $scriptdir = File::Basename::dirname($real0);
+    my $dev_btxperllibs = Cwd::abs_path("$scriptdir/../..");
+
+    # we need the lib/ subdirectories inside ...
+    unshift (@INC, glob ("$dev_btxperllibs/*/lib")) if -d $dev_btxperllibs;
+
+}
+
+use LaTeX::ToUnicode;
+
+our %opts;
+local *OUT; # output filehandle
+
+exit(main());
+
+sub main {
+    init();
+
+    # by paragraph?
+    while (<>) {
+        print OUT (convert($_));
+    }
+
+    return 0;
+}
+
+sub convert {
+    my ($in) = @_;
+
+    my @args = (); # what we'll pass to the convert() fn.
+    #
+    if (defined(&{"LaTeX_ToUnicode_convert_hook"})) {
+      push (@args, "hook" => \&LaTeX_ToUnicode_convert_hook); }
+    if ($opts{e}) { push (@args, "entities" => 1); }
+    if ($opts{g}) { push (@args, "german" => 1); }
+    if ($opts{h}) { push (@args, "html" => 1); }
+
+    LaTeX::ToUnicode::debuglevel($opts{v});
+    my $out = LaTeX::ToUnicode::convert($in, @args);
+
+    #warn "out=$out";
+    return $out;
+}
+
+

+# Command line options, etc.
+# 
+sub init {
+    my $USAGE = <<END;
+Usage: $0 [-c CONFIG] [-o OUTPUT] [--html] [...] [INFILE]...
+
+Convert the LaTeX source in INFILE (or standard input) to plain text
+using Unicode code points for accents and other special characters; or,
+optionally, output HTML with simple translations for font changes and url
+commands.
+
+Common accent sequences, special characters, and simple markup commands
+are translated, but there is no attempt at completeness. Math, tables,
+figures, sectioning, etc., are not handled in any way, and mostly left
+in their TeX form in the output. The translations assume standard LaTeX
+meanings for characters and control sequences; macros in the input are
+not considered.
+
+The input can be a fragment of text, not a full document, as the purpose
+of this script was to handle bibliography entries and abstracts (for the
+ltx2crossrefxml script that is part of the crossrefware package).
+Patches to extend this script are welcome. It uses the LaTeX::ToUnicode
+Perl library for the conversion; see its documentation for details.
+
+Conversion is currently done line by line, so TeX constructs that cross
+multiple lines are not handled properly. If it turns out to be useful,
+conversion could be done by paragraph instead.
+
+The config file is read as a Perl source file. It can define a function
+`LaTeX_ToUnicode_convert_hook()' which will be called early; the value
+it returns (which must be a string) will then be subject to the standard
+conversion.
+
+For an example of using this script and associated code, see the TUGboat
+processing at
+https://github.com/TeXUsersGroup/tugboat/tree/trunk/capsules/crossref.
+
+Options:
+  -c, --config=FILE  read (Perl) config FILE for a hook, as explained above
+  -e, --entities     output entities &#xNNNN; instead of literal characters
+  -g, --german       handle some features of the german package
+  -h, --html         output simplistic HTML instead of plain text
+  -o, --output=FILE  output to FILE instead of stdout
+  -v, --verbose      be verbose
+  -V, --version      output version information and exit
+  -?, --help         display this help and exit
+
+Options can be abbreviated unambiguously, and start with either - or --.
+
+Dev sources, bug tracker: https://github.com/borisveytsman/bibtexperllibs
+Releases: https://ctan.org/pkg/bibtexperllibs
+END
+
+ my $VERSION = <<END;
+ltx2unitxt (bibtexperllibs) 0.51
+Copyright 2023 Karl Berry.
+This is free software: you can redistribute it and/or
+modify it under the same terms as Perl itself.
+END
+
+    use Getopt::Long qw(:config no_ignore_case); # otherwise v|V is the same
+
+    GetOptions(
+      "config|c=s" => \($opts{c}),
+      "entities|e" => \($opts{e}),
+      "german|g"   => \($opts{g}),
+      "html|h"     => \($opts{h}),
+      "output|o=s" => \($opts{o}),
+      "verbose|v"  => \($opts{v}),
+      "version|V"  => \($opts{V}),
+      "help|?"     => \($opts{help}))
+    || die "Try $0 --help for more information.\n";
+
+    if ($opts{help}) { print "$USAGE\n$VERSION"; exit 0; } 
+    if ($opts{V}) { print $VERSION; exit 0; } 
+
+    binmode(STDOUT, ":utf8");
+    *OUT = *STDOUT;
+
+    if (defined($opts{o})) {
+         open(OUT, ">$opts{o}") || die "open(>$opts{o}) failed: $!\n";
+        binmode(OUT, ":utf8")
+    }
+
+    if ($opts{c}) {
+        if (-r $opts{c}) {
+        # if config arg is absolute, fine; if not, prepend "./" as slightly
+          # less troublesome than putting "." in the @INC path.
+          my $rel = (File::Spec->file_name_is_absolute($opts{c}) ? "" : "./");
+          my $cnffile = "$rel$opts{c}";
+          verbose("requiring config file: $cnffile");
+          require $cnffile;
+        } else {
+          die "open config file ($opts{c}) for reading failed: $!\n";
+      }
+    }
+}
+
+

+sub verbose { print @_ if $::opts{v}; }


Property changes on: trunk/Master/texmf-dist/scripts/bibtexperllibs/ltx2unitxt
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Deleted: trunk/Master/texmf-dist/source/support/bibtexperllibs/LaTeX-ToUnicode/script/ltx2unitxt
===================================================================
--- trunk/Master/texmf-dist/source/support/bibtexperllibs/LaTeX-ToUnicode/script/ltx2unitxt	2023-11-16 00:43:31 UTC (rev 68868)
+++ trunk/Master/texmf-dist/source/support/bibtexperllibs/LaTeX-ToUnicode/script/ltx2unitxt	2023-11-16 18:39:12 UTC (rev 68869)
@@ -1,169 +0,0 @@
-#!/usr/bin/env perl
-# Use the LaTeX::ToUnicode module (also in the bibtexperllibs
-# repository/package, like this script) to convert LaTeX to Unicode.
-# 
-# We work on fragments of text, not whole documents, the goal being to
-# replace LaTeX commands and syntax with obvious plain text equivalents,
-# or remove them.
-
-use strict;
-use warnings;
-
-use Cwd;
-use File::Basename;
-use File::Spec;
-
-BEGIN {
-    # find files relative to our installed location within TeX Live
-    chomp(my $TLMaster = `kpsewhich -var-value=SELFAUTOPARENT`); # TL root
-    if (length($TLMaster)) {
-        unshift @INC, "$TLMaster/texmf-dist/scripts/bibtexperllibs";
-    }
-    # find development bibtexperllibs in sibling checkout to this script,
-    # even if $0 is a symlink. Irrelevant when using from an installation.
-    my $real0 = Cwd::abs_path($0);
-    my $scriptdir = File::Basename::dirname($real0);
-    my $dev_btxperllibs = Cwd::abs_path("$scriptdir/../..");
-
-    # we need the lib/ subdirectories inside ...
-    unshift (@INC, glob ("$dev_btxperllibs/*/lib")) if -d $dev_btxperllibs;
-
-}
-
-use LaTeX::ToUnicode;
-
-our %opts;
-local *OUT; # output filehandle
-
-exit(main());
-
-sub main {
-    init();
-
-    # by paragraph?
-    while (<>) {
-        print OUT (convert($_));
-    }
-
-    return 0;
-}
-
-sub convert {
-    my ($in) = @_;
-
-    my @args = (); # what we'll pass to the convert() fn.
-    #
-    if (defined(&{"LaTeX_ToUnicode_convert_hook"})) {
-      push (@args, "hook" => \&LaTeX_ToUnicode_convert_hook); }
-    if ($opts{e}) { push (@args, "entities" => 1); }
-    if ($opts{g}) { push (@args, "german" => 1); }
-    if ($opts{h}) { push (@args, "html" => 1); }
-
-    LaTeX::ToUnicode::debuglevel($opts{v});
-    my $out = LaTeX::ToUnicode::convert($in, @args);
-
-    #warn "out=$out";
-    return $out;
-}
-
-

-# Command line options, etc.
-# 
-sub init {
-    my $USAGE = <<END;
-Usage: $0 [-c CONFIG] [-o OUTPUT] [--html] [...] [INFILE]...
-
-Convert the LaTeX source in INFILE (or standard input) to plain text
-using Unicode code points for accents and other special characters; or,
-optionally, output HTML with simple translations for font changes and url
-commands.
-
-Common accent sequences, special characters, and simple markup commands
-are translated, but there is no attempt at completeness. Math, tables,
-figures, sectioning, etc., are not handled in any way, and mostly left
-in their TeX form in the output. The translations assume standard LaTeX
-meanings for characters and control sequences; macros in the input are
-not considered.
-
-The input can be a fragment of text, not a full document, as the purpose
-of this script was to handle bibliography entries and abstracts (for the
-ltx2crossrefxml script that is part of the crossrefware package).
-Patches to extend this script are welcome. It uses the LaTeX::ToUnicode
-Perl library for the conversion; see its documentation for details.
-
-Conversion is currently done line by line, so TeX constructs that cross
-multiple lines are not handled properly. If it turns out to be useful,
-conversion could be done by paragraph instead.
-
-The config file is read as a Perl source file. It can define a function
-`LaTeX_ToUnicode_convert_hook()' which will be called early; the value
-it returns (which must be a string) will then be subject to the standard
-conversion.
-
-For an example of using this script and associated code, see the TUGboat
-processing at
-https://github.com/TeXUsersGroup/tugboat/tree/trunk/capsules/crossref.
-
-Options:
-  -c, --config=FILE  read (Perl) config FILE for a hook, as explained above
-  -e, --entities     output entities &#xNNNN; instead of literal characters
-  -g, --german       handle some features of the german package
-  -h, --html         output simplistic HTML instead of plain text
-  -o, --output=FILE  output to FILE instead of stdout
-  -v, --verbose      be verbose
-  -V, --version      output version information and exit
-  -?, --help         display this help and exit
-
-Options can be abbreviated unambiguously, and start with either - or --.
-
-Dev sources, bug tracker: https://github.com/borisveytsman/bibtexperllibs
-Releases: https://ctan.org/pkg/bibtexperllibs
-END
-
- my $VERSION = <<END;
-ltx2unitxt (bibtexperllibs) 0.51
-Copyright 2023 Karl Berry.
-This is free software: you can redistribute it and/or
-modify it under the same terms as Perl itself.
-END
-
-    use Getopt::Long qw(:config no_ignore_case); # otherwise v|V is the same
-
-    GetOptions(
-      "config|c=s" => \($opts{c}),
-      "entities|e" => \($opts{e}),
-      "german|g"   => \($opts{g}),
-      "html|h"     => \($opts{h}),
-      "output|o=s" => \($opts{o}),
-      "verbose|v"  => \($opts{v}),
-      "version|V"  => \($opts{V}),
-      "help|?"     => \($opts{help}))
-    || die "Try $0 --help for more information.\n";
-
-    if ($opts{help}) { print "$USAGE\n$VERSION"; exit 0; } 
-    if ($opts{V}) { print $VERSION; exit 0; } 
-
-    binmode(STDOUT, ":utf8");
-    *OUT = *STDOUT;
-
-    if (defined($opts{o})) {
-         open(OUT, ">$opts{o}") || die "open(>$opts{o}) failed: $!\n";
-        binmode(OUT, ":utf8")
-    }
-
-    if ($opts{c}) {
-        if (-r $opts{c}) {
-        # if config arg is absolute, fine; if not, prepend "./" as slightly
-          # less troublesome than putting "." in the @INC path.
-          my $rel = (File::Spec->file_name_is_absolute($opts{c}) ? "" : "./");
-          my $cnffile = "$rel$opts{c}";
-          verbose("requiring config file: $cnffile");
-          require $cnffile;
-        } else {
-          die "open config file ($opts{c}) for reading failed: $!\n";
-      }
-    }
-}
-
-

-sub verbose { print @_ if $::opts{v}; }

Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2023-11-16 00:43:31 UTC (rev 68868)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2023-11-16 18:39:12 UTC (rev 68869)
@@ -3693,6 +3693,7 @@
  'bib2gls'		=> '\.sh$',
  'bibcop'		=> '\.pl$',
  'bibexport'            => 'bibexport\.sh$',
+ 'bibtexperllibs'	=> 'ltx2unitxt',
  'bundledoc'            => '(arlatex|bundledoc)$',
  'checkcites'           => '\.lua$',
  'checklistings'        => '\.sh$',
@@ -4652,7 +4653,7 @@
   # first do the user-visible bindir entries.
   $scriptpatt = $specialscripts_bin{$package};
   if ($scriptpatt) {
-     print  " doing bindir pattern $scriptpatt...\n";
+    print  " doing bindir pattern $scriptpatt...\n";
     if (! $tds_zip) {
       &install ($scriptsdir, $scriptpatt);
       &SYSTEM ("chmod a+x $scriptsdir/*");
@@ -6176,6 +6177,11 @@
   &SYSTEM ("mkdir config");
 }
 
+sub PREHOOK_bibtexperllibs {
+  print "PREHOOK_$package - make .1 with pod2man\n";
+  &prehook_pod2man ("Peter Szabo", "$package.pl");
+}
+
 sub PREHOOK_cals {
   print "PREHOOK_$package - flatten only cals subdir\n";
   &SYSTEM ("$MV cals/* .");
@@ -6678,6 +6684,11 @@
   &xchdir ("$DEST/source/support/$package/");
   &mv_with_mkdir ("*/lib/*", "$DEST/scripts/$package/");
   &mv_with_mkdir ("*/man/*/*", "$DEST/doc/support/$package/");
+  #
+  # The user-level script is buried in a subdir.
+  &xchdir ("LaTeX-ToUnicode/script");
+  @filenames = glob ("*"); # have to reset @filenames for install()
+  &doscripts ();
 }
 
 sub POSTcfr_lm {

Modified: trunk/Master/tlpkg/tlpsrc/bibtexperllibs.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/bibtexperllibs.tlpsrc	2023-11-16 00:43:31 UTC (rev 68868)
+++ trunk/Master/tlpkg/tlpsrc/bibtexperllibs.tlpsrc	2023-11-16 18:39:12 UTC (rev 68869)
@@ -0,0 +1 @@
+binpattern f bin/${ARCH}/ltx2unitxt



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