From ac83f550108c37b64954f1a4d6a3e6e29071ed66 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 29 Apr 2015 13:31:29 +0000 Subject: update ptex2pdf to latest release git-svn-id: svn://tug.org/texlive/trunk@37116 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua | 213 ++++++++++++++++-------- 1 file changed, 144 insertions(+), 69 deletions(-) (limited to 'Master/texmf-dist/scripts') diff --git a/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua b/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua index 5b08fa0cc47..f6e4fc0fbb6 100755 --- a/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua +++ b/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua @@ -1,9 +1,10 @@ #!/usr/bin/env texlua NAME = "ptex2pdf[.lua]" -VERSION = "0.6" -AUTHOR = "Norbert Preining " -SHORTDESC = NAME .. ": Convert Japanese TeX documents to pdf" +VERSION = "0.7" +AUTHOR = "Norbert Preining" +AUTHOREMAIL = "norbert@preining.info" +SHORTDESC = "Convert Japanese TeX documents to pdf" LONGDESC = [[ Main purpose of the script is easy support of Japanese typesetting engines in TeXworks. As TeXworks typesetting setup does not allow @@ -11,7 +12,7 @@ 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] } ... +[texlua] ptex2pdf[.lua] { option | basename[.tex] } ... options: -v version -h help --help print full help (installation, TeXworks setup) @@ -21,14 +22,13 @@ options: -v version -s stop at dvi -i retain intermediate files -ot '' extra options for TeX - -od '' extra options for dvipdfmx -]] + -od '' extra options for dvipdfmx]] LICENSECOPYRIGHT = [[ 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 @@ -48,87 +48,115 @@ with this program; if not, write to the Free Software Foundation, Inc., 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: + `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: + `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 = [[ Under Preferences > Typesetting add new entries, for example: for ptex files: - 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: - 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: - 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: - 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: - 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 | ]] -DEVELPLACE = "https://git.gitorious.org/tlptexlive/ptex2pdf.git" + +DEVELPLACE = "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.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) ]] @@ -136,9 +164,46 @@ function usage() print(USAGE) end -function help() +function makereadme() + print("# " .. NAME .. " #") + print() + print("**Author:** " .. AUTHOR .. " ") + print("**Website:** http://www.preining.info/blog/software-projects/ptex2pdf/ (in Japanese) ") + print("**License:** GPLv2") + print() print(SHORTDESC) print() + print("## Description ##") + print() + print(LONGDESC) + print("## Usage ##") + print() + print("`````") + print(USAGE) + print("`````") + print() + print("## Installation ##") + print() + print(INSTALLATION) + print("## TeXworks setup ##") + print() + print(TEXWORKS) + print() + print("## Development place ##") + print() + print(DEVELPLACE) + print() + print("## Changelog ##") + print() + print(CHANGELOG) + print("## Copyright and License ##") + print() + print(LICENSECOPYRIGHT) +end + +function help() + print(NAME .. ": " .. SHORTDESC) + print() print("Author: " .. AUTHOR) print() print(LONGDESC) @@ -189,6 +254,9 @@ repeat if this_arg == "-v" then whoami() os.exit(0) + elseif this_arg == "--readme" then + makereadme() + os.exit(0) elseif this_arg == "--print-version" then print(VERSION) os.exit(0) @@ -252,12 +320,19 @@ else end end +-- initialize kpse +kpse.set_program_name(tex) + if filename ~= "" and string.sub(filename, -4, -1) == ".tex" then filename = string.sub(filename, 1, -5) end -if not io.open(filename .. ".tex", "r") then - print("Non-existent file: ", filename .. ".tex") - exit_code = 1 + +-- 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 -- cgit v1.2.3