From c322165b37e8f2dee17d03e37fbc7bb1d211b14f Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 16 Nov 2023 18:39:12 +0000 Subject: bibtexperllibs: ltx2unitxt as user-level script git-svn-id: svn://tug.org/texlive/trunk@68869 c570f23f-e606-0410-a88d-b1316a301751 --- .../LaTeX-ToUnicode/script/ltx2unitxt | 169 --------------------- 1 file changed, 169 deletions(-) delete mode 100755 Master/texmf-dist/source/support/bibtexperllibs/LaTeX-ToUnicode/script/ltx2unitxt (limited to 'Master/texmf-dist/source/support') diff --git a/Master/texmf-dist/source/support/bibtexperllibs/LaTeX-ToUnicode/script/ltx2unitxt b/Master/texmf-dist/source/support/bibtexperllibs/LaTeX-ToUnicode/script/ltx2unitxt deleted file mode 100755 index 661ea404171..00000000000 --- a/Master/texmf-dist/source/support/bibtexperllibs/LaTeX-ToUnicode/script/ltx2unitxt +++ /dev/null @@ -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 = < \($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}; } -- cgit v1.2.3