diff options
author | Karl Berry <karl@freefriends.org> | 2015-06-16 21:19:33 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-06-16 21:19:33 +0000 |
commit | aabaf017d9f80254268cc35b62b781ad9dc598f6 (patch) | |
tree | 9e653c8221bdaf1f729803854928f01bcce99f5b /Master | |
parent | 42f448fd67c0906edfb3bf8ad7c7a6e336e31da0 (diff) |
ptex2pdf (16jun15)
git-svn-id: svn://tug.org/texlive/trunk@37566 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-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 |
3 files changed, 163 insertions, 313 deletions
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 ) |