rbbeamer 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +188 -0
- data/bin/rbbeamer +506 -0
- data/lib/logo.png +0 -0
- data/lib/rbbeamer.rb +3 -0
- metadata +71 -0
data/README.md
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
rbbeamer - ruby-beamer
|
2
|
+
======================
|
3
|
+
|
4
|
+
rbbeamer is a preprocessor script to convert a structured file with informations about your slides into a .tex file. If pdflatex is installed, rbbeamer can go on and start pdflatex to build your PDF.
|
5
|
+
|
6
|
+
Most of work is done by the LaTeX-Beamer-package. But writing TEX-Files for beamer can be a little bit annoying if you usually use only a small (and everytime the same) part of the things beamer is capable to do. Most times I ended up with copy-and-pasting one slide after another and do same kind of changes all the time.
|
7
|
+
|
8
|
+
rbbeamer gives you access to (right now) just a small part of beamer-capabilities - in other words: it makes accessable the capabilities I usually use in my presentations / lectures. But you can input your data very fast with nearly no hazzle about formatting and counting clicks and all this stuff.
|
9
|
+
|
10
|
+
Example
|
11
|
+
-------
|
12
|
+
|
13
|
+
Let's say we need a couple of slides about rbbeamer. Open an ASCII-Editor of your choice and enter:
|
14
|
+
|
15
|
+
#sd|My Tests with rbbeamer | John Doe | April 2013
|
16
|
+
#toc|Agenda
|
17
|
+
#sec|Introduction
|
18
|
+
#fi| My first slide
|
19
|
+
#i| rbbeamer is for setting up slides very fast
|
20
|
+
#i|a tool for people who need lots of beautiful slides
|
21
|
+
#i| Have a closer look
|
22
|
+
#Fi
|
23
|
+
|
24
|
+
#sec|Details
|
25
|
+
#fd| Advantage and disadvantages
|
26
|
+
#d| advantage| you only type what is needed
|
27
|
+
#d|disadvantage | you have to read a \emph{small} README.
|
28
|
+
#Fd
|
29
|
+
|
30
|
+
Save this file as demo.rbt (rbt is default extension for rbbeamer-files). Now start rbbeamer:
|
31
|
+
|
32
|
+
if pdflatex is installed:
|
33
|
+
|
34
|
+
rbbeamer demo.rbt -p
|
35
|
+
|
36
|
+
or, if you just want to create a TEX-File for later use
|
37
|
+
|
38
|
+
rbbeamer demo.rbt
|
39
|
+
|
40
|
+
The resulting .TEX file will create a presentation with a title page, a table of content titled "Agenda" and two slides with data. Both slides will include animation (?? ander ausdruck) to step from one item to the next
|
41
|
+
|
42
|
+
### Install
|
43
|
+
|
44
|
+
Install with `gem install rbbeamer`.
|
45
|
+
|
46
|
+
rbbeamer compiles .rbt-files into .tex-files. If you want to create your PDF, you should also have a latex-installation (otherwise rbbeamer will just create a TEX-file that you can use to work with at your own). If latex is not in your $PATH, you can specify a path in ~/.rbbeamer.conf. Default binary-name ist pdflatex.
|
47
|
+
|
48
|
+
### System prerequisites
|
49
|
+
|
50
|
+
rbbeamer ist a script written in [Ruby][ruby]. You need a running Ruby-Installation (tested: 1.9.3, 2.0.0p0), most modern operating systems include one. rbbeamer ist developed and tested under Linux - it should run under MAC OS/X and Windows too - but I didn' t test it until now. Drop me a mail if you have additional info.
|
51
|
+
|
52
|
+
Creating pictures you will need *graphviz* in your path
|
53
|
+
### Commands
|
54
|
+
|
55
|
+
Commands start with a "#" as first char in a line. Every line not starting with # is ignored (so a blank as the first char means: this is a comment). You can use this to specify additional informations not shown on slide or just to decativate a command for testing purposes. The end of a command is defined by line break or seperator-char (default: |)
|
56
|
+
|
57
|
+
#sd|<Title Of Presentation> | <Author> | <Date> [ | sources]
|
58
|
+
start definition-command: Defines a titlepage with three entities. If you want to use citations with biblatex, just give a fourth option with name of .bib-file (specify without extension), i.e. `#sd| My Title Of Presentation | John Doe | April 2013 | sources`
|
59
|
+
|
60
|
+
#toc [| Agenda | <DEPTH>]
|
61
|
+
Table-Of-Content: includes a TOC-page based on defined sections and subsections. Optional: you can specify a title (default: Agenda) and a depth for building TOC (default: 1).
|
62
|
+
|
63
|
+
#sec|<yourtitle>
|
64
|
+
#sub|<yourtitle>
|
65
|
+
#ssub|<yourtitle>
|
66
|
+
Defines a section, subsection or subsubsection (are your sure using subsubsections in a presentation?) named \<yourtitle>.
|
67
|
+
|
68
|
+
#fi|<yourtitle>
|
69
|
+
Defines a frame (one slide) with different items using `itemize`. \<yourtitle> will be the title of frame.
|
70
|
+
|
71
|
+
#i| <content>
|
72
|
+
Defines one item within a frame started with `#fi`. This item will be visible after a click in presentation (if you didn't use `handout`-option, see later)
|
73
|
+
|
74
|
+
#Fi
|
75
|
+
Closes a frame started with `#fi`.
|
76
|
+
|
77
|
+
#fd|<yourtitle>
|
78
|
+
Defines a frame (one slide) with different items using `description`. \<yourtitle> will be the title of frame.
|
79
|
+
|
80
|
+
#d| <keyword> | <content>
|
81
|
+
Defines one item within a frame started with `#fd`. This item and its description will be visible after a click in presentation (if you didn't use `handout`-option, see later).
|
82
|
+
|
83
|
+
#Fd
|
84
|
+
Closes a frame started with `#fd`.
|
85
|
+
|
86
|
+
#fx|<yourtitle>
|
87
|
+
Defines a frame (one slide) with no content. \<yourtitle> will be the title of frame. You can use this to define a frame at your own (see `#[`-command).
|
88
|
+
|
89
|
+
#Fx
|
90
|
+
Closes a frame started with `#fx`.
|
91
|
+
|
92
|
+
#[|content
|
93
|
+
This command just copies all content of this line into resulting .TEX-file. Lets say, you want to specify a section with an additional short title. This you cannot do with `#sec`-command. Instead you can use `#[|\section[Short Title]{Really Long Title}`. Resulting .TEX-file will include this line: `\section[Short Title]{Really Long Title}`
|
94
|
+
|
95
|
+
#{|
|
96
|
+
If you need more flexibility in defining your slides, you can use this command. All lines following this command are copied 1:1 to resulting .TEX-file until you close this command. Let's assume you need a frame with special content. Design your frame with beamer. If you are done with this, copy your beamer-sourcecode into your rbt-file between a #{| and a #} line. So from this time on your special designed tex-code will be copied into tex-file.
|
97
|
+
|
98
|
+
#}
|
99
|
+
Closes the copy-mode.
|
100
|
+
|
101
|
+
#dig{|<filename> [|scale]
|
102
|
+
Using [Graphviz][graphviz]-package you can include pictures into your presentation. With this command you define the filename being used for building and saving your picture. Have a look into example.rbt to find a graphviz-picture. Don' t forget to define an empty frame (using `#fx`) before defining a graphviz-picture. If you omit *scale-option*, 1.0 will be inserted as scale: Graph width will be 100% of textwidth.
|
103
|
+
|
104
|
+
#input|<filename>
|
105
|
+
If you have large presentations, sometimes it is easier to use different source-files for different parts. Using `input`-command you can include another .rbt-file into your presentation (and yes, this one also can input a third one and so on).
|
106
|
+
|
107
|
+
### Commandline Options
|
108
|
+
Starting rbbeamer at least you will have to specify your .rbt-file to compile. But beside this you can specify a lot of options. Try option `--help` or `-x` to see a short description.
|
109
|
+
|
110
|
+
--seperator, -s <s>: use this pattern as seperator (default: |)
|
111
|
+
--logo, -l <s>: Logo-File (without extension) for slides (default:
|
112
|
+
logo)
|
113
|
+
--pdf, -p: Start pdflatex after creating tex-file
|
114
|
+
--handout, -h: build a handout (no animations in pdf, add _handout
|
115
|
+
to filename)
|
116
|
+
--theme, -t <s>: Beamer-Theme to use (see Beamer-Doc for more info)
|
117
|
+
(default: Luebeck)
|
118
|
+
--babel, -b <s>: Language-option for babel-Package (default: english)
|
119
|
+
--backend, -a <s>: Backend for biblatex setting up references (default:
|
120
|
+
bibtex)
|
121
|
+
--configfile, -c <s>: Use this file as configfile (default:
|
122
|
+
~/.rbbeamer.conf)
|
123
|
+
--deleteworkfiles, -d: Delete work-files from pdflatex:
|
124
|
+
.aux,.blg,.nav,.snm,.toc,.bbl,.log,.out,.run.xm,.tex,.eps,.run.xml,-blx.bib
|
125
|
+
--writeconfigfile, -w: write default config into ~/.rbbeamer.conf
|
126
|
+
(overwrite)
|
127
|
+
--debug, -e: Start in debugging mode
|
128
|
+
--debugpdf, -u: Show pdflatex-output during compilation
|
129
|
+
--help, -x: Show all options (this page)
|
130
|
+
|
131
|
+
|
132
|
+
### .rbbeamer.conf
|
133
|
+
Nearly all options regarding rbbeamer can be specified in command-line. But most times you don' t change your options. So ist is easier to use a config-file to save them. During startup rbbeamer sets all options to default values. If it finds .rbbeamer.conf, options are overriden by those specified in config-file. If you also specified options in command-line, these values will override the former ones.
|
134
|
+
|
135
|
+
To create your config-file, just specify all options needed for your work and add `--writeconfigfile (or -w)`. rbbeamer will then create a config (Linux: `~/.rbbeamer.conf`) to save all options within. Next time just start rbbeamer and specify your .rbt-file. Thats it. You can edit your config-file with any editor.
|
136
|
+
|
137
|
+
handout = false
|
138
|
+
pdf = true
|
139
|
+
deleteworkfiles = true
|
140
|
+
debug = false
|
141
|
+
debugpdf = false
|
142
|
+
seperator = |
|
143
|
+
babel = english
|
144
|
+
addpackage =
|
145
|
+
logo = rbb_logo
|
146
|
+
addpackage =
|
147
|
+
theme = Luebeck
|
148
|
+
latexpath =
|
149
|
+
latexbinary = pdflatex
|
150
|
+
backend = bibtex
|
151
|
+
|
152
|
+
|
153
|
+
If you need more packages to be declared in your .tex-file, just use addpackage option:
|
154
|
+
|
155
|
+
rbbeamer.rb test.rbt --addpackage [myoption=true]{testpackage},{otherpackage}
|
156
|
+
|
157
|
+
or use addpackage-line in .rbbeamer.conf:
|
158
|
+
|
159
|
+
addpackage = [myoption=true]{testpackage},{otherpackage}
|
160
|
+
|
161
|
+
This will lead to an additional entry in resulting .tex-file like this:
|
162
|
+
|
163
|
+
\usepackage[myoption=true]{testpackage}
|
164
|
+
\usepackage{otherpackage}
|
165
|
+
|
166
|
+
|
167
|
+
License
|
168
|
+
-------
|
169
|
+
|
170
|
+
rbbeamer is a preprocessor for creating TEX-files for LaTeX-Beamer.
|
171
|
+
Copyright (C) 2013 Thomas Romeyke (rubybeamer at googlemail.com).
|
172
|
+
|
173
|
+
This program is free software: you can redistribute it and/or modify
|
174
|
+
it under the terms of the GNU General Public License as published by
|
175
|
+
the Free Software Foundation, either version 3 of the License, or
|
176
|
+
any later version.
|
177
|
+
|
178
|
+
This program is distributed in the hope that it will be useful,
|
179
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
180
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
181
|
+
GNU General Public License for more details.
|
182
|
+
|
183
|
+
You should have received a copy of the GNU General Public License
|
184
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
185
|
+
|
186
|
+
[ruby]: http://www.ruby-lang.org
|
187
|
+
[graphviz]: http://www.graphviz.org
|
188
|
+
|
data/bin/rbbeamer
ADDED
@@ -0,0 +1,506 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#Encoding: UTF-8
|
3
|
+
#######################################################################
|
4
|
+
# rbbeamer is a preprocessor for creating TEX-files for LaTeX-Beamer.
|
5
|
+
# Copyright (C) 2013 Thomas Romeyke (rbbeamer at googlemail.com).
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
#######################################################################
|
21
|
+
require 'trollop'
|
22
|
+
require 'parseconfig.rb'
|
23
|
+
require 'open3'
|
24
|
+
require 'pathname'
|
25
|
+
|
26
|
+
Version = "0.5.0 (2013-04-24)"
|
27
|
+
|
28
|
+
sep = '|' # seperator-string to split different parts of a line / command
|
29
|
+
SAVESEP = '<-saveThisAsSeperatorForLaterUse->'
|
30
|
+
Defaulttheme = 'Luebeck'
|
31
|
+
DefaultLanguage = 'english'
|
32
|
+
Backend = 'bibtex'
|
33
|
+
Logofile = 'logo' # should be .png or .jpg or ...
|
34
|
+
DefaultLatexBinary = 'pdflatex'
|
35
|
+
DefaultLatexPath = '' # '' means: search in $PATH
|
36
|
+
copyLines = FALSE
|
37
|
+
endtext = ''
|
38
|
+
bibline = '%'
|
39
|
+
|
40
|
+
# These file-extensions are to be deleted after producing a pdf (only if deleteworkfiles is TRUE)
|
41
|
+
delLatexFiles = %w(.aux .blg .vrb .nav .snm .toc .bbl .log .out .run.xm .tex .eps .run.xml -blx.bib)
|
42
|
+
|
43
|
+
def license
|
44
|
+
lic = <<-EOF
|
45
|
+
rbbeamer is a preprocessor for creating TEX-files for LaTeX-Beamer.
|
46
|
+
Copyright (C) 2013 Thomas Romeyke (rbbeamer at googlemail.com).
|
47
|
+
|
48
|
+
This program is free software: you can redistribute it and/or modify
|
49
|
+
it under the terms of the GNU General Public License as published by
|
50
|
+
the Free Software Foundation, either version 3 of the License, or
|
51
|
+
any later version.
|
52
|
+
|
53
|
+
This program is distributed in the hope that it will be useful,
|
54
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
55
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
56
|
+
GNU General Public License for more details.
|
57
|
+
|
58
|
+
You should have received a copy of the GNU General Public License
|
59
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
60
|
+
EOF
|
61
|
+
return lic
|
62
|
+
end
|
63
|
+
class Object
|
64
|
+
def to_bool
|
65
|
+
!!(self.to_s =~ /^(true|t|yes|y|1)$/i)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def intro_beamer
|
70
|
+
intro = <<-'EOF'
|
71
|
+
\documentclass[/<-KVAR-TBR->/]{beamer}
|
72
|
+
\usepackage[/<-KVAR-TBR->/]{babel}
|
73
|
+
\usepackage[T1]{fontenc}
|
74
|
+
\usepackage[utf8]{inputenc}
|
75
|
+
\setbeamercovered{transparent}
|
76
|
+
\usepackage{pdfpages}
|
77
|
+
\usepackage[style=authortitle,backend=/<-KVAR-TBR->/]{biblatex}
|
78
|
+
\usetheme{/<-KVAR-TBR->/}
|
79
|
+
\usepackage{tikz}
|
80
|
+
\usetikzlibrary{shapes,arrows}
|
81
|
+
/<-KVAR-TBR->/
|
82
|
+
/<-KVAR-TBR->/
|
83
|
+
\begin{document}
|
84
|
+
\title[{\makebox[.45\paperwidth]{/<-KVAR-TBR->/\hfill%
|
85
|
+
\insertframenumber/\inserttotalframenumber}}]{/<-KVAR-TBR->/}
|
86
|
+
\titlegraphic{\includegraphics[height=1.5cm]{/<-LOGOFILE->/}}
|
87
|
+
\author{/<-KVAR-TBR->/}
|
88
|
+
\date{/<-KVAR-TBR->/}
|
89
|
+
%\setbeamerfont{parent A}{size=\Large}
|
90
|
+
%\setbeamerfont{parent B}{size=\small}
|
91
|
+
%\setbeamerfont{parent B}{size=\footnotesize}
|
92
|
+
%\setbeamerfont{parent Z}{size=\normalsize}
|
93
|
+
\logo{\pgfimage[height=0.7cm]{/<-LOGOFILE->/}}
|
94
|
+
\frame [plain]{
|
95
|
+
\titlepage
|
96
|
+
}
|
97
|
+
EOF
|
98
|
+
return intro
|
99
|
+
end
|
100
|
+
|
101
|
+
def toc_beamer
|
102
|
+
toc = <<-'EOF'
|
103
|
+
\setcounter{tocdepth}{%s}
|
104
|
+
\frame[plain]{
|
105
|
+
\frametitle{%s}
|
106
|
+
\tableofcontents
|
107
|
+
}
|
108
|
+
EOF
|
109
|
+
return toc
|
110
|
+
end
|
111
|
+
|
112
|
+
def checkStruc(struc,code,situation)
|
113
|
+
# trying to finde missing closing elements or unmatched #d or #i elements
|
114
|
+
case situation
|
115
|
+
when 'new'
|
116
|
+
# struc must be empty, otherwise we already have an open structure
|
117
|
+
mode = struc == ''
|
118
|
+
puts "WARNING: Missing closing element for " + struc[1] unless mode
|
119
|
+
when '-'
|
120
|
+
# code must fit to struc
|
121
|
+
mode = code.gsub(/#/,'') == struc[0].gsub(/#f/,'')
|
122
|
+
puts "WARNING: #{code} does'nt match #{struc[0]}: '" + struc[1] + "'" unless mode
|
123
|
+
when 'close'
|
124
|
+
# code must fit to struc
|
125
|
+
mode = code.gsub(/#F/,'') == struc[0].gsub(/#f/,'')
|
126
|
+
puts "WARNING: closing #{code} does'nt match #{struc[0]}: '" + struc[1] + "'" unless mode
|
127
|
+
else
|
128
|
+
raise "Problem: situation= #{situation.inspect} " + ' (' + struc + '): ' + code
|
129
|
+
end
|
130
|
+
return mode
|
131
|
+
end
|
132
|
+
|
133
|
+
def sanitize_path(path)
|
134
|
+
# path and filename is editable by user (configfile and/or options). So it should be
|
135
|
+
# sanitized to avoid entering a command within file/pathname.
|
136
|
+
return path.gsub(/[^a-z0-9A-Z\.\/\-]+/,'_')
|
137
|
+
end
|
138
|
+
|
139
|
+
def callsystem(cmd,verbose)
|
140
|
+
# runs command 'cmd' via commandline. if verbose == TRUE, all output will be
|
141
|
+
# forwarded to user.
|
142
|
+
# if verbose == FALSE, only stderr will be forwarded
|
143
|
+
if verbose
|
144
|
+
Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr|
|
145
|
+
while line = stdout_err.gets
|
146
|
+
puts line
|
147
|
+
end
|
148
|
+
exit_code = wait_thr.value
|
149
|
+
unless exit_code.success?
|
150
|
+
abort "Error (callsystem): #{cmd}"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
else
|
154
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
155
|
+
while line = stderr.gets
|
156
|
+
puts line
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
#######################################################################################
|
163
|
+
|
164
|
+
fname = File.basename(__FILE__)
|
165
|
+
firstname = File.basename(__FILE__,'.*')
|
166
|
+
pathname = File.dirname(File.expand_path(__FILE__))
|
167
|
+
pathname_lib = Pathname.new(pathname).parent.to_s + '/lib'
|
168
|
+
homedir = Dir.home + '/'
|
169
|
+
|
170
|
+
# Configfile will be:
|
171
|
+
ccfg = homedir + '.' + firstname + '.conf'
|
172
|
+
|
173
|
+
opts = Trollop::options do
|
174
|
+
opt :seperator, "use this pattern as seperator", :type => :string, :default => sep
|
175
|
+
opt :logo, "Logo-File (without extension) for slides", :type => :string, :short => 'o', :default => Logofile
|
176
|
+
opt :pdf, "Start pdflatex after creating tex-file", :default => false
|
177
|
+
opt :handout, "build a handout (no animations in pdf, add _handout to filename)", :default => false
|
178
|
+
opt :theme, "Beamer-Theme to use (see Beamer-Doc for more info)", :type => :string, :default => 'luebeck'
|
179
|
+
opt :babel, "Language-option for babel-Package", :type => :string, :short => 'b', :default => DefaultLanguage
|
180
|
+
opt :backend, "Backend for biblatex setting up references", :type => :string, :default => Backend
|
181
|
+
opt :addpackage, "add latex-packages (i.e. [myoption=true]{testpackage},{otherpackage})", :type => :string, :short => 'a', :default => ''
|
182
|
+
opt :configfile, "Use this file as configfile", :short => "c", :default => ccfg
|
183
|
+
opt :deleteworkfiles, "Delete work-files from pdflatex: "+delLatexFiles.join(','), :default => false
|
184
|
+
opt :writeconfigfile, "write default config into #{ccfg} (overwrite)", :default => false
|
185
|
+
opt :debug, "Start in debugging mode", :default => false
|
186
|
+
opt :debugpdf, "Show latex-output during compilation", :default => false
|
187
|
+
opt :license, "Show license and stop", :short => 'l'
|
188
|
+
opt :help, "Show all options (this page)", :short => 'x'
|
189
|
+
end
|
190
|
+
|
191
|
+
cfg = Hash.new
|
192
|
+
cfg[:handout] = false
|
193
|
+
cfg[:writeconfigfile] = false
|
194
|
+
cfg[:pdf] = false
|
195
|
+
cfg[:deleteworkfiles] = false
|
196
|
+
cfg[:debug] = false
|
197
|
+
cfg[:debugpdf] = false
|
198
|
+
cfg[:seperator] = sep
|
199
|
+
cfg[:babel] = DefaultLanguage
|
200
|
+
cfg[:logo] = pathname_lib + '/' + Logofile
|
201
|
+
cfg[:addpackage] = ''
|
202
|
+
cfg[:theme] = Defaulttheme
|
203
|
+
cfg[:latexpath] = DefaultLatexPath
|
204
|
+
cfg[:latexbinary] = DefaultLatexBinary
|
205
|
+
cfg[:backend] = Backend
|
206
|
+
cfg[:license] = false
|
207
|
+
|
208
|
+
if File.exists?(ccfg)
|
209
|
+
# Reading Config-File
|
210
|
+
ccfgexist = " (File exists)"
|
211
|
+
config = ParseConfig.new(ccfg)
|
212
|
+
cfg.keys.each do |k|
|
213
|
+
cfg[k] = config[k.to_s] if config.get_params().include?(k.to_s)
|
214
|
+
end
|
215
|
+
else
|
216
|
+
ccfgexist = " (File doesn't exist)"
|
217
|
+
end
|
218
|
+
|
219
|
+
# Reading options from commandline:
|
220
|
+
cfg.keys.each do |k|
|
221
|
+
cfg[k] = opts[k.to_sym] if opts.has_key?((k.to_s + '_given').to_sym)
|
222
|
+
end
|
223
|
+
|
224
|
+
# transform boolean vars from string:
|
225
|
+
[:debug,:debugpdf,:deleteworkfiles,:handout,:writeconfigfile,:pdf,:license].each {|s| cfg[s] = cfg[s].to_bool}
|
226
|
+
|
227
|
+
# This our config for this session:
|
228
|
+
if cfg[:debug]
|
229
|
+
puts "\n\nDebugging info:\nPathes:\npathname = #{pathname}\nhomedir = #{homedir}\n\nConfig-File = #{ccfg} #{ccfgexist}\n"
|
230
|
+
puts "\nConfig for this session:"
|
231
|
+
cfg.each_pair{|k,v| puts "#{k} = #{v}"}
|
232
|
+
puts "\n\n"
|
233
|
+
end
|
234
|
+
|
235
|
+
# Do we need an additional usepackage-line in tex-file?
|
236
|
+
packages = cfg[:addpackage].split(',')
|
237
|
+
packages.map!{|p| "\\usepackage#{p}"} if packages.size > 0
|
238
|
+
|
239
|
+
if cfg[:license]
|
240
|
+
puts "Version #{Version}"
|
241
|
+
puts "\n\n" + license() + "\n"
|
242
|
+
exit
|
243
|
+
end
|
244
|
+
|
245
|
+
sep = cfg[:seperator] # we use a shorter variable-name within our script
|
246
|
+
|
247
|
+
# Should a configfile be written?
|
248
|
+
if cfg[:writeconfigfile]
|
249
|
+
File.open(ccfg,'w') do |dat|
|
250
|
+
dat.puts "# Configfile for rbbeamer created at #{Time.now}"
|
251
|
+
cfg.each_pair{ |k,v| dat.puts "#{k} = #{v}" if k.to_s != 'writeconfigfile'} # writeconfigfile should not be saved in config
|
252
|
+
end
|
253
|
+
puts "created configfile: #{ccfg} with active options"
|
254
|
+
end
|
255
|
+
|
256
|
+
if ARGV.size <= 0
|
257
|
+
puts <<-EOF
|
258
|
+
------------------------------------------------------
|
259
|
+
rbbeamer Version #{Version}
|
260
|
+
This script prepares slides for presentations using Beamer and LaTeX the easy way
|
261
|
+
See README for details or have a look at https://github.com/rubybeamer/rbbeamer
|
262
|
+
License: GPL Version 3 or higher
|
263
|
+
Author: Thomas Romeyke, rbbeamer at gmail.com
|
264
|
+
EOF
|
265
|
+
puts "\n\nNo Inputfiles given:" + ARGV.join()
|
266
|
+
exit
|
267
|
+
end
|
268
|
+
|
269
|
+
raise "Please specify only one rbt-file: " + ARGV.join(', ') if ARGV.size > 1
|
270
|
+
# puts "Zu bearbeiten: "+ARGV.join(', ')
|
271
|
+
filename = sanitize_path(ARGV.first)
|
272
|
+
fbasename = File.basename(filename,'.rbt')
|
273
|
+
fbasename += '_handout' if cfg[:handout]
|
274
|
+
fn = fbasename + '.tex'
|
275
|
+
|
276
|
+
# Do we have to preprocess graphviz-pictures?
|
277
|
+
picmake = FALSE
|
278
|
+
puts "Processing #{filename}"
|
279
|
+
lines = IO.readlines(filename).map{|x| x.chomp}
|
280
|
+
# Do we have to input more files? (#input|file)
|
281
|
+
lines.each_index do |i|
|
282
|
+
if lines[i].split(sep).first == '#input'
|
283
|
+
puts "... reading input from #{lines[i].split(sep)[1].strip+'.rbt'}"
|
284
|
+
lines[i..i] = IO.readlines(lines[i].split(sep)[1].strip+'.rbt')
|
285
|
+
redo
|
286
|
+
end
|
287
|
+
end
|
288
|
+
# save all escaped seperator-symbols:
|
289
|
+
lines.map!{|l| l.gsub(Regexp.new(Regexp.escape('\\'+sep)),SAVESEP)}
|
290
|
+
# Any graphviz-pics?
|
291
|
+
fh = 1
|
292
|
+
0.step(lines.size-1) do |n|
|
293
|
+
line = lines[n]
|
294
|
+
sp = line.split(sep).reverse
|
295
|
+
code,content = sp.pop, sp.reverse
|
296
|
+
if code.to_s.chomp == "#dig{"
|
297
|
+
# New pic
|
298
|
+
picmake = TRUE
|
299
|
+
raise "Error: DOT without PIC-name: #{line}" if content.first.chomp.to_s.strip == ""
|
300
|
+
fname = content.first.chomp + ".dot"
|
301
|
+
fh = File.open(fname,'w')
|
302
|
+
end
|
303
|
+
if code.to_s.chomp == "#dig}"
|
304
|
+
# end of pic
|
305
|
+
picmake = FALSE
|
306
|
+
fh.close
|
307
|
+
# build pic:
|
308
|
+
dotcmd = "dot -Teps #{fname} -o#{File.basename(fname,'.dot')}.eps"
|
309
|
+
callsystem(dotcmd,cfg[:debugpdf])
|
310
|
+
File.delete(fname)
|
311
|
+
end
|
312
|
+
# just a normal line for setting up a graphviz-pic, simply copy it but replace our saved seperator-symbols
|
313
|
+
fh.puts line.gsub(SAVESEP,sep) if picmake
|
314
|
+
end
|
315
|
+
0.step(lines.size-1) do |n|
|
316
|
+
line = lines[n]
|
317
|
+
sp = line.split(sep).reverse
|
318
|
+
code,content = sp.pop, sp.reverse
|
319
|
+
# Do we have to copy complete lines?
|
320
|
+
copyLines = TRUE if code == '#{'
|
321
|
+
if copyLines
|
322
|
+
# Copymode: precede the line with special code to copy it:
|
323
|
+
lines[n] = "#[|#{line}" if (code != '#{' and code != '#}')
|
324
|
+
else
|
325
|
+
if (code.to_s == ''.to_s)
|
326
|
+
lines[n] = " "
|
327
|
+
else
|
328
|
+
lines[n] = "#{code}#{sep}#{content.join(sep)}"
|
329
|
+
end
|
330
|
+
end
|
331
|
+
copyLines = FALSE if code == '#}'
|
332
|
+
# find empty lines and mark them with L
|
333
|
+
lines[n] = "#L| " if line.strip.size == 0
|
334
|
+
end
|
335
|
+
lines = lines.select{|x| x[0]=='#'} # select all lines starting with # (only these are important for us)
|
336
|
+
puts "-> writing #{fn}"
|
337
|
+
|
338
|
+
x = 0
|
339
|
+
nums = Array.new
|
340
|
+
text = Array.new
|
341
|
+
numsfi = Array.new
|
342
|
+
textfi = Array.new
|
343
|
+
lines.each do |line|
|
344
|
+
sp = line.split(sep).reverse
|
345
|
+
code,content = sp.pop, sp.reverse
|
346
|
+
if code == '#fd'
|
347
|
+
x += 1
|
348
|
+
nums << 0
|
349
|
+
text << ''
|
350
|
+
end
|
351
|
+
if code == '#fi'
|
352
|
+
x += 1
|
353
|
+
numsfi << 0
|
354
|
+
textfi << ''
|
355
|
+
end
|
356
|
+
if code == '#d'
|
357
|
+
nums[nums.size-1] += 1
|
358
|
+
cs = content.first.strip
|
359
|
+
text[text.size-1] = cs if cs.size > text[text.size-1].size
|
360
|
+
end
|
361
|
+
if code == '#i'
|
362
|
+
numsfi[numsfi.size-1] += 1
|
363
|
+
end
|
364
|
+
end
|
365
|
+
openstruc = ''
|
366
|
+
# puts nums
|
367
|
+
nums.reverse!
|
368
|
+
text.reverse!
|
369
|
+
numsfi.reverse!
|
370
|
+
textfi.reverse!
|
371
|
+
File.open(fn,'w') do |out|
|
372
|
+
out.puts "% File created by #{fname}, Version #{Version}"
|
373
|
+
out.puts "% File created at #{Time.now}"
|
374
|
+
out.puts "% DO NOT CHANGE MANUALLY, FILE WILL BE OVERWRITTEN\n% "
|
375
|
+
counter = 1 # Start every frame empty; after first click first item will appear
|
376
|
+
anz = 0
|
377
|
+
anzfi = 0
|
378
|
+
textmuster = ''
|
379
|
+
# scalefaktor = 1.0 # default factor resizing DOT-pics (use command #sca to change it)
|
380
|
+
lines.each do |line|
|
381
|
+
sp = line.split(sep).reverse
|
382
|
+
code,content = sp.pop.strip, sp.reverse
|
383
|
+
# puts "code=#{code}, content=#{content.inspect}"
|
384
|
+
case code
|
385
|
+
when '#{', '#}', '#dig}'
|
386
|
+
# nothing to do
|
387
|
+
when '#<'
|
388
|
+
# puts "#< is deprecated"
|
389
|
+
when '#sec' # new section
|
390
|
+
out.puts "\\section{#{content.first.chomp}}"
|
391
|
+
when '#sub' # new subsection
|
392
|
+
out.puts "\\subsection{#{content.first.chomp}}"
|
393
|
+
when '#ssub' # new subsubsection
|
394
|
+
out.puts "\\subsubsection{#{content.first.chomp}}"
|
395
|
+
when '#toc' # table of content
|
396
|
+
#toc <optional> | Titel of TOC | depth of TOC # if depth is specified, title has to be specified too.
|
397
|
+
toc_title = content.first.to_s.size > 0 ? content.first.chomp.strip : 'Agenda' # special headline given?
|
398
|
+
toc_depth = content[1].to_i > 0 ? content[1].to_i : 1 # default depth of toc is '1'
|
399
|
+
toc_line = toc_beamer % [toc_depth,toc_title]
|
400
|
+
out.puts toc_line
|
401
|
+
when '#dig{' # Graphviz picture include
|
402
|
+
scalefaktor = content[1].to_f > 0 ? content[1].to_f : 1.0 # Scalefactor is optional in Content-pos. 1
|
403
|
+
out.puts "\\begin{figure}[h]"
|
404
|
+
out.puts "\\begin{center}"
|
405
|
+
out.puts "\\includegraphics[width=#{scalefaktor}\\linewidth]{#{content.first.strip}}"
|
406
|
+
out.puts "\\end{center}"
|
407
|
+
out.puts "\\end{figure}"
|
408
|
+
when '#sca' # set our new scalefactor
|
409
|
+
puts "#sca is deprecated"
|
410
|
+
scalefaktor = content.first.to_f
|
411
|
+
when '#[' # Content unverändert übernehmen (this line only)
|
412
|
+
out.puts content.join
|
413
|
+
when '#sd' # Start eines Beamer Documents, Vorspann schreiben
|
414
|
+
raise "Need title,author and date in #sd-Command: " + line if content.size < 3
|
415
|
+
Titel,Autor,Datum = content[0..2]
|
416
|
+
opt_handout = cfg[:handout] ? 'handout' : '' # we include this in \documentclass-command
|
417
|
+
addpackage = packages.size > 0 ? packages.join("\n") : '% no additional packages defined'
|
418
|
+
bibline = content.size >= 4 ? '\bibliography{' + content[3].strip + '}' : '%'
|
419
|
+
vorspann = intro_beamer
|
420
|
+
vorspann.gsub!('%','/PROZENT!/')
|
421
|
+
vorspann.gsub!('/<-KVAR-TBR->/','%s')
|
422
|
+
vorspann = vorspann % [opt_handout,cfg[:babel],cfg[:backend],cfg[:theme],addpackage,bibline,Titel,Titel,Autor,Datum]
|
423
|
+
vorspann.gsub!('/<-LOGOFILE->/',cfg[:logo])
|
424
|
+
vorspann.gsub!('/PROZENT!/','%')
|
425
|
+
out.puts vorspann
|
426
|
+
endtext = '\end{document}'
|
427
|
+
when '#l' # Label für Frame vergeben
|
428
|
+
out.puts '\label{' + content.first.strip + '}'
|
429
|
+
when '#f'
|
430
|
+
raise "#f is deprecated, please change to #fd and #Fd"
|
431
|
+
when '#fd' # Beginn eines Frames
|
432
|
+
checkStruc(openstruc,code,'new')
|
433
|
+
out.puts '\frame{'
|
434
|
+
out.puts ' \frametitle{' + content.first + '}'
|
435
|
+
counter = 1
|
436
|
+
anz = nums.pop + 1
|
437
|
+
textmuster = text.pop
|
438
|
+
out.puts ' \begin{description}['+textmuster+':]'
|
439
|
+
openstruc = ['#fd',content.join]
|
440
|
+
when '#fi' # Beginn eines Frames
|
441
|
+
checkStruc(openstruc,code,'new')
|
442
|
+
openstruc = ['#fi',content.join]
|
443
|
+
out.puts '\frame{'
|
444
|
+
out.puts ' \frametitle{' + content.first + '}'
|
445
|
+
counter = 1
|
446
|
+
anzfi = numsfi.pop + 1
|
447
|
+
out.puts ' \begin{itemize}'
|
448
|
+
when '#d' # Ausgabe eines description items
|
449
|
+
checkStruc(openstruc,code,'-')
|
450
|
+
counter += 1
|
451
|
+
content.reverse!
|
452
|
+
word = content.pop.strip
|
453
|
+
description = content.reverse.join.gsub(SAVESEP,sep)
|
454
|
+
out.puts ' \item<'+counter.to_s+'-'+anz.to_s+'|alert@'+counter.to_s+'> [' + word + ':] ' + description
|
455
|
+
when '#i' # Ausgabe eines items
|
456
|
+
checkStruc(openstruc,code,'-')
|
457
|
+
counter += 1
|
458
|
+
out.puts ' \item<'+counter.to_s+'-'+anzfi.to_s+'|alert@'+counter.to_s+'> ' + content.join.gsub(SAVESEP,sep)
|
459
|
+
when '#fx' # Beginn eines Frames aber ohne description
|
460
|
+
out.puts '\begin{frame}[fragile]'
|
461
|
+
out.puts ' \frametitle{' + content.first + '}'
|
462
|
+
when '#L'
|
463
|
+
out.puts ' ' # only a newline
|
464
|
+
when '#F'
|
465
|
+
raise "#f is deprecated, please change to #fd"
|
466
|
+
when '#Fd'
|
467
|
+
checkStruc(openstruc,code,'close')
|
468
|
+
openstruc = '' # closing structure
|
469
|
+
out.puts ' \end{description}'
|
470
|
+
out.puts '}'
|
471
|
+
when '#Fi'
|
472
|
+
checkStruc(openstruc,code,'close')
|
473
|
+
openstruc = '' # closing structure
|
474
|
+
out.puts ' \end{itemize}'
|
475
|
+
out.puts '}'
|
476
|
+
when '#Fx'
|
477
|
+
out.puts '\end{frame}'
|
478
|
+
else
|
479
|
+
raise "(RBB) Error, don't know this command: " + code
|
480
|
+
end
|
481
|
+
end
|
482
|
+
checkStruc(openstruc,'#Fd','new') # all strucs closed?
|
483
|
+
out.puts "\\printbibliography" if bibline != '%'
|
484
|
+
out.puts endtext
|
485
|
+
end
|
486
|
+
if cfg[:pdf]
|
487
|
+
pdfbin = sanitize_path(cfg[:latexpath] + cfg[:latexbinary]) + " " + sanitize_path(fn)
|
488
|
+
puts "Starting #{pdfbin}"
|
489
|
+
callsystem(pdfbin,cfg[:debugpdf])
|
490
|
+
if bibline != '%'
|
491
|
+
bibbin = sanitize_path(cfg[:latexpath] + cfg[:backend]) + " " + sanitize_path(fbasename)
|
492
|
+
puts "starting #{bibbin}"
|
493
|
+
callsystem(bibbin,cfg[:debugpdf])
|
494
|
+
end
|
495
|
+
puts "Starting #{pdfbin} again"
|
496
|
+
callsystem(pdfbin,FALSE)
|
497
|
+
end
|
498
|
+
|
499
|
+
# Should we delete some files from pdflatex?
|
500
|
+
if cfg[:deleteworkfiles]
|
501
|
+
listing = Array.new
|
502
|
+
delLatexFiles.each{|f| listing << Dir.glob(fbasename + f).flatten}
|
503
|
+
puts "deleting files: " + listing.flatten.join(', ') if cfg[:debug]
|
504
|
+
listing.flatten.each{|f| File.delete(f) if f.strip.size > 0}
|
505
|
+
end
|
506
|
+
|
data/lib/logo.png
ADDED
Binary file
|
data/lib/rbbeamer.rb
ADDED
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rbbeamer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Thomas Romeyke
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: trollop
|
16
|
+
requirement: &78815090 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *78815090
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: parseconfig
|
27
|
+
requirement: &78814630 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.2
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *78814630
|
36
|
+
description: Helps you building beamer-presentations
|
37
|
+
email: rbbeamer@gmail.com
|
38
|
+
executables:
|
39
|
+
- rbbeamer
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- bin/rbbeamer
|
44
|
+
- lib/logo.png
|
45
|
+
- lib/rbbeamer.rb
|
46
|
+
- README.md
|
47
|
+
homepage: https://github.com/rubybeamer/rbbeamer
|
48
|
+
licenses: []
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.8.10
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: rbbeamer is a preprocessor script for latex-beamer
|
71
|
+
test_files: []
|