diff options
-rwxr-xr-x | Build/source/texk/texlive/linked_scripts/ptex2pdf/ptex2pdf.lua | 96 | ||||
-rwxr-xr-x | Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl | 105 | ||||
-rwxr-xr-x | Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl | 11 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/ptex2pdf/README | 212 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/ptex2pdf/README.md | 168 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua | 96 |
6 files changed, 324 insertions, 364 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/ptex2pdf/ptex2pdf.lua b/Build/source/texk/texlive/linked_scripts/ptex2pdf/ptex2pdf.lua index f6e4fc0fbb6..3b0c5b5d62b 100755 --- a/Build/source/texk/texlive/linked_scripts/ptex2pdf/ptex2pdf.lua +++ b/Build/source/texk/texlive/linked_scripts/ptex2pdf/ptex2pdf.lua @@ -1,7 +1,7 @@ #!/usr/bin/env texlua NAME = "ptex2pdf[.lua]" -VERSION = "0.7" +VERSION = "0.8" AUTHOR = "Norbert Preining" AUTHOREMAIL = "norbert@preining.info" SHORTDESC = "Convert Japanese TeX documents to pdf" @@ -152,11 +152,14 @@ CHANGELOG = [[ cygwin didn't like the (accidentally inserted) spaces after the texlua in the shebang line, and stopped working with "no such program: "texlua " ..." -- version 0.7dev 2015-XX-XX +- version 0.7 2015-04-29 move to github as gitorious will be closed, adapt help output to generate github flavored markdown check for files using kpathsea instead of opening directly, to allow for input of files found by kpathsea (closes github issue 1) +- version 0.8 2015-06-15 + file name checks: first search for arg as is, then try .tex and .ltx + (closes github issue: 3) ]] @@ -247,6 +250,7 @@ use_eptex = 0 use_uptex = 0 use_latex = 0 filename = "" +bname = "" exit_code = 0 narg = 1 repeat @@ -323,46 +327,64 @@ end -- initialize kpse kpse.set_program_name(tex) -if filename ~= "" and string.sub(filename, -4, -1) == ".tex" then - filename = string.sub(filename, 1, -5) +-- filename searching +-- first search for the file as is, +-- if not found, try file .tex, if that not found, file .ltx + +if ( filename == "" ) then + print("No filename argument given, exiting.") + os.exit(1) +else + if ( kpse.find_file(filename) == nil ) then + -- try .tex extension + if ( kpse.find_file(filename .. ".tex") == nil ) then + -- last try .ltx + if ( kpse.find_file(filename .. ".ltx") == nil ) then + print("File cannot be found with kpathsea: ", filename .. "[.tex, .ltx]") + os.exit(1) + else + bname = filename + filename = filename .. ".ltx" + end + else + bname = filename + filename = filename .. ".tex" + end + else + -- if it has already an extension, we need to drop it to get the dvi name + bname = string.gsub(filename, "^(.*)%.[^.]+$", "%1") + end end --- if not io.open(filename .. ".tex", "r") then --- print("Non-existent file: ", filename .. ".tex") --- exit_code = 1 -if ( kpse.find_file(filename .. ".tex") == nil ) then - print("File cannot be found with kpathsea: ", filename .. ".tex") - exit_code = 1 -else - -- make sure that on Windows/uptex we are using utf8 as command line encoding - if use_uptex == 1 then - if os.type == 'windows' then - os.setenv('command_line_encoding', 'utf8') - end +-- we are still here, so we found a file +-- make sure that on Windows/uptex we are using utf8 as command line encoding +if use_uptex == 1 then + if os.type == 'windows' then + os.setenv('command_line_encoding', 'utf8') end - print("Processing ".. filename .. ".tex.") - if (os.execute(tex .. " " .. texopts .. " \"" .. filename .. "\"") == 0) and - (dvipdf == "" or (os.execute(dvipdf .. " " .. dvipdfopts .. " \"" .. filename .. "\"") == 0)) - then - if dvipdf ~= "" then - print(filename .. ".pdf generated by " .. dvipdf .. ".") - end - if intermediate == 1 then -- clean-up: - if dvipdf ~= "" then - os.remove( filename .. ".dvi" ) - end - end - else - print("ptex2pdf processing of " .. filename .. ".tex fails.\n") - exit_code = 2 - --[[ uncomment for debugging - print("tex = ", tex) - print("dvipdf = ", dvipdf) - --]] +end +print("Processing ".. filename) +if (os.execute(tex .. " " .. texopts .. " \"" .. filename .. "\"") == 0) and + (dvipdf == "" or (os.execute(dvipdf .. " " .. dvipdfopts .. " \"" .. bname .. ".dvi" .. "\"") == 0)) then + if dvipdf ~= "" then + print(bname .. ".pdf generated by " .. dvipdf .. ".") + end + if intermediate == 1 then -- clean-up: + if dvipdf ~= "" then + os.remove( bname .. ".dvi" ) end -end --if not io.open ... + end +else + print("ptex2pdf processing of " .. filename .. " failed.\n") + --[[ uncomment for debugging + print("tex = ", tex) + print("dvipdf = ", dvipdf) + --]] + os.exit(2) +end -os.exit( exit_code ) +-- all done ... exit with success +os.exit( 0 ) diff --git a/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl b/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl index 4bf66b2c952..53d5d70ce8b 100755 --- a/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl +++ b/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# $Id: fmtutil.pl 37485 2015-05-23 16:52:36Z karl $ +# $Id: fmtutil.pl 37541 2015-06-15 00:00:42Z preining $ # fmtutil - utility to maintain format files. # (Maintained in TeX Live:Master/texmf-dist/scripts/texlive.) # @@ -25,11 +25,11 @@ BEGIN { } -my $svnid = '$Id: fmtutil.pl 37485 2015-05-23 16:52:36Z karl $'; -my $lastchdate = '$Date: 2015-05-23 18:52:36 +0200 (Sat, 23 May 2015) $'; +my $svnid = '$Id: fmtutil.pl 37541 2015-06-15 00:00:42Z preining $'; +my $lastchdate = '$Date: 2015-06-15 02:00:42 +0200 (Mon, 15 Jun 2015) $'; $lastchdate =~ s/^\$Date:\s*//; $lastchdate =~ s/ \(.*$//; -my $svnrev = '$Revision: 37485 $'; +my $svnrev = '$Revision: 37541 $'; $svnrev =~ s/^\$Revision:\s*//; $svnrev =~ s/\s*\$$//; my $version = "r$svnrev ($lastchdate)"; @@ -228,11 +228,11 @@ sub main { print_warning("--catcfg command not supported anymore!\n"); exit(1); } elsif ($opts{'listcfg'}) { - print_warning("--listcfg currently not implemented, be patient!\n"); + return callback_list_cfg(); exit(1); } elsif ($opts{'disablefmt'}) { return callback_enable_disable_format($changes_config_file, - $opts{'enablefmt'}, 'disabled'); + $opts{'disablefmt'}, 'disabled'); } elsif ($opts{'enablefmt'}) { return callback_enable_disable_format($changes_config_file, $opts{'enablefmt'}, 'enabled'); @@ -665,14 +665,14 @@ sub enable_disable_format_engine { my $origin = $alldata->{'merged'}{$fmt}{$eng}{'origin'}; if ($origin ne $tc) { $alldata->{'fmtutil'}{$tc}{'formats'}{$fmt}{$eng} = - {%{$alldata->{'fmtutil'}{$origin}{'formats'}{$fmt}{$eng}}} + {%{$alldata->{'fmtutil'}{$origin}{'formats'}{$fmt}{$eng}}}; + $alldata->{'fmtutil'}{$tc}{'formats'}{$fmt}{$eng}{'line'} = -1; } $alldata->{'fmtutil'}{$tc}{'formats'}{$fmt}{$eng}{'status'} = $mode; - $alldata->{'fmtutil'}{$tc}{'formats'}{$fmt}{$eng}{'line'} = -1; - $alldata->{'fmtutil'}{$tc}{'formats'}{$fmt}{$eng}{'changed'} = 1; + $alldata->{'fmtutil'}{$tc}{'changed'} = 1; $alldata->{'merged'}{$fmt}{$eng}{'status'} = $mode; $alldata->{'merged'}{$fmt}{$eng}{'origin'} = $tc; - dump_data(); + # dump_data(); return save_fmtutil($tc); } } else { @@ -732,12 +732,34 @@ sub callback_enable_disable_format { } } +sub callback_list_cfg { + my @lines; + for my $f (keys %{$alldata->{'merged'}}) { + for my $e (keys %{$alldata->{'merged'}{$f}}) { + my $orig = $alldata->{'merged'}{$f}{$e}{'origin'}; + my $hyph = $alldata->{'merged'}{$f}{$e}{'hyphen'}; + my $stat = $alldata->{'merged'}{$f}{$e}{'status'}; + my $args = $alldata->{'merged'}{$f}{$e}{'args'}; + push @lines, + [ "$f/$e/$hyph", + "$f (engine=$e) $stat\n hyphen=$hyph, args=$args\n origin=$orig\n" ]; + } + } + # sort lines + @lines = map { $_->[1] } sort { $a->[0] cmp $b->[0] } @lines; + print "List of all formats:\n"; + print @lines; +} + sub read_fmtutil_files { my (@l) = @_; for my $l (@l) { read_fmtutil_file($l); } # in case the changes_config is a new one read it in and initialize it here + # the file might be already readable but not in ls-R so not found by + # kpsewhich. That means we need to check that it is readable and whether + # the lines entry is already defined my $cc = $alldata->{'changes_config'}; - if (! -r $cc) { + if ((! -r $cc) || (!$alldata->{'fmtutil'}{$cc}{'lines'}) ) { $alldata->{'fmtutil'}{$cc}{'lines'} = [ ]; } # @@ -946,6 +968,67 @@ sub determine_config_files { +# returns 1 if actually saved due to changes +sub save_fmtutil { + my $fn = shift; + return if $opts{'dry-run'}; + my %fmtf = %{$alldata->{'fmtutil'}{$fn}}; + if ($fmtf{'changed'}) { + TeXLive::TLUtils::mkdirhier(dirname($fn)); + open (FN, ">$fn") || die "$prg: can't write to $fn: $!"; + my @lines = @{$fmtf{'lines'}}; + if (!@lines) { + print "Creating new config file $fn\n"; + # update lsR database + $updLSR->add($fn); + $updLSR->exec(); + $updLSR->reset(); + } + # collect the lines with data + my %line_to_fmt; + my @add_fmt; + if (defined($fmtf{'formats'})) { + for my $f (keys %{$fmtf{'formats'}}) { + for my $e (keys %{$fmtf{'formats'}{$f}}) { + if ($fmtf{'formats'}{$f}{$e}{'line'} == -1) { + push @add_fmt, [ $f, $e ]; + } else { + $line_to_fmt{$fmtf{'formats'}{$f}{$e}{'line'}} = [ $f, $e ]; + } + } + } + } + for my $i (0..$#lines) { + if (defined($line_to_fmt{$i})) { + my $f = $line_to_fmt{$i}->[0]; + my $e = $line_to_fmt{$i}->[1]; + my $mode = $fmtf{'formats'}{$f}{$e}{'status'}; + my $args = $fmtf{'formats'}{$f}{$e}{'args'}; + my $hyph = $fmtf{'formats'}{$f}{$e}{'hyphen'}; + my $p = ($mode eq 'disabled' ? "#! " : ""); + print FN "$p$f $e $hyph $args\n"; + } else { + print FN "$lines[$i]\n"; + } + } + # add the new settings and maps + for my $m (@add_fmt) { + my $f = $m->[0]; + my $e = $m->[1]; + my $mode = $fmtf{'formats'}{$f}{$e}{'status'}; + my $args = $fmtf{'formats'}{$f}{$e}{'args'}; + my $hyph = $fmtf{'formats'}{$f}{$e}{'hyphen'}; + my $p = ($mode eq 'disabled' ? "#! " : ""); + print FN "$p$f $e $hyph $args\n"; + } + close(FN) || warn("$prg: Cannot close file handle for $fn: $!"); + delete $alldata->{'fmtutil'}{$fn}{'changed'}; + return 1; + } + return 0; +} + + # # $HOME and sudo and updmap-sys horror # some instances of sudo do not reset $HOME to the home of root diff --git a/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl b/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl index 11741c5e5d8..76746e25f05 100755 --- a/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl +++ b/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl @@ -1,13 +1,13 @@ #!/usr/bin/env perl -# $Id: tlmgr.pl 37488 2015-05-23 17:58:40Z karl $ +# $Id: tlmgr.pl 37523 2015-06-14 13:37:20Z preining $ # # Copyright 2008-2015 Norbert Preining # This file is licensed under the GNU General Public License version 2 # or any later version. # -my $svnrev = '$Revision: 37488 $'; -my $datrev = '$Date: 2015-05-23 19:58:40 +0200 (Sat, 23 May 2015) $'; +my $svnrev = '$Revision: 37523 $'; +my $datrev = '$Date: 2015-06-14 15:37:20 +0200 (Sun, 14 Jun 2015) $'; my $tlmgrrevision; my $prg; if ($svnrev =~ m/: ([0-9]+) /) { @@ -1553,6 +1553,10 @@ sub action_info { if $tlp->cataloguedata->{'date'}; print "cat-license: ", $tlp->cataloguedata->{'license'}, "\n" if $tlp->cataloguedata->{'license'}; + print "cat-topics: ", $tlp->cataloguedata->{'topics'}, "\n" + if $tlp->cataloguedata->{'topics'}; + print "cat-related: ", $tlp->cataloguedata->{'also'}, "\n" + if $tlp->cataloguedata->{'also'}; print "collection: ", @colls, "\n" if (@colls); if ($opts{"list"}) { if ($tlp->category eq "Collection" || $tlp->category eq "Scheme") { @@ -1685,6 +1689,7 @@ sub search_pkg_desc { my $t = "$pkg\n"; $t = $t . $tlp->shortdesc . "\n" if (defined($tlp->shortdesc)); $t = $t . $tlp->longdesc . "\n" if (defined($tlp->longdesc)); + $t = $t . $tlp->cataloguedata->{'topics'} . "\n" if (defined($tlp->cataloguedata->{'topics'})); my $pat = $what; $pat = '\W' . $what . '\W' if ($inword); my $matched = ""; diff --git a/Master/texmf-dist/doc/latex/ptex2pdf/README b/Master/texmf-dist/doc/latex/ptex2pdf/README index d4a03097974..55b96e1c5ea 100644 --- a/Master/texmf-dist/doc/latex/ptex2pdf/README +++ b/Master/texmf-dist/doc/latex/ptex2pdf/README @@ -1,164 +1,159 @@ +# ptex2pdf[.lua] # - -PTEX2PDF[.LUA] - - -AUTHOR: Norbert Preining -WEBSITE: http://www.preining.info/blog/software-projects/ptex2pdf/ (in Japanese) -LICENSE: GPLv2 +**Author:** Norbert Preining +**Website:** http://www.preining.info/blog/software-projects/ptex2pdf/ (in Japanese) +**License:** GPLv2 Convert Japanese TeX documents to pdf - -Description +## Description ## Main purpose of the script is easy support of Japanese typesetting engines in TeXworks. As TeXworks typesetting setup does not allow for multistep processing, this script runs one of the ptex based programs (ptex, uptex, eptex, platex, uplatex) followed by dvipdfmx. +## Usage ## -Usage - - [texlua] ptex2pdf[.lua] { option | basename[.tex] } ... - options: -v version - -h help - --help print full help (installation, TeXworks setup) - -e use eptex class of programs - -u use uptex class of programs - -l use latex based formats - -s stop at dvi - -i retain intermediate files - -ot '<opts>' extra options for TeX - -od '<opts>' extra options for dvipdfmx - +````` +[texlua] ptex2pdf[.lua] { option | basename[.tex] } ... +options: -v version + -h help + --help print full help (installation, TeXworks setup) + -e use eptex class of programs + -u use uptex class of programs + -l use latex based formats + -s stop at dvi + -i retain intermediate files + -ot '<opts>' extra options for TeX + -od '<opts>' extra options for dvipdfmx +````` -Installation +## Installation ## Copy the file ptex2pdf.lua into a directory where scripts are found, that is for example -TLROOT/texmf-dist/scripts/ptex2pdf/ + `TLROOT/texmf-dist/scripts/ptex2pdf/` -(where TLROOT is for example the root of your TeX Live installation) +(where `TLROOT` is for example the root of your TeX Live installation) -Unix +### Unix ### create a link in one of the bin dirs to the above file, in the TeX Live case: -TLROOT/bin/ARCH/ptex2pdf -> ../../texmf-dist/scripts/ptex2pdf/ptex2pdf.lua - -Windows + `TLROOT/bin/ARCH/ptex2pdf -> ../../texmf-dist/scripts/ptex2pdf/ptex2pdf.lua` +### Windows ### create a copy of runscript.exe as ptex2pdf.exe, in the TeX Live case: -copy TLROOT/bin/win32/runscript.exe TLROOT/bin/win32/ptex2pdf.exe - + `copy TLROOT/bin/win32/runscript.exe TLROOT/bin/win32/ptex2pdf.exe` -TeXworks setup +## TeXworks setup ## Under Preferences > Typesetting add new entries, for example: for ptex files: - Setting Value - ------------ ---------------- - Name: pTeX to pdf - Program: ptex2pdf - Arguments: -ot - $synctexoption - $fullname +| Setting | Value | +|-------------|------------------| +| Name: | pTeX to pdf | +| Program: | ptex2pdf | +| Arguments: | -ot | +| | $synctexoption | +| | $fullname | + for platex files: - Setting Value - ------------ ---------------- - Name: pLaTeX to pdf - Program: ptex2pdf - Arguments: -l - -ot - $synctexoption - $fullname +| Setting | Value | +|-------------|----------------| +| Name: | pLaTeX to pdf | +| Program: | ptex2pdf | +| Arguments: | -l | +| | -ot | +| | $synctexoption | +| | $fullname | for uptex files: - Setting Value - ------------ ---------------- - Name: upTeX to pdf - Program: ptex2pdf - Arguments: -u - -ot - $synctexoption - $fullname +| Setting | Value | +|-------------|----------------| +| Name: | upTeX to pdf | +| Program: | ptex2pdf | +| Arguments: | -u | +| | -ot | +| | $synctexoption | +| | $fullname | for uplatex files: - Setting Value - ------------ ---------------- - Name: upLaTeX to pdf - Program: ptex2pdf - Arguments: -l - -u - -ot - $synctexoption - $fullname +| Setting | Value | +|-------------|----------------| +| Name: | upLaTeX to pdf | +| Program: | ptex2pdf | +| Arguments: | -l | +| | -u | +| | -ot | +| | $synctexoption | +| | $fullname | If you need special kanji encodings for one of these programs, -add the respective -kanji option after the $synctexoption. Example: +add the respective `-kanji` option after the `$synctexoption`. Example: for platex files in SJIS encoding: - Setting Value - ------------ ---------------------------- - Name: pLaTeX/SJIS to pdf - Program: ptex2pdf - Arguments: -l - -ot - $synctexoption -kanji=sjis - $fullname +| Setting | Value | +|-------------|-----------------------------| +| Name: | pLaTeX/SJIS to pdf | +| Program: | ptex2pdf | +| Arguments: | -l | +| | -ot | +| | $synctexoption -kanji=sjis | +| | $fullname | -Development place +## Development place ## http://github.com/norbusan/ptex2pdf - -Changelog - -- version 0.1 2013-03-08 NP - Initial release on blog -- version 0.2 2013-03-10 NP - import into git repository - support passing options on to tex and dvipdfm - add README with TeXworks config options -- version 0.3 2013-05-01 NP - include the readme in the lua code - fix program name for -e -u -- version 0.4 2013-05-07 NP - quote the filename with ", so that special chars do survive - add an example for TeXworks for files with different kanji encoding -- version 0.5 2014-11-05 NP - on Windows: set command_line_encoding to utf8 when running uptex - (patch by Akira Kakuto) -- version 0.6 2015-03-08 NP - cygwin didn't like the (accidentally inserted) spaces after the - texlua in the shebang line, and stopped working with - "no such program: "texlua " ..." -- version 0.7dev 2015-XX-XX - move to github as gitorious will be closed, adapt help output - to generate github flavored markdown - check for files using kpathsea instead of opening directly, to allow - for input of files found by kpathsea (closes github issue 1) - - -Copyright and License +## Changelog ## + +- version 0.1 2013-03-08 NP + Initial release on blog +- version 0.2 2013-03-10 NP + import into git repository + support passing options on to tex and dvipdfm + add README with TeXworks config options +- version 0.3 2013-05-01 NP + include the readme in the lua code + fix program name for -e -u +- version 0.4 2013-05-07 NP + quote the filename with ", so that special chars do survive + add an example for TeXworks for files with different kanji encoding +- version 0.5 2014-11-05 NP + on Windows: set command_line_encoding to utf8 when running uptex + (patch by Akira Kakuto) +- version 0.6 2015-03-08 NP + cygwin didn't like the (accidentally inserted) spaces after the + texlua in the shebang line, and stopped working with + "no such program: "texlua " ..." +- version 0.7 2015-04-29 + move to github as gitorious will be closed, adapt help output + to generate github flavored markdown + check for files using kpathsea instead of opening directly, to allow + for input of files found by kpathsea (closes github issue 1) +- version 0.8 2015-06-15 + file name checks: first search for arg as is, then try .tex and .ltx + (closes github issue: 3) + +## Copyright and License ## Originally based on musixtex.lua from Bob Tennent. -(c) Copyright 2012 Bob Tennent rdt@cs.queensu.ca - -(c) Copyright 2013-2015 Norbert Preining norbert@preining.info +(c) Copyright 2012 Bob Tennent rdt@cs.queensu.ca +(c) Copyright 2013-2015 Norbert Preining norbert@preining.info This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -173,3 +168,4 @@ Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + diff --git a/Master/texmf-dist/doc/latex/ptex2pdf/README.md b/Master/texmf-dist/doc/latex/ptex2pdf/README.md deleted file mode 100644 index 55be29284de..00000000000 --- a/Master/texmf-dist/doc/latex/ptex2pdf/README.md +++ /dev/null @@ -1,168 +0,0 @@ -# ptex2pdf[.lua] # - -**Author:** Norbert Preining -**Website:** http://www.preining.info/blog/software-projects/ptex2pdf/ (in Japanese) -**License:** GPLv2 - -Convert Japanese TeX documents to pdf - -## Description ## - -Main purpose of the script is easy support of Japanese typesetting -engines in TeXworks. As TeXworks typesetting setup does not allow -for multistep processing, this script runs one of the ptex based -programs (ptex, uptex, eptex, platex, uplatex) followed by dvipdfmx. - -## Usage ## - -````` -[texlua] ptex2pdf[.lua] { option | basename[.tex] } ... -options: -v version - -h help - --help print full help (installation, TeXworks setup) - -e use eptex class of programs - -u use uptex class of programs - -l use latex based formats - -s stop at dvi - -i retain intermediate files - -ot '<opts>' extra options for TeX - -od '<opts>' extra options for dvipdfmx -````` - -## Installation ## - -Copy the file ptex2pdf.lua into a directory where scripts are found, -that is for example - - `TLROOT/texmf-dist/scripts/ptex2pdf/` - -(where `TLROOT` is for example the root of your TeX Live installation) - -### Unix ### - -create a link in one of the bin dirs to the above file, in the -TeX Live case: - - `TLROOT/bin/ARCH/ptex2pdf -> ../../texmf-dist/scripts/ptex2pdf/ptex2pdf.lua` - -### Windows ### -create a copy of runscript.exe as ptex2pdf.exe, in the TeX Live case: - - `copy TLROOT/bin/win32/runscript.exe TLROOT/bin/win32/ptex2pdf.exe` - -## TeXworks setup ## - -Under Preferences > Typesetting add new entries, for example: - -for ptex files: - -| Setting | Value | -|-------------|------------------| -| Name: | pTeX to pdf | -| Program: | ptex2pdf | -| Arguments: | -ot | -| | $synctexoption | -| | $fullname | - - -for platex files: - -| Setting | Value | -|-------------|----------------| -| Name: | pLaTeX to pdf | -| Program: | ptex2pdf | -| Arguments: | -l | -| | -ot | -| | $synctexoption | -| | $fullname | - -for uptex files: - -| Setting | Value | -|-------------|----------------| -| Name: | upTeX to pdf | -| Program: | ptex2pdf | -| Arguments: | -u | -| | -ot | -| | $synctexoption | -| | $fullname | - -for uplatex files: - -| Setting | Value | -|-------------|----------------| -| Name: | upLaTeX to pdf | -| Program: | ptex2pdf | -| Arguments: | -l | -| | -u | -| | -ot | -| | $synctexoption | -| | $fullname | - -If you need special kanji encodings for one of these programs, -add the respective `-kanji` option after the `$synctexoption`. Example: - -for platex files in SJIS encoding: - -| Setting | Value | -|-------------|-----------------------------| -| Name: | pLaTeX/SJIS to pdf | -| Program: | ptex2pdf | -| Arguments: | -l | -| | -ot | -| | $synctexoption -kanji=sjis | -| | $fullname | - - -## Development place ## - -http://github.com/norbusan/ptex2pdf - -## Changelog ## - -- version 0.1 2013-03-08 NP - Initial release on blog -- version 0.2 2013-03-10 NP - import into git repository - support passing options on to tex and dvipdfm - add README with TeXworks config options -- version 0.3 2013-05-01 NP - include the readme in the lua code - fix program name for -e -u -- version 0.4 2013-05-07 NP - quote the filename with ", so that special chars do survive - add an example for TeXworks for files with different kanji encoding -- version 0.5 2014-11-05 NP - on Windows: set command_line_encoding to utf8 when running uptex - (patch by Akira Kakuto) -- version 0.6 2015-03-08 NP - cygwin didn't like the (accidentally inserted) spaces after the - texlua in the shebang line, and stopped working with - "no such program: "texlua " ..." -- version 0.7dev 2015-XX-XX - move to github as gitorious will be closed, adapt help output - to generate github flavored markdown - check for files using kpathsea instead of opening directly, to allow - for input of files found by kpathsea (closes github issue 1) - -## Copyright and License ## - -Originally based on musixtex.lua from Bob Tennent. - -(c) Copyright 2012 Bob Tennent rdt@cs.queensu.ca -(c) Copyright 2013-2015 Norbert Preining norbert@preining.info - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - diff --git a/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua b/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua index f6e4fc0fbb6..3b0c5b5d62b 100755 --- a/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua +++ b/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua @@ -1,7 +1,7 @@ #!/usr/bin/env texlua NAME = "ptex2pdf[.lua]" -VERSION = "0.7" +VERSION = "0.8" AUTHOR = "Norbert Preining" AUTHOREMAIL = "norbert@preining.info" SHORTDESC = "Convert Japanese TeX documents to pdf" @@ -152,11 +152,14 @@ CHANGELOG = [[ cygwin didn't like the (accidentally inserted) spaces after the texlua in the shebang line, and stopped working with "no such program: "texlua " ..." -- version 0.7dev 2015-XX-XX +- version 0.7 2015-04-29 move to github as gitorious will be closed, adapt help output to generate github flavored markdown check for files using kpathsea instead of opening directly, to allow for input of files found by kpathsea (closes github issue 1) +- version 0.8 2015-06-15 + file name checks: first search for arg as is, then try .tex and .ltx + (closes github issue: 3) ]] @@ -247,6 +250,7 @@ use_eptex = 0 use_uptex = 0 use_latex = 0 filename = "" +bname = "" exit_code = 0 narg = 1 repeat @@ -323,46 +327,64 @@ end -- initialize kpse kpse.set_program_name(tex) -if filename ~= "" and string.sub(filename, -4, -1) == ".tex" then - filename = string.sub(filename, 1, -5) +-- filename searching +-- first search for the file as is, +-- if not found, try file .tex, if that not found, file .ltx + +if ( filename == "" ) then + print("No filename argument given, exiting.") + os.exit(1) +else + if ( kpse.find_file(filename) == nil ) then + -- try .tex extension + if ( kpse.find_file(filename .. ".tex") == nil ) then + -- last try .ltx + if ( kpse.find_file(filename .. ".ltx") == nil ) then + print("File cannot be found with kpathsea: ", filename .. "[.tex, .ltx]") + os.exit(1) + else + bname = filename + filename = filename .. ".ltx" + end + else + bname = filename + filename = filename .. ".tex" + end + else + -- if it has already an extension, we need to drop it to get the dvi name + bname = string.gsub(filename, "^(.*)%.[^.]+$", "%1") + end end --- if not io.open(filename .. ".tex", "r") then --- print("Non-existent file: ", filename .. ".tex") --- exit_code = 1 -if ( kpse.find_file(filename .. ".tex") == nil ) then - print("File cannot be found with kpathsea: ", filename .. ".tex") - exit_code = 1 -else - -- make sure that on Windows/uptex we are using utf8 as command line encoding - if use_uptex == 1 then - if os.type == 'windows' then - os.setenv('command_line_encoding', 'utf8') - end +-- we are still here, so we found a file +-- make sure that on Windows/uptex we are using utf8 as command line encoding +if use_uptex == 1 then + if os.type == 'windows' then + os.setenv('command_line_encoding', 'utf8') end - print("Processing ".. filename .. ".tex.") - if (os.execute(tex .. " " .. texopts .. " \"" .. filename .. "\"") == 0) and - (dvipdf == "" or (os.execute(dvipdf .. " " .. dvipdfopts .. " \"" .. filename .. "\"") == 0)) - then - if dvipdf ~= "" then - print(filename .. ".pdf generated by " .. dvipdf .. ".") - end - if intermediate == 1 then -- clean-up: - if dvipdf ~= "" then - os.remove( filename .. ".dvi" ) - end - end - else - print("ptex2pdf processing of " .. filename .. ".tex fails.\n") - exit_code = 2 - --[[ uncomment for debugging - print("tex = ", tex) - print("dvipdf = ", dvipdf) - --]] +end +print("Processing ".. filename) +if (os.execute(tex .. " " .. texopts .. " \"" .. filename .. "\"") == 0) and + (dvipdf == "" or (os.execute(dvipdf .. " " .. dvipdfopts .. " \"" .. bname .. ".dvi" .. "\"") == 0)) then + if dvipdf ~= "" then + print(bname .. ".pdf generated by " .. dvipdf .. ".") + end + if intermediate == 1 then -- clean-up: + if dvipdf ~= "" then + os.remove( bname .. ".dvi" ) end -end --if not io.open ... + end +else + print("ptex2pdf processing of " .. filename .. " failed.\n") + --[[ uncomment for debugging + print("tex = ", tex) + print("dvipdf = ", dvipdf) + --]] + os.exit(2) +end -os.exit( exit_code ) +-- all done ... exit with success +os.exit( 0 ) |