Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.0:Staging:E
texlive
source-missed-scripts.dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File source-missed-scripts.dif of Package texlive
--- texk/texlive/linked_scripts/diadia/diadia.lua | 298 ++++++ texk/texlive/linked_scripts/glossaries/makeglossaries-lite.lua | 471 ++++++++++ texk/texlive/linked_scripts/make4ht/make4ht | 62 + texk/texlive/linked_scripts/pdfbook2/pdfbook2 | 237 +++++ texk/texlive/linked_scripts/tex4ebook/tex4ebook | 154 +++ 5 files changed, 1222 insertions(+) --- texk/texlive/linked_scripts/diadia/diadia.lua +++ texk/texlive/linked_scripts/diadia/diadia.lua 2016-01-29 11:39:38.599088869 +0000 @@ -0,0 +1,298 @@ +#!/usr/bin/env texlua +-- +-- diadia [options] +-- +-- loads and processes a diadia data file +-- +-- License: LPPL +-- +local version = "v1.0 (2015/05/15)" + +local infile = "" +local outfile = "" +local mode = "*" +local startdate = "" +local enddate = "" +local columns = "" +local data = {} +function pversion() + print("diadia.lua " .. version) + print("(C) Josef Kleber 2015 License: LPPL") + os.exit(0) +end +function phelp() + print([[ +diadia.lua [options] + + allows you to + + - cut a chunk out of the data file + e.g.: -i in.dat -o out.dat -s YYYY-MM-DD -e YYYY-MM-DD + + - compose a new data file based on given columns of an + existing data file + e.g.: -i in.dat -o out.dat -c 1,2 + + - create a new data file with date and value (1st and + 2nd column of existing file) and added value average + columns of the last 7, 14, 30, 60 and 90 days + e.g.: -i in.dat -o out.dat [-s YYYY-MM-DD -e YYYY-MM-DD] + + Options: + + -m specify the mode (cut|compose|average) + + -i specify the input file + + -o specify the output file + + -c specify the columns for compose mode + + -s specify the start date (YYYY-MM-DD) in + cut and average mode + + -e specify the end date + + -v prints version information + + -h prints help information + +]]) + pversion() +end +function check_date(date) + if string.find(date, "(%d%d%d%d)-(%d%d)-(%d%d)") == nil + then + io.stderr:write ("Error 21: wrong date format (YYYY-MM-DD)\n") + os.exit(11) + end +end +function parse_date(date) + return string.match(date, "(%d%d%d%d)%-(%d%d)%-(%d%d)") +end +function parse_dateinline(line) + return string.match(line, "(%d%d%d%d%-%d%d%-%d%d)") +end +function daystring(unixtime) + return os.date("%Y-%m-%d", unixtime) +end +function unixtime(year,month,day) + return os.time{year=year, month=month, day=day} +end +function round(number) + return math.floor(number+0.5) +end +function ptd(value) + local val = tostring(value) + local slen = string.len(val) + if slen == 3 + then + return val + else + return val .. " " + end +end +function calc_avg(data,date,days) + local sum = 0 + local wdays = 0 + local wday + local endday = unixtime(parse_date(date)) + local startday = endday - 60*60*24*(days-1) + while startday <= endday + do + wday = daystring(startday) + if data[wday] ~= nil + then + sum = sum + data[wday] + wdays = wdays + 1 + end + startday = startday + 60*60*24 + end + if wdays == 0 + then + return "nan" + else + return tostring(round(sum/wdays)) + end +end +function read_data(file) + local data = {} + local date + local startdate + local enddate + local dat + local firstline = true + for line in io.lines(file) + do + if string.match(line, "date") + then + else + date, dat = string.match(line, "(%d%d%d%d%-%d%d%-%d%d)%s+(%S+)") + if firstline == true + then + startdate = date + firstline = false + end + if dat ~= "nan" and dat ~= "{}" and dat ~= "" + then + data[date] = dat + end + end + end + enddate = date + return data,startdate,enddate +end +function write_avg_file(data,file,startdate,enddate) + local sdate + local edate + local wday + sdate = unixtime(parse_date(startdate)) + edate = unixtime(parse_date(enddate)) + outfile = assert(io.open(file, "w")) + outfile:write("date value avg07 avg14 avg30 avg60 avg90") + while sdate <= edate+7200 + do + wday = daystring(sdate) + if data[wday] ~= nil + then + outfile:write("\n" .. wday .. " " + .. ptd(data[wday]) .. " " + .. ptd(calc_avg(data,wday,7)) .. " " + .. ptd(calc_avg(data,wday,14)) .. " " + .. ptd(calc_avg(data,wday,30)) .. " " + .. ptd(calc_avg(data,wday,60)) .. " " + .. ptd(calc_avg(data,wday,90))) + end + sdate = sdate + 60*60*24 + end + outfile:close() +end +do + local newarg = {} + local i, limit = 1, #arg + while (i <= limit) do + if arg[i] == "-i" then + infile = arg[i+1] + i = i + 1 + elseif arg[i] == "-o" then + outfile = arg[i+1] + i = i + 1 + elseif arg[i] == "-s" then + startdate = arg[i+1] + i = i + 1 + elseif arg[i] == "-e" then + enddate = arg[i+1] + i = i + 1 + elseif arg[i] == "-c" then + columns = arg[i+1] + i = i + 1 + elseif arg[i] == "-m" then + mode = arg[i+1] + i = i + 1 + elseif arg[i] == "-v" then + pversion() + elseif arg[i] == "-h" then + phelp() + else + newarg[#newarg+1] = arg[i] + end + i = i + 1 + end + arg = newarg +end +if mode == "average" +then + local startd + local endd + + print("set mode to " .. mode) + print("reading data file " .. infile) + data,startd,endd = read_data(infile) + if startdate ~= "" + then + startd = startdate + end + if enddate ~= "" + then + endd = enddate + end + print("writing data file " .. outfile) + write_avg_file(data,outfile,startd,endd) + os.exit(0) +end +if mode == "compose" +then + local row = 0 + local column = 0 + local ofile + local cols + + print("set mode to " .. mode) + print("reading data file " .. infile) + for line in io.lines(infile) + do + row = row + 1 + data[row] = {} + column = 0 + for value in string.gmatch(line, "%S+") + do + column = column + 1 + data[row][column] = value + end + end + cols = assert(load("return table.concat({"..columns:gsub("%d+","(...)[%0]").."},' ')")) + ofile = assert(io.open(outfile, "w")) + print("writing data file " .. outfile) + for irow = 1,row + do + if irow == row + then + ofile:write(cols(data[irow])) + else + ofile:write(cols(data[irow]).."\n") + end + end + ofile:close() + os.exit(0) +end +if mode == "cut" +then + local ofile + local date + local sdate + local edate + local cdate + + check_date(startdate) + check_date(enddate) + sdate = unixtime(parse_date(startdate)) + edate = unixtime(parse_date(enddate)) + print("set mode to " .. mode) + print("reading data file " .. infile) + print("writing data file " .. outfile) + ofile = assert(io.open(outfile, "w")) + for line in io.lines(infile) + do + if string.match(line, "date") + then + ofile:write(line) + else + date = parse_dateinline(line) + cdate = unixtime(parse_date(date)) + if cdate >= sdate and cdate <= edate + then + ofile:write("\n" .. line) + end + end + end + ofile:close() + os.exit(0) +end +if mode == "*" +then + io.stderr:write ("Error 11: no mode specified!") + os.exit(11) +else + io.stderr:write ("Error 12: invalid mode " .. mode) + os.exit(12) +end --- texk/texlive/linked_scripts/glossaries/makeglossaries-lite.lua +++ texk/texlive/linked_scripts/glossaries/makeglossaries-lite.lua 2016-01-29 12:25:37.115559979 +0000 @@ -0,0 +1,471 @@ +#!/usr/bin/env texlua +--[[ + File : makeglossaries.lua + Author : Nicola Talbot + + Lua alternative to the makeglossaries Perl script. + + Since Lua has limitations, this script isn't an exact + replacement to the Perl script. In particular the makeglossaries -d + switch isn't implemented in this Lua version. + This also doesn't provide the more detailed diagnostics that the Perl + version does nor does it attempt any language mappings. Since xindy + requires Perl, don't use this script if you want to use xindy. Instead + use the Perl makeglossaries script. + + This file is distributed as part of the glossaries LaTeX package. + Copyright 2015 Nicola L.C. Talbot + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either version 1.3 + of this license or any later version. + The latest version of this license is in + http://www.latex-project.org/lppl.txt + and version 1.3 or later is part of all distributions of LaTeX + version 2005/12/01 or later. + + This work has the LPPL maintenance status `maintained'. + + History: + * 1.1 changed first line from lua to texlua +--]] + +thisversion = "1.1 2015-07-17" + +quiet = false +dryrun = false + +infile = nil +outfile = nil +styfile = nil +logfile = nil + +isxindy = false + +xindylang = nil +xindyexec = "xindy" + +makeindex_c = false +makeindex_g = false +letterorder = false +makeindex_r = false +makeindex_p = nil +makeindex_m = "makeindex" + +function version() + print(string.format("makeglossaries.lua version %s", thisversion)) + print("Copyright (C) 2015 Nicola L C Talbot") + print("This material is subject to the LaTeX Project Public License.") +end + +function help() + version() + print([[ +Syntax : makeglossaries.lua [options] <filename> + +For use with the glossaries package to pass relevant +files to makeindex or xindy. + +<filename> Base name of glossary file(s). This should + be the name of your main LaTeX document without any + extension. If you do add an extension, only that + glossary file will be processed. + +General Options: + +-o <gls> Use <gls> as the output file. + (Don't use -o if you have more than one glossary.) +-s <sty> Employ <sty> as the style file. +-t <log> Employ <log> as the transcript file. + (Don't use -t if you have more than one glossary + or the transcripts will be overwritten.) +-q Quiet mode. +-l Letter ordering. +-n Print the command that would normally be executed, + but don't execute it (dry run). +--help Print this help message. +--version Print the version. + +Xindy Options: + +-L <language> Use <language>. +-x <file> Full path to xindy executable. + (Default assumes xindy is on the operating system's path.) + +Makeindex Options: +(See makeindex documentation for further details on these options.) + +-c Compress intermediate blanks. +-g Employ German word ordering. +-p <num> Set the starting page number to be <num>. +-r Disable implicit page range formation. +-m <file> Full path to makeindex executable. + (Default assumes makeindex is on the operating system's path.) + +This is a light-weight Lua alternative to the makeglossaries Perl script. +If you want to use xindy, it's better to use the Perl makeglossaries version +instead. +]]) +end + +function dorun(name, glg, gls, glo, language, codepage) + + if isxindy then + doxindy(name, glg, gls, glo, language, codepage) + else + domakeindex(name, glg, gls, glo) + end + +end + +function doxindy(name, glg, gls, glo, language, codepage) + + cmd = string.format('"%s" -I xindy -L %s -C %s -M "%s" -t "%s" -o "%s"', + xindyexec, language, codepage, styfile, glg, gls) + + if letterorder then cmd = string.format('%s -M ord/letorder', cmd) end + + if quiet then cmd = string.format('%s -q', cmd) end + + cmd = string.format('%s "%s"', cmd, glo) + + if dryrun then + + print(cmd) + + else + + assert(os.execute(cmd), + string.format("Failed to execute '%s'", cmd)) + + end + +end + +function domakeindex(name, glg, gls, glo) + + cmd = string.format('"%s"', makeindex_m) + + if makeindex_c then cmd = cmd .. " -c" end + + if makeindex_g then cmd = cmd .. " -g" end + + if letterorder then cmd = cmd .. " -l" end + + if quiet then cmd = cmd .. " -q" end + + if glg ~= nil then cmd = string.format('%s -t "%s"', cmd, glg) end + + if gls ~= nil then cmd = string.format('%s -o "%s"', cmd, gls) end + + if makeindex_p ~= nil then + cmd = string.format("%s -p %s", cmd, makeindex_p) + end + + if styfile ~= nil then + cmd = string.format('%s -s "%s"', cmd, styfile) + end + + cmd = string.format('%s "%s"', cmd, glo) + + if dryrun then + print(cmd) + else + assert(os.execute(cmd), + string.format("Failed to execute '%s'", cmd)) + end + +end + +if #arg < 1 +then + error("Syntax error: filename expected. Use --help for help.") +end + +i = 1 + +while i <= #arg do + +-- General Options + if arg[i] == "-q" then + quiet = true + elseif arg[i] == "-n" + then + dryrun = true + elseif arg[i] == "-o" + then + i = i + 1 + if i > #arg then error("-o requires a filename") end + outfile = arg[i] + elseif arg[i] == "-s" + then + i = i + 1 + if i > #arg then error("-s requires a filename") end + styfile = arg[i] + elseif arg[i] == "-t" + then + i = i + 1 + if i > #arg then error("-t requires a filename") end + logfile = arg[i] + elseif arg[i] == "--version" + then + version() + os.exit() + elseif arg[i] == "--help" + then + help() + os.exit() +-- General options for the Perl version that aren't implemented by +-- this light-weight version: + elseif (arg[i] == "-Q") or (arg[i] == "-k") + then + print(string.format("Ignoring option '%s' (only available with the Perl version).", arg[i])) + elseif arg[i] == "-d" + then + error(string.format( + "The '%s' option isn't available for this light-weight version.\nYou will need to use the Perl version instead.", + arg[i])) + +-- Xindy Options + elseif arg[i] == "-L" + then + i = i + 1 + if i > #arg then error("-L requires a language name") end + xindylang = arg[i] + elseif arg[i] == "-x" + then + i = i + 1 + if i > #arg then error("-x requires a filename") end + xindyexec = arg[i] + +-- Makeindex Options + elseif arg[i] == "-c" + then + makeindex_c = true + elseif arg[i] == "-g" + then + makeindex_g = true + elseif arg[i] == "-l" + then + letterorder = true + elseif arg[i] == "-r" + then + makeindex_r = true + elseif arg[i] == "-p" + then + i = i + 1 + if i > #arg then error("-p requires a page number") end + makeindex_p = arg[i] + elseif arg[i] == "-m" + then + i = i + 1 + if i > #arg then error("-m requires a filename") end + makeindex_m = arg[i] + +-- Unknown Option + elseif string.sub(arg[i], 1, 1) == "-" + then + error( + string.format("Syntax error: unknown option '%s'. Use '--help' for help.", + arg[i])); + +-- Input file + elseif infile == nil + then + infile = arg[i] + else + error("Syntax error: only one filename permitted"); + end + + i = i + 1 +end + +if not quiet then + print(string.format("makeglossaries.lua version %s", thisversion)) +end + +if infile == nil +then + error("Syntax error: missing filename") +end + +i, j = string.find(infile, "%.%a*$") + +ext = nil +inbase = infile + +if i ~= nil +then + ext = string.sub(infile, i, j); + + lext = string.lower(ext) + + inbase = string.sub(infile, 1, i-1); + + -- Just in case user has accidentally specified the aux or tex file + if lext == ".aux" or lext == ".tex" + then + ext = nil + infile = inbase + end +end + +auxfile = inbase..".aux" + +if not quiet then print(string.format("Parsing '%s'", auxfile)) end + +assert(io.input(auxfile), + string.format("Unable to open '%s'", auxfile)) + +aux = io.read("*a") + +if styfile == nil +then + styfile = string.match(aux, "\\@istfilename{\"?([^}]*%.?%a*)\"?}") + + if styfile == nil + then + error([[ +No \@istfilename found. +Did your LaTeX run fail? +Did your LaTeX run produce any output? +Did you remember to use \makeglossaries? + ]]) + end +end + +i = string.len(styfile) + +if string.sub(styfile, i-3, i) == ".xdy" +then + isxindy = true +end + +if not letterorder +then + if string.match(aux, "\\@glsorder{letter}") ~= nil + then + letterorder = true + end +end + +if dryrun then print("Dry run mode. No commands will be executed.") end + +onlyname = nil + +glossaries = {} + +for name, glg, gls, glo in + string.gmatch(aux, "\\@newglossary{([^}]+)}{([^}]+)}{([^}]+)}{([^}]+)}") do + + if not quiet then + print(string.format("Found glossary type '%s' (%s,%s,%s)", + name, glg, gls, glo)) + end + + glossaries[name] = {} + + glossaries[name].glg = glg + glossaries[name].gls = gls + glossaries[name].glo = glo + + if "."..glo == ext then + + onlyname = name + + end + + if isxindy then + + if xindylang == nil then + glossaries[name].language = string.match(aux, + "\\@xdylanguage{"..name.."}{([^}]+)}"); + else + glossaries[name].language = xindylang + end + + glossaries[name].codepage = string.match(aux, + "\\@gls@codepage{"..name.."}{([^}]+)}"); + + end + +end + + +if ext == nil +then + + done = false + + for name, value in pairs(glossaries) do + + glg = value.glg + gls = value.gls + glo = value.glo + + if logfile == nil then + glg = inbase .. "." .. glg + else + glg = logfile + end + + if outfile == nil then + gls = inbase .. "." .. gls + else + gls = outfile + end + + glo = infile .. "." .. glo + + dorun(name, glg, gls, glo, value.language, value.codepage) + + done = true + end + + if not done then + error([[ +No \@newglossary commands found in aux file. +Did you remember to use \makeglossaries? +Did you accidentally suppress the default glossary using "nomain" +and not provide an alternative glossary? +]]) + end + +else + + if onlyname == nil then + + glo = infile + gls = outfile + glg = logfile + + language = xindylang + codepage = 'utf8' + + if language == nil then language = 'english' end + + if gls == nil then gls = infile..".gls" end + + else + + value = glossaries[onlyname] + + glg = value.glg + gls = value.gls + glo = infile + + if logfile == nil then + glg = inbase .. "." .. glg + else + glg = logfile + end + + if outfile == nil then + gls = inbase .. "." .. gls + else + gls = outfile + end + + end + + dorun(onlyname, glg, gls, glo, language, codepage) +end --- texk/texlive/linked_scripts/make4ht/make4ht +++ texk/texlive/linked_scripts/make4ht/make4ht 2016-01-29 13:11:56.883615943 +0000 @@ -0,0 +1,62 @@ +#!/usr/bin/env texlua +kpse.set_program_name("luatex") + + +local make4ht = require("make4ht-lib") +local lapp = require("lapp-mk4") +local mkutils = require("mkutils") +local mkparams = require("mkparams") +-- args string is here just as sample, we dont pass it it to +-- mkparams.get_args() so default args string is used +local args = [[ +make4ht - build system for tex4ht +Usage: +make4ht [options] filename ["tex4ht.sty op." "tex4ht op." "t4ht op" "latex op"] +-c,--config (default xhtml) Custom config file +-d,--output-dir (default nil) Output directory +-l,--lua Use lualatex for document compilation +-s,--shell-escape Enables running external programs from LaTeX +-u,--utf8 For output documents in utf8 encoding +-x,--xetex Use xelatex for document compilation +<filename> (string) Input file name +]] + +local args = mkparams.get_args() + +local parameters = mkparams.process_args(args) + +local mode = parameters.mode +local build_file = parameters.build_file + +local make = mkutils.load_config(parameters, build_file)["Make"] +make.params = parameters +if make:length() < 1 then + if mode == "draft" then + make:htlatex() + else + make:htlatex() + make:htlatex() + make:htlatex() + end +end + + +if not args["no-tex4ht"] then + make:tex4ht() +end + +local ext = args.xetex and "xdv" or "dvi" +if #make.image_patterns > 0 then + make.params.t4ht_par = make.params.t4ht_par .. " -p" +end +make:t4ht {ext = ext} +make:match("tmp$", function() return false,"tmp file" end) +make:match(".*",function(filename,par) + local outdir = '' --par["outdir"] and par["outdir"] .."/" or '' + if par['outdir'] ~= "" then outdir = par['outdir'] .. '/' end + print("outdir: "..outdir) + local outfilename = outdir .. filename + mkutils.copy(filename,outfilename) + return true +end) +make:run() --- texk/texlive/linked_scripts/pdfbook2/pdfbook2 +++ texk/texlive/linked_scripts/pdfbook2/pdfbook2 2016-01-29 13:13:36.561613489 +0000 @@ -0,0 +1,237 @@ +#!/usr/bin/env python +""" pdfbook2 - transform pdf files to booklets + + 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 3 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, see <http://www.gnu.org/licenses/>. + """ + + +import sys +import subprocess +import os +from optparse import OptionParser, OptionGroup, HelpFormatter +import shutil + + +#=============================================================================== +# Create booklet for file $name +#=============================================================================== + +def booklify( name, opts ): + #------------------------------------------------------ Check if file exists + print "\nProcessing", name + if not os.path.isfile( name ): + print "SKIP: file not found." + return + print "Getting bounds...", + sys.stdout.flush() + + #---------------------------------------------------------- useful constants + bboxName = "%%HiResBoundingBox:" + tmpFile = ".crop-tmp.pdf" + + #------------------------------------------------- find min/max bounding box + if opts.crop: + p = subprocess.Popen( ["pdfcrop", "--verbose", + "--resolution", repr( opts.resolution ), + name, tmpFile], + stdout = subprocess.PIPE, + stderr = subprocess.PIPE ) + p.wait() + out, err = p.communicate() + if len( err ) != 0: + print err + print "\n\nABORT: Problem getting bounds" + sys.exit( 1 ) + lines = out.splitlines() + bboxes = [s[len( bboxName ) + 1:] for s in lines if s.startswith( bboxName )] + bounds = [[float( x ) for x in bbox.split()] for bbox in bboxes ] + minLOdd = min( [bound[0] for bound in bounds[::2] ] ) + maxROdd = max( [bound[2] for bound in bounds[::2] ] ) + minLEven = min( [bound[0] for bound in bounds[1::2] ] ) + maxREven = max( [bound[2] for bound in bounds[1::2] ] ) + minT = min( [bound[1] for bound in bounds ] ) + maxB = max( [bound[3] for bound in bounds ] ) + + widthOdd = maxROdd - minLOdd + widthEven = maxREven - minLEven + maxWidth = max( widthOdd, widthEven ) + minLOdd -= maxWidth - widthOdd + maxREven += maxWidth - widthEven + + print "done" + sys.stdout.flush() + + #--------------------------------------------- crop file to area of interest + print "cropping...", + sys.stdout.flush() + p = subprocess.Popen( ["pdfcrop", + "--bbox-odd", "{L} {T} {R} {B}".format( L = minLOdd - opts.innerMargin / 2, + T = minT - opts.topMargin, + R = maxROdd + opts.outerMargin, + B = maxB + opts.outerMargin ), + "--bbox-even", "{L} {T} {R} {B}".format( L = minLEven - opts.outerMargin, + T = minT - opts.topMargin, + R = maxREven + opts.innerMargin / 2, + B = maxB + opts.outerMargin ), + "--resolution", repr( opts.resolution ), + name, + tmpFile], + stdout = subprocess.PIPE, + stderr = subprocess.PIPE ) + p.wait() + out, err = p.communicate() + if len( err ) != 0: + print err + print "\n\nABORT: Problem with cropping" + sys.exit( 1 ) + print "done" + sys.stdout.flush() + else: + shutil.copy( name, tmpFile ) + + #-------------------------------------------------------- create the booklet + print "create booklet...", + sys.stdout.flush() + pdfJamCallList = [ "pdfjam", + "--booklet", "true", + "--landscape", + "--suffix", "book", + "--signature", repr( opts.signature ), + tmpFile ] + + # add option --paper to call + if opts.paper is not None: + pdfJamCallList.append( "--paper" ) + pdfJamCallList.append( opts.paper ) + + # add option --short-edge to call + if opts.shortedge: + # check if everyshi.sty exists as texlive recommends + p = subprocess.Popen( ["kpsewhich", "everyshi.sty"], + stdout = subprocess.PIPE, + stderr = subprocess.PIPE ) + p.wait() + out, err = p.communicate() + if len( out ) == 0: + print "\n\nABORT: The everyshi.sty latex package is needed for short-edge." + sys.exit( 1 ) + else: + pdfJamCallList.append( "--preamble" ) + pdfJamCallList.append( r"\usepackage{everyshi}\makeatletter\EveryShipout{\ifodd\c@page\pdfpageattr{/Rotate 180}\fi}\makeatother" ) + + # run call to pdfJam to make booklet + p = subprocess.Popen( pdfJamCallList, + stdout = subprocess.PIPE, + stderr = subprocess.PIPE ) + p.wait() + + #-------------------------------------------- move file and remove temp file + os.rename( tmpFile[:-4] + "-book.pdf", name[:-4] + "-book.pdf" ) + os.remove( tmpFile ) + print "done" + sys.stdout.flush() + + +#=============================================================================== +# Help formatter +#=============================================================================== + +class MyHelpFormatter ( HelpFormatter ): + """Format help with indented section bodies. + """ + + def __init__( self, + indent_increment = 4, + max_help_position = 16, + width = None, + short_first = 0 ): + HelpFormatter.__init__( + self, indent_increment, max_help_position, width, short_first ) + + def format_usage( self, usage ): + return ( "USAGE\n\n%*s%s\n" ) % ( self.indent_increment, "", usage ) + + def format_heading( self, heading ): + return "%*s%s\n\n" % ( self.current_indent, "", heading.upper() ) + + +#=============================================================================== +# main programm +#=============================================================================== + +if __name__ == "__main__": + #------------------------------------------------------------ useful strings + usageString = "Usage: %prog [options] file1 [file2 ...]" + versionString = """ + %prog v1.2 + (c) 2015 Johannes Neumann (http://www.neumannjo.de) + licensed under GPLv3 (http://www.gnu.org/licenses/gpl-3.0) + based on pdfbook by David Firth with help from Marco Pessotto\n""" + defaultString = " (default: %default)" + + #------------------------------------------------- create commandline parser + parser = OptionParser( usage = usageString, version = versionString, + formatter = MyHelpFormatter( indent_increment = 4 ) ) + + generalGroup = OptionGroup( parser, "General" ) + generalGroup.add_option( "-p", "--paper", dest = "paper", type = "str", action = "store", + metavar = "STR", + help = "Format of the output paper dimensions as latex keyword (e.g. a4paper, letterpaper, legalpaper, ...)" ) + generalGroup.add_option( "-s", "--short-edge", dest = "shortedge", action = "store_true", + help = "Format the booklet for short-edge double-sided printing", + default = False ) + generalGroup.add_option( "-n", "--no-crop", dest = "crop", action = "store_false", + help = "Prevent the cropping to the content area", + default = True ) + parser.add_option_group( generalGroup ) + + marginGroup = OptionGroup( parser, "Margins" ) + marginGroup.add_option( "-o", "--outer-margin", type = "int", default = 40, + dest = "outerMargin", action = "store", metavar = "INT", + help = "Defines the outer margin in the booklet" + defaultString ) + marginGroup.add_option( "-i", "--inner-margin", type = "int", default = 150, + dest = "innerMargin", action = "store", metavar = "INT", + help = "Defines the inner margin between the pages in the booklet" + defaultString ) + marginGroup.add_option( "-t", "--top-margin", type = "int", default = 30, + dest = "topMargin", action = "store", metavar = "INT", + help = "Defines the top margin in the booklet" + defaultString ) + marginGroup.add_option( "-b", "--bottom-margin", type = "int", default = 30, metavar = "INT", + dest = "bottomMargin", action = "store", + help = "Defines the bottom margin in the booklet" + defaultString ) + parser.add_option_group( marginGroup ) + + advancedGroup = OptionGroup( parser, "Advanced" ) + advancedGroup.add_option( "--signature", dest = "signature", action = "store", type = "int", + help = "Define the signature for the booklet handed to pdfjam, needs to be multiple of 4" + defaultString, + default = 4, metavar = "INT" ) + advancedGroup.add_option( "--signature*", dest = "signature", action = "store", type = "int", + help = "Same as --signature", metavar = "INT" ) + advancedGroup.add_option( "--resolution", dest = "resolution", action = "store", type = "int", + help = "Resolution used by ghostscript in bp" + defaultString, + metavar = "INT", default = 72 ) + parser.add_option_group( advancedGroup ) + + opts, args = parser.parse_args() + + #------------------------------------ show help if started without arguments + if len( args ) == 0: + parser.print_version() + parser.print_help() + print "" + sys.exit( 2 ) + + #------------------------------------------- run for each provided file name + parser.print_version() + for arg in args: + booklify( arg, opts ) --- texk/texlive/linked_scripts/tex4ebook/tex4ebook +++ texk/texlive/linked_scripts/tex4ebook/tex4ebook 2016-01-29 13:15:14.519645559 +0000 @@ -0,0 +1,154 @@ +#!/usr/bin/env texlua +kpse.set_program_name("luatex") +require("lapp-mk4") +-- require("ebookutils") +local ebookutils = require "mkutils" + +-- Setting +local latex_cmd="latex" +local copy_cmd="copy" +local move_cmd="move" +local env_param="%%" +local htlatex_call="" +-- These correspond to htlatex parameters +local tex4ht_sty_par="" +local tex4ht_par="" +local t4ht_par="" +local latex_par="" +local output_formats={epub=true,mobi=true,epub3=true} +local executor=nil +local tidy = false +local include_fonts = false +local arg_message = [[ +tex4ebook - ebook generation support for LaTeX +Usage: +tex4ebook [switches] inputfile ["tex4ht.sty op." "tex4ht op." "t4ht op" "latex op"] +-c,--config (default xhtml) Custom config file +-e,--build-file (default nil) If build file is different than `filename`.mk4 +-f,--format (default epub) Output format. Supported values: epub, epub3, mobi +-l,--lua Runs htlualatex instead of htlatex +-m,--mode (default default) Switch which can be used in the makefile +-r,--resolution (default 167) +-s,--shell-escape Enable shell escape in htlatex run +-t,--tidy Run html tidy on html output. May result in wrong spacing! +]] + +-- This option is no longer available, all files must be unicode +-- -u,--utf8 +local args=lapp(arg_message) + +if args[1] == nil then + print(arg_message) + return +else + input_file=args[1] +end + +if args.lua then + print("Mame lua") + latex_cmd="dvilualatex" +end + +--if args.utf8 then +tex4ht_sty_par=tex4ht_sty_par .. ", charset=utf-8" +tex4ht_par=tex4ht_par .. " -cmozhtf -utf8" +--end + +if args["shell-escape"] then + latex_par = latex_par .. " -shell-escape" +end + +if args["include-fonts"] then + include_fonts = true +end + +-- local mathml = "," +-- if args["mathml"] then +-- -- mathml = ",mathml," +-- tex4ht_sty_par = tex4ht_sty_par .. ",mathml" +-- end +local mode = args.mode or "default" + +if os.type=="unix" then + env_param="$" + copy_cmd="cp" + move_cmd="mv" + t4ht_dir_format="%s/" +else + env_param="%%" + copy_cmd="copy" + move_cmd="move" + t4ht_dir_format="%s" +end + +if args.tidy then + tidy = true +else + tidy = false +end +-- Env file copying + +--[[if not ebookutils.file_exists("tex4ht.env") then +local env_file = kpse.find_file("epub2.env") +ebookutils.copy_filter(env_file,"tex4ht.env",function(s) return s % { +move = move_cmd, +copy = copy_cmd, +resolution = args.resolution +} end) +end--]] + +--print ("nazdar ${world}" % {world="svete"}) +--print(args.config) + +local input = ebookutils.remove_extension(input_file) +local config=ebookutils.remove_extension(args.config) +local tex4ht_sty_par = config ..tex4ht_sty_par..","+args.format +--local sty_args = args[2] and ", " .. args[2] or "" +local sty_args = "" +if args[2] then + sty_args = "," .. args[2] +end +local tex4ht_sty_par = tex4ht_sty_par + sty_args --args[2] +local tex4ht_par = tex4ht_par +args[3] +local t4ht_par = t4ht_par + args[4] +local latex_par = latex_par + args[5] +local params = { + htlatex=latex_cmd + ,input=input + ,format=args.format + ,latex_par=latex_par + ,tex4ht_sty_par=tex4ht_sty_par + ,tex4ht_par=tex4ht_par + ,t4ht_par=t4ht_par + ,mode = mode + ,t4ht_dir_format=t4ht_dir_format + ,tidy = tidy + ,include_fonts = include_fonts + ,resolution=args.resolution + ,mathml=mathml + ,packages="\\RequirePackage{tex4ebook}" +} + +if output_formats[args.format] then + executor=require("exec_"..args.format) + params=executor.prepare(params) +else + print("Unknown output format: "..args.format) + return +end + +local build_file = input.. ".mk4" + +if args["build-file"] and args["build-file"] ~= "nil" then + build_file = args["build-file"] +end + +local config_file = ebookutils.load_config(nil, build_file) + +params["config_file"] = config_file +--config_file.Make:run() +print("${htlatex} ${input} \"${tex4ht_sty_par}\" \"${tex4ht_par}\" \"${t4ht_par}\" \"${latex_par}\"" % params) +executor.run(input,params) +executor.writeContainer() +executor.clean() +--print(args[1])
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor