summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-11-16 18:39:12 +0000
committerKarl Berry <karl@freefriends.org>2023-11-16 18:39:12 +0000
commitc322165b37e8f2dee17d03e37fbc7bb1d211b14f (patch)
treec3d2af56c2d455a1046a445775d93fe491f66449
parent1eb8ec41072dd41f0c26702d2f3226f740930d8a (diff)
bibtexperllibs: ltx2unitxt as user-level script
git-svn-id: svn://tug.org/texlive/trunk@68869 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Build/source/texk/texlive/linked_scripts/Makefile.am2
-rw-r--r--Build/source/texk/texlive/linked_scripts/Makefile.in3
-rwxr-xr-xBuild/source/texk/texlive/linked_scripts/bibtexperllibs/ltx2unitxt (renamed from Master/texmf-dist/source/support/bibtexperllibs/LaTeX-ToUnicode/script/ltx2unitxt)0
-rw-r--r--Build/source/texk/texlive/linked_scripts/scripts.lst1
l---------Master/bin/aarch64-linux/ltx2unitxt1
l---------Master/bin/amd64-freebsd/ltx2unitxt1
l---------Master/bin/amd64-netbsd/ltx2unitxt1
l---------Master/bin/armhf-linux/ltx2unitxt1
l---------Master/bin/i386-freebsd/ltx2unitxt1
l---------Master/bin/i386-linux/ltx2unitxt1
l---------Master/bin/i386-netbsd/ltx2unitxt1
l---------Master/bin/i386-solaris/ltx2unitxt1
l---------Master/bin/universal-darwin/ltx2unitxt1
-rwxr-xr-xMaster/bin/windows/ltx2unitxt.exebin0 -> 6144 bytes
l---------Master/bin/x86_64-cygwin/ltx2unitxt1
l---------Master/bin/x86_64-darwinlegacy/ltx2unitxt1
l---------Master/bin/x86_64-linux/ltx2unitxt1
l---------Master/bin/x86_64-linuxmusl/ltx2unitxt1
l---------Master/bin/x86_64-solaris/ltx2unitxt1
-rwxr-xr-xMaster/texmf-dist/scripts/bibtexperllibs/ltx2unitxt169
-rwxr-xr-xMaster/tlpkg/libexec/ctan2tds13
-rw-r--r--Master/tlpkg/tlpsrc/bibtexperllibs.tlpsrc1
22 files changed, 202 insertions, 1 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.am b/Build/source/texk/texlive/linked_scripts/Makefile.am
index e7601eda950..9102aee218b 100644
--- a/Build/source/texk/texlive/linked_scripts/Makefile.am
+++ b/Build/source/texk/texlive/linked_scripts/Makefile.am
@@ -99,6 +99,7 @@ texmf_shell_scripts = \
typeoutfileinfo/typeoutfileinfo.sh \
wordcount/wordcount.sh
+#
texmf_other_scripts = \
a2ping/a2ping.pl \
accfonts/mkt1font \
@@ -111,6 +112,7 @@ texmf_other_scripts = \
bib2gls/bib2gls.sh \
bib2gls/convertgls2bib.sh \
bibcop/bibcop.pl \
+ bibtexperllibs/ltx2unitxt \
bundledoc/arlatex \
bundledoc/bundledoc \
cachepic/cachepic.tlu \
diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.in b/Build/source/texk/texlive/linked_scripts/Makefile.in
index 443b441cb23..3e350511bc0 100644
--- a/Build/source/texk/texlive/linked_scripts/Makefile.in
+++ b/Build/source/texk/texlive/linked_scripts/Makefile.in
@@ -315,6 +315,8 @@ texmf_shell_scripts = \
typeoutfileinfo/typeoutfileinfo.sh \
wordcount/wordcount.sh
+
+#
texmf_other_scripts = \
a2ping/a2ping.pl \
accfonts/mkt1font \
@@ -327,6 +329,7 @@ texmf_other_scripts = \
bib2gls/bib2gls.sh \
bib2gls/convertgls2bib.sh \
bibcop/bibcop.pl \
+ bibtexperllibs/ltx2unitxt \
bundledoc/arlatex \
bundledoc/bundledoc \
cachepic/cachepic.tlu \
diff --git a/Master/texmf-dist/source/support/bibtexperllibs/LaTeX-ToUnicode/script/ltx2unitxt b/Build/source/texk/texlive/linked_scripts/bibtexperllibs/ltx2unitxt
index 661ea404171..661ea404171 100755
--- a/Master/texmf-dist/source/support/bibtexperllibs/LaTeX-ToUnicode/script/ltx2unitxt
+++ b/Build/source/texk/texlive/linked_scripts/bibtexperllibs/ltx2unitxt
diff --git a/Build/source/texk/texlive/linked_scripts/scripts.lst b/Build/source/texk/texlive/linked_scripts/scripts.lst
index a455f39391a..3342efc3356 100644
--- a/Build/source/texk/texlive/linked_scripts/scripts.lst
+++ b/Build/source/texk/texlive/linked_scripts/scripts.lst
@@ -53,6 +53,7 @@ authorindex/authorindex
bib2gls/bib2gls.sh
bib2gls/convertgls2bib.sh
bibcop/bibcop.pl
+bibtexperllibs/ltx2unitxt
bundledoc/arlatex
bundledoc/bundledoc
cachepic/cachepic.tlu
diff --git a/Master/bin/aarch64-linux/ltx2unitxt b/Master/bin/aarch64-linux/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/aarch64-linux/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/amd64-freebsd/ltx2unitxt b/Master/bin/amd64-freebsd/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/amd64-freebsd/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/amd64-netbsd/ltx2unitxt b/Master/bin/amd64-netbsd/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/amd64-netbsd/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/armhf-linux/ltx2unitxt b/Master/bin/armhf-linux/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/armhf-linux/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/i386-freebsd/ltx2unitxt b/Master/bin/i386-freebsd/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/i386-freebsd/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/i386-linux/ltx2unitxt b/Master/bin/i386-linux/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/i386-linux/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/i386-netbsd/ltx2unitxt b/Master/bin/i386-netbsd/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/i386-netbsd/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/i386-solaris/ltx2unitxt b/Master/bin/i386-solaris/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/i386-solaris/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/universal-darwin/ltx2unitxt b/Master/bin/universal-darwin/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/universal-darwin/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/windows/ltx2unitxt.exe b/Master/bin/windows/ltx2unitxt.exe
new file mode 100755
index 00000000000..3332231b08c
--- /dev/null
+++ b/Master/bin/windows/ltx2unitxt.exe
Binary files differ
diff --git a/Master/bin/x86_64-cygwin/ltx2unitxt b/Master/bin/x86_64-cygwin/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/x86_64-cygwin/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/x86_64-darwinlegacy/ltx2unitxt b/Master/bin/x86_64-darwinlegacy/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/x86_64-darwinlegacy/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/x86_64-linux/ltx2unitxt b/Master/bin/x86_64-linux/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/x86_64-linux/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/x86_64-linuxmusl/ltx2unitxt b/Master/bin/x86_64-linuxmusl/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/x86_64-linuxmusl/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/bin/x86_64-solaris/ltx2unitxt b/Master/bin/x86_64-solaris/ltx2unitxt
new file mode 120000
index 00000000000..f3664696b44
--- /dev/null
+++ b/Master/bin/x86_64-solaris/ltx2unitxt
@@ -0,0 +1 @@
+../../texmf-dist/scripts/bibtexperllibs/ltx2unitxt \ No newline at end of file
diff --git a/Master/texmf-dist/scripts/bibtexperllibs/ltx2unitxt b/Master/texmf-dist/scripts/bibtexperllibs/ltx2unitxt
new file mode 100755
index 00000000000..661ea404171
--- /dev/null
+++ b/Master/texmf-dist/scripts/bibtexperllibs/ltx2unitxt
@@ -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}; }
diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds
index 2f14370fc3b..f444431484f 100755
--- a/Master/tlpkg/libexec/ctan2tds
+++ b/Master/tlpkg/libexec/ctan2tds
@@ -3693,6 +3693,7 @@ $standardttf = '\.ttf|\.TTC';
'bib2gls' => '\.sh$',
'bibcop' => '\.pl$',
'bibexport' => 'bibexport\.sh$',
+ 'bibtexperllibs' => 'ltx2unitxt',
'bundledoc' => '(arlatex|bundledoc)$',
'checkcites' => '\.lua$',
'checklistings' => '\.sh$',
@@ -4652,7 +4653,7 @@ sub doscripts {
# 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 @@ sub PREHOOK_apa7 {
&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 @@ sub POSTbibtexperllibs {
&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 {
diff --git a/Master/tlpkg/tlpsrc/bibtexperllibs.tlpsrc b/Master/tlpkg/tlpsrc/bibtexperllibs.tlpsrc
index e69de29bb2d..f136d4dd7f4 100644
--- a/Master/tlpkg/tlpsrc/bibtexperllibs.tlpsrc
+++ b/Master/tlpkg/tlpsrc/bibtexperllibs.tlpsrc
@@ -0,0 +1 @@
+binpattern f bin/${ARCH}/ltx2unitxt