diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/rake4latex |
Initial commit
Diffstat (limited to 'support/rake4latex')
-rw-r--r-- | support/rake4latex/README | 40 | ||||
-rw-r--r-- | support/rake4latex/call_rake4latex.rb | 180 | ||||
-rw-r--r-- | support/rake4latex/readme_call_rake4latex.txt | 26 |
3 files changed, 246 insertions, 0 deletions
diff --git a/support/rake4latex/README b/support/rake4latex/README new file mode 100644 index 0000000000..f864a803c8 --- /dev/null +++ b/support/rake4latex/README @@ -0,0 +1,40 @@ +Call_rake4latex offers an easy-use interface to the rake4latex-gem. + +rake4latex calls LaTeX as often as needed, including necessary makeindex and bibtex-calls. +rake4latex offers the possibilities of a make-tool. + +rake4latex is available at http://gemcutter.org/gems/rake4latex + +Call_rake4latex is available in two versions: + +Call_rake4latex.rb: +Ruby-script, needs Ruby, Rake and the rake4latex-gem. + +Call_rake4latex.exe: +Windows executable. +Usage: call_rake4latex.rb [options] filename +Call LaTeX as often as needed. + +Examples: +call_rake4latex testdocument.pdf + Create testdocument.pdf via pdflatex + Starts only if testdocument.tex is newer then testdocument.pdf. + +call_rake4latex -e testdocument + Touch 'testdocument.tex' (set the modification date) + Create testdocument.pdf via pdflatex + +Specific options: + -e, --enforce Enforce an initial TeX-run + -f, --format FORMAT Set the format for TeX-run (pdflatex, xelatex, lualatex) + --dep, --dependecies Build dependecies (rakefile recommended) + -i, --ignore, --ignore-error Allow LaTeX errors + -s, --statistic Show the statistic after TeX-run + -o, --overview Create a log-overview file + -c, --clean Clean after TeX-run (delete auxiliary files) + --touch FILE Touch FILE + --task TASK Define a rake-task + --task_after TASK Define a rake-task after the TeX-run + --maxrun MAXRUN Maximum MAXRUN TeX calls + -l, --loglevel LEVEL Log Level for the logger (1=debug, 2=info(default), 3=warn 4=error) + -v, --version Version diff --git a/support/rake4latex/call_rake4latex.rb b/support/rake4latex/call_rake4latex.rb new file mode 100644 index 0000000000..a712f0a581 --- /dev/null +++ b/support/rake4latex/call_rake4latex.rb @@ -0,0 +1,180 @@ +=begin rdoc +call_rake4latex.rb offers an easy and fast interface +to rake4latex. + +Just call it from the shell: + call_rake4latex.rb my_file + +my_file.tex will be compiled to my_file.pdf. + +For details, please use the help: + call_rake4latex.rb -h + +For complex documents you may want define your own rakefile +and use rake. + +It is recommended to copy this file to a location in your +search path for executable files. +=end + +require 'rake4latex' +#~ Dir.chdir('lib'){ require 'rake4latex' } +require 'optparse' + +#Anlegen des Parsers +opts = OptionParser.new() +opts.banner = "Usage: call_rake4latex.rb [options] filename" #Usage-zeile +opts.separator "Call LaTeX as often as needed." +opts.separator "" +opts.separator "Examples:" +opts.separator "call_rake4latex testdocument.pdf" +opts.separator " Create testdocument.pdf via pdflatex" +opts.separator " Starts only if testdocument.tex is newer then testdocument.pdf." +opts.separator "" +opts.separator "call_rake4latex -e testdocument" +opts.separator " Touch 'testdocument.tex' (set the modification date)" +opts.separator " Create testdocument.pdf via pdflatex" +opts.separator "" +opts.separator "Specific options:" + +# +#List of task to be done after the TeX-call. +# +TASK_BEFORE_TeX = [] #only task where we need the filenem +TASK_AFTER_TeX = [] +PARSE_MESSAGES = true + + +# +#fixme: format +=begin +Shortcuts +=end +opts.on('-e', "--enforce", "Enforce an initial TeX-run") { |v| + TASK_BEFORE_TeX << :enforce +} + +opts.on('-f', "--format FORMAT", "Set the format for TeX-run (pdflatex, xelatex, lualatex)") { |v| + Rake4LaTeX::DEFAULT_SETTINGS[:program] = v.to_sym +} + +# +#fixme: +#Warum gibt es immer einen TeX-Lauf mit dieser Option? +# +opts.on('--dep', "--dependecies", "Build dependecies (rakefile recommended)") { |v| + TASK_BEFORE_TeX << :dependecies +} +opts.on("-i", "--ignore", "--ignore-error", "Allow LaTeX errors") { |v| + puts "Allow LaTeX errors" if PARSE_MESSAGES + Rake4LaTeX::DEFAULT_SETTINGS[:texerrors_allowed] = true +} +opts.on("-s", "--statistic", "Show the statistic after TeX-run") { |v| + puts "Show the statistic after TeX-run" if PARSE_MESSAGES + TASK_BEFORE_TeX << :statistic #Set filename + TASK_AFTER_TeX << :statistic +} +opts.on("-o", "--overview", "Create a log-overview file") { |v| + puts "Create a log-overview file after TeX-run" if PARSE_MESSAGES + TASK_BEFORE_TeX << :statistic #Set filename + TASK_AFTER_TeX << :log_overview_file +} +opts.on("-c", "--clean", "Clean after TeX-run (delete auxiliary files)") { |v| + puts "Clean after TeX-run" if PARSE_MESSAGES + TASK_AFTER_TeX << :clean +} + +=begin +Main options +=end +# Soll der Parameter Optional sein, kann [] verwendet werden. +opts.on("--touch FILE", "Touch FILE") { |v| + puts "Touch #{v.inspect}" if PARSE_MESSAGES + task :touch => v + task :default => :touch +} + + +# +opts.on("--task TASK", "Define a rake-task") { |v| + puts "Set task #{v.inspect}" if PARSE_MESSAGES + task :default => v +} + +# +opts.on("--task_after TASK", "Define a rake-task after the TeX-run") { |v| + puts "Set task #{v.inspect} after LaTeX" if PARSE_MESSAGES + TASK_AFTER_TeX << v +} + +=begin +LaTeXRunner-options +=end +# +opts.on("--maxrun MAXRUN", "Maximum MAXRUN TeX calls") { |v| + puts "Set maximum TeX-Runs #{v.inspect}" if PARSE_MESSAGES + Rake4LaTeX::DEFAULT_SETTINGS[:maxruns] = v.to_i +} + +opts.on("-l", "--loglevel LEVEL", "Log Level for the logger (1=debug, 2=info(default), 3=warn 4=error)") { |v| + puts "Set loglevel to #{v.inspect}" if PARSE_MESSAGES + Rake4LaTeX::DEFAULT_SETTINGS[:loglevel] = v.to_i +} + +opts.on("-v", "--version", "Version") { |v| + puts "Rake4LaTeX-Caller Version #{Rake4LaTeX::VERSION}" +} + +task :default #empty dummy task + +#Parsen der Parameter mit Exception bei ungültigen Parametern +begin + opts.parse! + ARGV.each{|arg| + target = arg.ext('pdf') + puts "Define target #{target}" + TASK_BEFORE_TeX.each{|task| + case task + when :enforce + puts "Force an initial TeX-run (touch #{target.ext('tex')})" if PARSE_MESSAGES + task (:touch => target.ext('tex')) + task (:default => :touch) + when :dependecies + puts "Build dependecies for #{target.ext('tex')}" if PARSE_MESSAGES + TeXfile.new(target.ext('tex')).includes(:recursive, :uniq).each{|dep| + puts " => #{dep.inspect}" if PARSE_MESSAGES + task (target => dep) + } + when :statistic + task (:statistic => target.ext('tex')) + when :log_overview_file + task (:log_overview_file => target.ext('tex')) + else + raise ArgumentError, "Undefined option #{task.inspect}" + end + } + task( :default => target ) + puts "call_rake4latex tries to generate #{target}" + } +rescue OptionParser::MissingArgument, OptionParser::InvalidOption => err + puts "Error:\t#{err}" + #Ausgabe der Schnittstelle + puts opts +end + +# +#Set tasks after the LaTeX-call +TASK_AFTER_TeX.each{|task| + task (:default => task) +} + +app = Rake.application +app[:default].invoke + +if $0 == __FILE__ + if STDIN.tty? + puts "Finished, please enter any key" + STDOUT.flush + STDIN.getc + end +end
\ No newline at end of file diff --git a/support/rake4latex/readme_call_rake4latex.txt b/support/rake4latex/readme_call_rake4latex.txt new file mode 100644 index 0000000000..fcc3946cd2 --- /dev/null +++ b/support/rake4latex/readme_call_rake4latex.txt @@ -0,0 +1,26 @@ +Usage: call_rake4latex.rb [options] filename +Call LaTeX as often as needed. + +Examples: +call_rake4latex testdocument.pdf + Create testdocument.pdf via pdflatex + Starts only if testdocument.tex is newer then testdocument.pdf. + +call_rake4latex -e testdocument + Touch 'testdocument.tex' (set the modification date) + Create testdocument.pdf via pdflatex + +Specific options: + -e, --enforce Enforce an initial TeX-run + -f, --format FORMAT Set the format for TeX-run (pdflatex, xelatex, lualatex) + --dep, --dependecies Build dependecies (rakefile recommended) + -i, --ignore, --ignore-error Allow LaTeX errors + -s, --statistic Show the statistic after TeX-run + -o, --overview Create a log-overview file + -c, --clean Clean after TeX-run (delete auxiliary files) + --touch FILE Touch FILE + --task TASK Define a rake-task + --task_after TASK Define a rake-task after the TeX-run + --maxrun MAXRUN Maximum MAXRUN TeX calls + -l, --loglevel LEVEL Log Level for the logger (1=debug, 2=info(default), 3=warn 4=error) + -v, --version Version |