runtex 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/Code_zum_Pluendern_rtex4newrtex.rb +275 -0
- data/lib/catch_output.rb +99 -0
- data/lib/runtex.rb +221 -0
- data/lib/runtex_bibtex.rb +111 -0
- data/lib/runtex_job_chain.rb +371 -0
- data/lib/runtex_latex.rb +373 -0
- data/lib/runtex_makeindex.rb +114 -0
- data/lib/runtex_pathes.yaml +59 -0
- data/lib/runtex_rail.rb +116 -0
- data/lib/runtex_splitindex.rb +78 -0
- data/lib/runtex_tool.rb +128 -0
- data/lppl.txt +416 -0
- data/readme +73 -0
- data/unittest/expected/test_bibliography_babelbib.debug1.txt +31 -0
- data/unittest/expected/test_bibliography_babelbib.debug2.txt +16 -0
- data/unittest/expected/test_bibliography_babelbib.tex.runtex_summary.txt +19 -0
- data/unittest/expected/test_bibliography_babelbib_1.txt +15 -0
- data/unittest/expected/test_bibliography_babelbib_2.txt +11 -0
- data/unittest/expected/test_bibliography_plain.debug1.txt +45 -0
- data/unittest/expected/test_bibliography_plain.debug2.txt +16 -0
- data/unittest/expected/test_bibliography_plain.tex.runtex_summary.txt +18 -0
- data/unittest/expected/test_bibliography_plain_1.txt +19 -0
- data/unittest/expected/test_bibliography_plain_2.txt +11 -0
- data/unittest/expected/test_error.debug1.txt +22 -0
- data/unittest/expected/test_error.debug2.txt +12 -0
- data/unittest/expected/test_error.tex.runtex_summary.txt +15 -0
- data/unittest/expected/test_error_1.txt +15 -0
- data/unittest/expected/test_error_2.txt +12 -0
- data/unittest/expected/test_gloss.debug1.txt +45 -0
- data/unittest/expected/test_gloss.debug2.txt +16 -0
- data/unittest/expected/test_gloss.tex.runtex_summary.txt +18 -0
- data/unittest/expected/test_gloss_1.txt +19 -0
- data/unittest/expected/test_gloss_2.txt +11 -0
- data/unittest/expected/test_gloss_newgloss.debug1.txt +58 -0
- data/unittest/expected/test_gloss_newgloss.debug2.txt +20 -0
- data/unittest/expected/test_gloss_newgloss.tex.runtex_summary.txt +24 -0
- data/unittest/expected/test_gloss_newgloss_1.txt +23 -0
- data/unittest/expected/test_gloss_newgloss_2.txt +13 -0
- data/unittest/expected/test_glossaries.debug1.txt +56 -0
- data/unittest/expected/test_glossaries.debug2.txt +28 -0
- data/unittest/expected/test_glossaries.tex.runtex_summary.txt +30 -0
- data/unittest/expected/test_glossaries_1.txt +24 -0
- data/unittest/expected/test_glossaries_2.txt +19 -0
- data/unittest/expected/test_index.debug1.txt +35 -0
- data/unittest/expected/test_index.debug2.txt +18 -0
- data/unittest/expected/test_index.tex.runtex_summary.txt +24 -0
- data/unittest/expected/test_index2.debug1.txt +58 -0
- data/unittest/expected/test_index2.debug2.txt +29 -0
- data/unittest/expected/test_index2.tex.runtex_summary.txt +27 -0
- data/unittest/expected/test_index2_1.txt +23 -0
- data/unittest/expected/test_index2_2.txt +17 -0
- data/unittest/expected/test_index_1.txt +21 -0
- data/unittest/expected/test_index_2.txt +17 -0
- data/unittest/expected/test_makeindex.debug1.txt +35 -0
- data/unittest/expected/test_makeindex.debug2.txt +18 -0
- data/unittest/expected/test_makeindex.tex.runtex_summary.txt +18 -0
- data/unittest/expected/test_makeindex_1.txt +15 -0
- data/unittest/expected/test_makeindex_2.txt +11 -0
- data/unittest/expected/test_packagedoc_dtx.debug1.txt +54 -0
- data/unittest/expected/test_packagedoc_dtx.debug2.txt +27 -0
- data/unittest/expected/test_packagedoc_dtx.dtx.runtex_summary.txt +31 -0
- data/unittest/expected/test_packagedoc_dtx_1.txt +18 -0
- data/unittest/expected/test_packagedoc_dtx_2.txt +13 -0
- data/unittest/expected/test_rail.debug1.txt +35 -0
- data/unittest/expected/test_rail.debug2.txt +12 -0
- data/unittest/expected/test_rail.tex.runtex_summary.txt +12 -0
- data/unittest/expected/test_rail_1.txt +13 -0
- data/unittest/expected/test_rail_2.txt +9 -0
- data/unittest/expected/test_rail_error.debug1.txt +37 -0
- data/unittest/expected/test_rail_error.debug2.txt +35 -0
- data/unittest/expected/test_rail_error.tex.runtex_summary.txt +18 -0
- data/unittest/expected/test_rail_error_1.txt +18 -0
- data/unittest/expected/test_rail_error_2.txt +18 -0
- data/unittest/expected/test_splitindex.debug1.txt +64 -0
- data/unittest/expected/test_splitindex.debug2.txt +32 -0
- data/unittest/expected/test_splitindex.tex.runtex_summary.txt +31 -0
- data/unittest/expected/test_splitindex_1.txt +21 -0
- data/unittest/expected/test_splitindex_2.txt +15 -0
- data/unittest/expected/test_test.debug1.txt +32 -0
- data/unittest/expected/test_test.debug2.txt +12 -0
- data/unittest/expected/test_test.tex.runtex_summary.txt +12 -0
- data/unittest/expected/test_test_1.txt +15 -0
- data/unittest/expected/test_test_2.txt +9 -0
- data/unittest/expected/test_test_bibliography.debug1.txt +31 -0
- data/unittest/expected/test_test_gloss.debug1.txt +45 -0
- data/unittest/expected/test_test_gloss_newgloss.debug1.txt +58 -0
- data/unittest/expected/test_test_glossaries.debug1.txt +48 -0
- data/unittest/expected/test_test_index.debug1.txt +35 -0
- data/unittest/expected/test_test_index2.debug1.txt +58 -0
- data/unittest/expected/test_test_makeindex.debug1.txt +35 -0
- data/unittest/expected/test_test_rail.debug1.txt +35 -0
- data/unittest/expected/test_test_splitindex.debug1.txt +64 -0
- data/unittest/expected/test_test_test.debug1.txt +32 -0
- data/unittest/testcases.yaml +427 -0
- data/unittest/unittest_catch_output.rb +66 -0
- data/unittest/unittest_runtex.rb +282 -0
- metadata +149 -0
@@ -0,0 +1,275 @@
|
|
1
|
+
puts <<xx
|
2
|
+
Kopiervorlage aus alter Version
|
3
|
+
Sollte am Ende der Umsetzung leer sein.
|
4
|
+
------------------------------
|
5
|
+
xx
|
6
|
+
|
7
|
+
require 'yaml'
|
8
|
+
File.open('runtex_pathes.yaml'){|f| $conf = YAML.load(f)}
|
9
|
+
|
10
|
+
#~ puts $conf.inspect
|
11
|
+
basename = 'basename'
|
12
|
+
|
13
|
+
exit
|
14
|
+
#
|
15
|
+
#Things to get better:
|
16
|
+
#- class Configuration is platform depending and only defined for Win2K
|
17
|
+
# - path and program for each tool
|
18
|
+
# - stdout/stderr/Log->Files
|
19
|
+
#- Error and Warning-Analyses must be enforced
|
20
|
+
#- support multibib.sty (bibtex)
|
21
|
+
#- support multind.sty
|
22
|
+
#- Option -c to remove all auxiliary files.
|
23
|
+
#- Check in which source-file an error/warning occurs (input-list)
|
24
|
+
#- Check on which output page an error/warning occurs (input-list)
|
25
|
+
|
26
|
+
#
|
27
|
+
#This class allows some precompile on the given TeX-File(s)
|
28
|
+
#Actual a method for listings.sty is implemented.
|
29
|
+
class Precompile
|
30
|
+
#This method overwrites the given file with the replacements for listings
|
31
|
+
def Precompile.mix_references!( filename )
|
32
|
+
|
33
|
+
Logger.add(2, '', "Precompile #{filename} for cross-references")
|
34
|
+
pre = new( filename)
|
35
|
+
pre.listings_mix_references()
|
36
|
+
|
37
|
+
new = File.new(filename, 'w')
|
38
|
+
new.puts pre.text() #write the converted text
|
39
|
+
new.close
|
40
|
+
end #mix_references( template )
|
41
|
+
#Read the contents of the file
|
42
|
+
def initialize( filename)
|
43
|
+
@text = ''
|
44
|
+
File.open( filename ){ |f|
|
45
|
+
@text = f.readlines.to_s
|
46
|
+
}
|
47
|
+
end
|
48
|
+
attr_reader :text
|
49
|
+
#This function supports the handling of the package listings.
|
50
|
+
#Listings.sty allows you the insertion of external lsitings with the command
|
51
|
+
# \lstinputlisting[firstline=<first>,lastline=<last>]{Programm}
|
52
|
+
#There is one Problem: Whats the value of <first> and <last>?
|
53
|
+
#Once a programm is finished, it is no problem. But when the program is still in develpment,
|
54
|
+
#you have to adapt the line numbering.
|
55
|
+
#It would be much nicer, if you could use something like
|
56
|
+
# \lstinputlisting[fromlabel=<first>,tolabel=<last>]{Programm}
|
57
|
+
#Well, I understand why it is dificult to make it in listings.sty.
|
58
|
+
#This method makes this work. It scans the listing file for the label and replaces it in the source.
|
59
|
+
def listings_mix_references( template = @text )
|
60
|
+
#This method scan a program file for the string TeXlabel{<label>} or LABEL{<label>} and stores the linenumber.
|
61
|
+
#The string can be redefined by a regular expression, $1 must be the label.
|
62
|
+
def scan_source( source, r = /[(TeXlabel)|(LABEL)]\{(.*?)?\}/ )
|
63
|
+
Logger.add(4, self.class, "Read File #{source} for cross-references")
|
64
|
+
labels = Hash.new( 0 )
|
65
|
+
if !File.exist?( source )
|
66
|
+
Logger.add(3, self.class, "Sourcecode #{source} nicht gefunden" )
|
67
|
+
return labels
|
68
|
+
end
|
69
|
+
#extend this Hash with a method get_label
|
70
|
+
File.open(source){ |f|
|
71
|
+
linenumber = 0
|
72
|
+
f.each{|l|
|
73
|
+
linenumber += 1
|
74
|
+
while l =~ r #Perhaps there are mor then one label on a line
|
75
|
+
labels[$1] = linenumber
|
76
|
+
l.sub!( r ,'') #delete label for next Regex-check
|
77
|
+
end
|
78
|
+
#Idee f�r ABAP: FORM/Endform automatisch mit Labels versehen?
|
79
|
+
}
|
80
|
+
}
|
81
|
+
Logger.add(5, self.class, "Found labels in #{source}: #{labels.inspect}")
|
82
|
+
return labels
|
83
|
+
end
|
84
|
+
def get_label( hash, key, source )
|
85
|
+
pos = hash.fetch(key, 0)
|
86
|
+
Logger.add(3, self.class, "Label #{key} not found in #{source}") if pos == 0
|
87
|
+
return pos
|
88
|
+
end
|
89
|
+
#If this script is running more the once, the inputlistings would increase.
|
90
|
+
#So we clear it here to a "virgin" state.
|
91
|
+
@text.gsub!(
|
92
|
+
/%(lstinputlisting\[.*?\]\{(.*?)\})\n.lstinputlisting\[.*?\]\{.*?\}/m,
|
93
|
+
'\\\\\1'
|
94
|
+
)
|
95
|
+
#\ABAPinput is a macro used in a privat package of the author ;-)
|
96
|
+
@text.gsub!(
|
97
|
+
/%(ABAPinput\[.*?\]\{(.*?)\})\n.ABAPinpu\[.*?\]\{.*?\}/m,
|
98
|
+
'\\\\\1'
|
99
|
+
)
|
100
|
+
|
101
|
+
sources = Hash.new() #all Sources
|
102
|
+
#Replace all from/tolabe-listings with the new first/lastline version.
|
103
|
+
#Remember the original labels in a TeX-comment (needed next time, the programm could change.
|
104
|
+
r = Regexp.new('\\\\(lstinputlisting|ABAPinput)\[.*(?:fromlabel=(.*?))(,.*)*(?:tolabel=(.*?))(,.*)*\]{(.*)}')
|
105
|
+
while m = r.match(@text)
|
106
|
+
old = m[0]
|
107
|
+
source = m[6]
|
108
|
+
Logger.add(5, self.class, "Found lstinputlisting #{source}")
|
109
|
+
if ! sources.has_key?(source)
|
110
|
+
sources[source] = scan_source( source )
|
111
|
+
end
|
112
|
+
pos1 = get_label(sources[source], m[2], source ) + 1
|
113
|
+
pos2 = get_label(sources[source], m[4], source ) - 1
|
114
|
+
new = '\\' + m[1] + '[' + 'firstline=' + pos1.to_s + m[3] +
|
115
|
+
'lastline=' + pos2.to_s + m[5].to_s + "]{" + source + '}'
|
116
|
+
Logger.add(5, self.class, "Command old:\t#{old}\nCommand new\t#{new}" )
|
117
|
+
@text = m.pre_match + "%#{old[1..-1]}\n" + new + m.post_match
|
118
|
+
end
|
119
|
+
return @text
|
120
|
+
end #mix_references
|
121
|
+
end #Precompile
|
122
|
+
|
123
|
+
|
124
|
+
class DVIPS< Tool
|
125
|
+
def initialize( filename )
|
126
|
+
super()
|
127
|
+
@filename = filename
|
128
|
+
@logInclude = false #Add log-Files
|
129
|
+
@stdoutInclude = false #Add the stdout-Files
|
130
|
+
@stderrInclude = true #Add the stderr-Files same as ilg-file
|
131
|
+
@first = true
|
132
|
+
end
|
133
|
+
def rerun?( log = nil )
|
134
|
+
return @first #Postprocessor runs only once
|
135
|
+
end
|
136
|
+
def execute()
|
137
|
+
@first = false
|
138
|
+
Logger.add( 5, self.class, "Execute #{Configuration.dvips}")
|
139
|
+
@dataChanged = false #clear flag
|
140
|
+
stderrOff()
|
141
|
+
result = system( Configuration.dvips(@filename) )
|
142
|
+
stderrOn()
|
143
|
+
@log = get_stderr()
|
144
|
+
put_analyse( analyse( @log ) )
|
145
|
+
if !result
|
146
|
+
Logger.add(1, self.class, "Error executing #{self.class}")
|
147
|
+
end
|
148
|
+
add_stdout( self.class ) if @stdoutInclude
|
149
|
+
add_stderr( self.class ) if @stderrInclude
|
150
|
+
return result
|
151
|
+
end
|
152
|
+
def analyse( log=@log )
|
153
|
+
result = { 'Error' => 0,
|
154
|
+
'Warning' => 0,
|
155
|
+
'Informationlist' => [],
|
156
|
+
'Errorlist' => [],
|
157
|
+
'Warninglist' => [],
|
158
|
+
}
|
159
|
+
log.each{ |l|
|
160
|
+
if /This is (.*) Copyright/ =~ l
|
161
|
+
result['Informationlist'] << "Called #{$1}"
|
162
|
+
# check analyses
|
163
|
+
elsif /[Ee]rror/ =~ l
|
164
|
+
result['Error'] += 1
|
165
|
+
result[:error] << "#{l}"
|
166
|
+
elsif /[Ww]arning/ =~ l
|
167
|
+
result['Warning'] += 1
|
168
|
+
result[:warning] << "#{l}"
|
169
|
+
end
|
170
|
+
}
|
171
|
+
return result
|
172
|
+
end
|
173
|
+
end #DVIPS
|
174
|
+
|
175
|
+
class PS2PDF< Tool
|
176
|
+
def initialize( filename )
|
177
|
+
super()
|
178
|
+
@filename = filename
|
179
|
+
@logInclude = false #Add log-Files
|
180
|
+
@stdoutInclude = true #Add the stdout-Files
|
181
|
+
@stderrInclude = false #Add the stderr-Files
|
182
|
+
@first = true
|
183
|
+
end
|
184
|
+
def rerun?( log = nil )
|
185
|
+
return @first #Postprocessor runs only once
|
186
|
+
end
|
187
|
+
def execute()
|
188
|
+
@first = false
|
189
|
+
Logger.add( 5, self.class, "Execute #{self.class} (#{Configuration.ps2pdf})")
|
190
|
+
@dataChanged = false #clear flag
|
191
|
+
stdoutOff()
|
192
|
+
result = system( Configuration.ps2pdf( @filename ) )
|
193
|
+
stdoutOn()
|
194
|
+
@log = get_stdout()
|
195
|
+
put_analyse( analyse( @log ) )
|
196
|
+
if !result
|
197
|
+
Logger.add(1, self.class, "Error executing #{self.class}")
|
198
|
+
end
|
199
|
+
add_stdout( self.class ) if @stdoutInclude
|
200
|
+
add_stderr( self.class ) if @stderrInclude
|
201
|
+
return result
|
202
|
+
end
|
203
|
+
def analyse( log=@log )
|
204
|
+
result = { 'Error' => 0,
|
205
|
+
'Warning' => 0,
|
206
|
+
'Informationlist' => [],
|
207
|
+
'Errorlist' => [],
|
208
|
+
'Warninglist' => [],
|
209
|
+
}
|
210
|
+
log.each{ |l|
|
211
|
+
if /Unable to open the initial device, quitting./ =~ l
|
212
|
+
result['Error'] += 1
|
213
|
+
result[:error] << "Unable to open the initial device (PDF opened in Acrobat?)"
|
214
|
+
elsif /[Ee]rror/ =~ l
|
215
|
+
result['Error'] += 1
|
216
|
+
result[:error] << "#{l}"
|
217
|
+
elsif /[Ww]arning/ =~ l
|
218
|
+
result['Warning'] += 1
|
219
|
+
result[:warning] << "#{l}"
|
220
|
+
end
|
221
|
+
}
|
222
|
+
return result
|
223
|
+
end
|
224
|
+
end #PS2PDF
|
225
|
+
|
226
|
+
class DVIPDFM< Tool
|
227
|
+
def initialize( filename )
|
228
|
+
super()
|
229
|
+
@filename = filename
|
230
|
+
@logInclude = false #Add log-Files
|
231
|
+
@stdoutInclude = true #Add the stdout-Files
|
232
|
+
@stderrInclude = false #Add the stderr-Files
|
233
|
+
@first = true
|
234
|
+
end
|
235
|
+
def rerun?( log = nil )
|
236
|
+
return @first #Postprocessor runs only once
|
237
|
+
end
|
238
|
+
def execute()
|
239
|
+
@first = false
|
240
|
+
Logger.add( 5, self.class, "Execute #{self.class} (#{Configuration.ps2pdf})")
|
241
|
+
@dataChanged = false #clear flag
|
242
|
+
stdoutOff()
|
243
|
+
result = system( Configuration.dvipdfm( @filename ) )
|
244
|
+
stdoutOn()
|
245
|
+
@log = get_stdout()
|
246
|
+
put_analyse( analyse() )
|
247
|
+
if !result
|
248
|
+
Logger.add(1, self.class, "Error executing #{self.class}")
|
249
|
+
end
|
250
|
+
add_stdout( self.class ) if @stdoutInclude
|
251
|
+
add_stderr( self.class ) if @stderrInclude
|
252
|
+
return result
|
253
|
+
end
|
254
|
+
def analyse( log=@log )
|
255
|
+
result = { 'Error' => 0,
|
256
|
+
'Errorlist' => [],
|
257
|
+
'Warninglist' => [],
|
258
|
+
}
|
259
|
+
log.each{ |l|
|
260
|
+
if /Unable to open the initial device, quitting./ =~ l
|
261
|
+
result['Error'] += 1
|
262
|
+
result[:error] << "Unable to open the initial device (PDF opened in Acrobat?)"
|
263
|
+
elsif /[Ee]rror/ =~ l
|
264
|
+
result['Error'] += 1
|
265
|
+
result[:error] << "#{l}"
|
266
|
+
elsif /[Ww]arning/ =~ l
|
267
|
+
result['Warning'] += 1
|
268
|
+
result[:warning] << "#{l}"
|
269
|
+
end
|
270
|
+
}
|
271
|
+
return result
|
272
|
+
end
|
273
|
+
end #DVIPDFM
|
274
|
+
|
275
|
+
|
data/lib/catch_output.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
#
|
2
|
+
#Catch screen output.
|
3
|
+
#Can be used to avoid messages from programms called by system
|
4
|
+
#
|
5
|
+
#
|
6
|
+
|
7
|
+
|
8
|
+
#Class Tempfile for temporary redirection of stdout and stderr
|
9
|
+
require "tempfile"
|
10
|
+
|
11
|
+
#Catch screen output.
|
12
|
+
#Can be used to avoid messages from programms called by system
|
13
|
+
module Catch_output
|
14
|
+
STDOUT_ORIG = STDOUT.clone()
|
15
|
+
STDERR_ORIG = STDERR.clone()
|
16
|
+
|
17
|
+
|
18
|
+
#Catch stdout for the given block, but print stderr.
|
19
|
+
def catch_stdout( &block )
|
20
|
+
#~ raise 'no block' unless block_given?
|
21
|
+
raise 'no block' unless block.is_a?(Proc)
|
22
|
+
stdout, stderr = catch_screen_output( true, false, &block )
|
23
|
+
return stdout
|
24
|
+
end #catch_stdout()
|
25
|
+
|
26
|
+
#Catch stderr for the given block, but print stdout.
|
27
|
+
def catch_stderr( &block )
|
28
|
+
#~ raise 'no block' unless block_given?
|
29
|
+
raise 'no block' unless block.is_a?(Proc)
|
30
|
+
stdout, stderr = catch_screen_output( false, true, &block )
|
31
|
+
return stderr
|
32
|
+
end #catch_stderr()
|
33
|
+
|
34
|
+
#Catch the screen output (stdout and stderr) for the given block.
|
35
|
+
#You can set, which output you want to catch.
|
36
|
+
#
|
37
|
+
#Returnvalue is an array with the result of stdout and stderr.
|
38
|
+
#If any output wasn't catched, the return value in the array is nil.
|
39
|
+
def catch_screen_output(
|
40
|
+
catch_stdout = true,
|
41
|
+
catch_stderr = true,
|
42
|
+
stdout_orig = STDOUT.clone(),
|
43
|
+
stderr_orig = STDERR.clone()
|
44
|
+
)
|
45
|
+
|
46
|
+
raise 'no block' unless block_given?
|
47
|
+
|
48
|
+
if catch_stdout
|
49
|
+
#Create temporary file for stdout
|
50
|
+
tmpstdout = Tempfile.new( 'stdout')
|
51
|
+
#redirect stdout
|
52
|
+
STDOUT.reopen( tmpstdout )
|
53
|
+
end
|
54
|
+
if catch_stderr
|
55
|
+
#Create temporary file for stdout
|
56
|
+
tmpstderr = Tempfile.new( 'stderr')
|
57
|
+
#redirect stdout
|
58
|
+
STDERR.reopen( tmpstderr )
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
yield #Execute the block
|
63
|
+
|
64
|
+
if catch_stdout
|
65
|
+
#stdout is coming again to the screen.
|
66
|
+
tmpstdout.close()
|
67
|
+
STDOUT.reopen( stdout_orig)
|
68
|
+
|
69
|
+
# Get the result of stdout
|
70
|
+
tmpstdout.open()
|
71
|
+
stdout = tmpstdout.readlines().join
|
72
|
+
tmpstdout.close()
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
if catch_stderr
|
77
|
+
#stderr is coming again to the screen.
|
78
|
+
tmpstderr.close()
|
79
|
+
STDERR.reopen( stderr_orig)
|
80
|
+
|
81
|
+
# Get the result of stderr
|
82
|
+
tmpstderr.open()
|
83
|
+
stderr = tmpstderr.readlines().join
|
84
|
+
tmpstderr.close()
|
85
|
+
end
|
86
|
+
return [ stdout, stderr ]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
#Frame to use module Catch_output
|
92
|
+
#
|
93
|
+
#Example:
|
94
|
+
# Frame_catch_output.catch_stdout{ puts 11 }
|
95
|
+
class Frame_catch_output
|
96
|
+
class << self
|
97
|
+
include Catch_output
|
98
|
+
end
|
99
|
+
end
|
data/lib/runtex.rb
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
#
|
2
|
+
#This program translates a (La)TeX-File as often as necessary and
|
3
|
+
#gives a log-overview.
|
4
|
+
#
|
5
|
+
#
|
6
|
+
#Some programs with a similar functionalty
|
7
|
+
#- texify (miktex)
|
8
|
+
|
9
|
+
#- texexec (ConTeXt)
|
10
|
+
#- rubber (Python) http://ebeffara.free.fr/stuff/rubber/
|
11
|
+
#- texi2pdf (or texi2dvi)
|
12
|
+
#- mk Perl script http://www.servalys.nl/tex/mk.html
|
13
|
+
#
|
14
|
+
#Sometimes 'make' is recommended for this task,
|
15
|
+
#but make makes problems with the multiple calls
|
16
|
+
#of LaTeX.
|
17
|
+
#
|
18
|
+
#This script consider:
|
19
|
+
#- index (normal makeindex and multiple indices with indes.sty or splitindex)
|
20
|
+
#- glossaries.sty
|
21
|
+
#- bibliography
|
22
|
+
#- rails and rails.sty
|
23
|
+
#- ...
|
24
|
+
#
|
25
|
+
# %%%%%%%%%%%%%%%%%%%%
|
26
|
+
# % License
|
27
|
+
# %%%%%%%%%%%%%%%%%%%%
|
28
|
+
# %% Copyright 2009 Knut Lickert
|
29
|
+
# %
|
30
|
+
# % This work may be distributed and/or modified under the
|
31
|
+
# % conditions of the LaTeX Project Public License, either version 1.3
|
32
|
+
# % of this license or (at your option) any later version.
|
33
|
+
# % The latest version of this license is in
|
34
|
+
# % http://www.latex-project.org/lppl.txt
|
35
|
+
# % and version 1.3 or later is part of all distributions of LaTeX
|
36
|
+
# % version 2005/12/01 or later.
|
37
|
+
# %
|
38
|
+
# % This work has the LPPL maintenance status `maintained'.
|
39
|
+
# %
|
40
|
+
# % The Current Maintainer of this work is Knut Lickert.
|
41
|
+
# %
|
42
|
+
#
|
43
|
+
|
44
|
+
require 'log4r'
|
45
|
+
require 'zip/zip' #The log files are stored in a zip.
|
46
|
+
require 'optparse'
|
47
|
+
require 'yaml'
|
48
|
+
|
49
|
+
#Some Tools have screen output.
|
50
|
+
#runtex should run silent in background, so we have to redirect the output.
|
51
|
+
require 'catch_output'
|
52
|
+
|
53
|
+
module RunTeX
|
54
|
+
CONFIGURATION = File.dirname(__FILE__) + '/runtex_pathes.yaml'
|
55
|
+
|
56
|
+
require 'runtex_job_chain'
|
57
|
+
require 'runtex_tool'
|
58
|
+
require 'runtex_latex'
|
59
|
+
require 'runtex_makeindex'
|
60
|
+
require 'runtex_splitindex'
|
61
|
+
require 'runtex_rail'
|
62
|
+
require 'runtex_bibtex'
|
63
|
+
end #module runtex
|
64
|
+
|
65
|
+
#Analyse from ARGV when called from Desktop
|
66
|
+
def start_from_desktop( )
|
67
|
+
|
68
|
+
options = {
|
69
|
+
:format => 'pdflualatex',
|
70
|
+
:overfull => 100, #report overfull boxes > this value
|
71
|
+
:underfull => 9000, #report underfull boxes > this badness
|
72
|
+
}
|
73
|
+
|
74
|
+
optparser = OptionParser.new{ |opts|
|
75
|
+
opts.banner = <<BANNER
|
76
|
+
runtex.rb: Translate a TeX-File.
|
77
|
+
This tool checks, how often the file must be translated to
|
78
|
+
create a document with correct references.
|
79
|
+
Usage:
|
80
|
+
runtex.rb [switches] source[.tex]
|
81
|
+
|
82
|
+
Known Problems:
|
83
|
+
- Not tested on different systems (PS2PDF will work only on windows)
|
84
|
+
- The errors statistic count some errors twice
|
85
|
+
(or do you want to loose errors)
|
86
|
+
- index.sty is not supported. Use index2.sty instead
|
87
|
+
Detailed informations: http://ruby.lickert.net/runtex
|
88
|
+
|
89
|
+
Switches:
|
90
|
+
-h <switch> for details of option <switch>
|
91
|
+
BANNER
|
92
|
+
|
93
|
+
#~ opts.on('-h', '--help' ){ |selection|
|
94
|
+
#~ puts opts.banner()
|
95
|
+
#~ STDIN.getc if @@wait
|
96
|
+
#~ exit
|
97
|
+
#~ }
|
98
|
+
#~ opts.on('-H', '--HELP' ){ |selection|
|
99
|
+
#~ puts opt.help( '--HELP' )
|
100
|
+
#~ STDIN.getc if @@wait
|
101
|
+
#~ exit
|
102
|
+
#~ }
|
103
|
+
#~ puts "Option #{option}#{selection} not known\nUse -h for help"
|
104
|
+
|
105
|
+
opts.on('-a', "--action ACTION", '--chain ACTION', %Q|Define the action chain
|
106
|
+
A chain defines the steps from source to the target.
|
107
|
+
- pdfLaTeX
|
108
|
+
- pdfLuaLaTeX [default]
|
109
|
+
- XeLaTeX
|
110
|
+
- LaTeX
|
111
|
+
- LaTeXPS Call LaTeX and then create a
|
112
|
+
Postscript file (dvips)
|
113
|
+
- LaTeXPSPDF Call LaTeX and then create a PDF
|
114
|
+
via dvips and ghostscript
|
115
|
+
-LaTeXPDF Call LaTeX and then create a PDF with dvipdfm
|
116
|
+
remark: Each tool may define a "subchain"
|
117
|
+
(pdf)LaTeX calls bibtex, makeindex, rail if necessary|.gsub(/^\t/, '')
|
118
|
+
){ |selection|
|
119
|
+
selection = '?' if ! selection.respond_to?( :downcase )
|
120
|
+
case selection.downcase
|
121
|
+
when 'latex', 'pdflatex', 'pdflualatex', 'xelatex'
|
122
|
+
options[:format] = selection.to_sym
|
123
|
+
when 'latexps', 'latexpdf', 'latexpspdf'
|
124
|
+
puts "Sorry, not supported yet"
|
125
|
+
else
|
126
|
+
puts "Action chain #{selection} not valid"
|
127
|
+
STDIN.getc if $stdin.tty?
|
128
|
+
exit
|
129
|
+
end #case selection
|
130
|
+
}
|
131
|
+
|
132
|
+
opts.on('-o', "--overfull OVERFULL",
|
133
|
+
"Set the limit, from which overfull boxes are reported"
|
134
|
+
){ |selection|
|
135
|
+
options[:overfull] = selection.to_i
|
136
|
+
}
|
137
|
+
|
138
|
+
opts.on('-u', "--underfull UNDERFULL", "Set the limit, from which underfull boxes are reported"){ |selection|
|
139
|
+
options[:underfull] = selection.to_i
|
140
|
+
}
|
141
|
+
|
142
|
+
#~ opts.on('-p', "--precompile PRE", %q|The given file(s) are precompiled.
|
143
|
+
#~ Conversions of the precompiler:
|
144
|
+
#~ - listings.sty:
|
145
|
+
#~ \lstinputlisting[fromlabel=<label>,tolabel=<label>]{file} to
|
146
|
+
#~ \lstinputlisting[firstline=<num>,lastline=<num>] {file}
|
147
|
+
#~ file must contain tags like "TeXlabel{label}"
|
148
|
+
#~ |.gsub(/^\t/, '')){ |selection|
|
149
|
+
#~ selection.each{|f|
|
150
|
+
#~ Precompile.mix_references!( f )
|
151
|
+
#~ }
|
152
|
+
#~ }
|
153
|
+
}
|
154
|
+
|
155
|
+
begin
|
156
|
+
optparser.parse!
|
157
|
+
#~ rescue OptionParser::MissingArgument => err
|
158
|
+
#~ rescue OptionParser::InvalidOption => err
|
159
|
+
rescue OptionParser::MissingArgument, OptionParser::InvalidOption => err
|
160
|
+
puts "Error:\t#{err}"
|
161
|
+
#Ausgabe der Schnittstelle
|
162
|
+
puts optparser.banner
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
if ARGV.size == 0
|
167
|
+
#Message if called by exe created with rubyscript2exe
|
168
|
+
puts "Add file to translate or -h for help" if /app.rb/ =~ $0
|
169
|
+
end
|
170
|
+
ARGV.each{|arg|
|
171
|
+
if arg =~ /\.(tex|dtx)$/
|
172
|
+
job = RunTeX::Job_chain.new(arg, options)
|
173
|
+
else
|
174
|
+
job = RunTeX::Job_chain.new("#{arg}.tex", options)
|
175
|
+
end
|
176
|
+
job.log.level = Log4r::WARN
|
177
|
+
job.start(options[:format])
|
178
|
+
}
|
179
|
+
|
180
|
+
if ARGV.empty?
|
181
|
+
puts "No TeX-File given"
|
182
|
+
exit
|
183
|
+
end
|
184
|
+
|
185
|
+
puts "Thanks for using #{File.basename($0)}."
|
186
|
+
STDIN.getc if $stdin.tty?
|
187
|
+
|
188
|
+
end #start_from_desktop( )
|
189
|
+
|
190
|
+
start_from_desktop( ) if __FILE__ == $0
|
191
|
+
|
192
|
+
__END__
|
193
|
+
lox: fixme.sty
|
194
|
+
out: hyperref.ste
|
195
|
+
tex: TeX-Source-file
|
196
|
+
aux: Auxiliary file, created by LaTeX
|
197
|
+
toc: table of contents (LaTeX)
|
198
|
+
bib: Bibliography, define bib-entries for BibTeX
|
199
|
+
bbl: Result of BibTeX
|
200
|
+
blg: Logfile from BibTeX
|
201
|
+
idx: Index, input for makeindex (LaTeX)
|
202
|
+
ind: Index, output from makeindex
|
203
|
+
ilg: Logfile by makeindex
|
204
|
+
glo: Glossary, definitions for glossaries.sty
|
205
|
+
gls: Glossary, corresponds to ind (glossaries.sty)
|
206
|
+
glg: Logfile from glossaries.sty, corresponds to ilg
|
207
|
+
ist: Style file for makeindex
|
208
|
+
rai: Rail-input file (rail)
|
209
|
+
rao: Rail-output file (rail)
|
210
|
+
log: logfile (TeX)
|
211
|
+
dvi: Result of (La)TeX.
|
212
|
+
pdf: Portable document format, result of the tex-run
|
213
|
+
sty: Style-file (LaTeX)
|
214
|
+
cls: document class definition (LaTeX)
|
215
|
+
dtx: source for cls/sty-files. (LaTeX)
|
216
|
+
ins: Install-file to create cls/sty from dtx. (LaTeX)
|
217
|
+
nav: Help-File Navigation (hyperref?) (LaTeX)
|
218
|
+
ps: Post-Script
|
219
|
+
eps: encapsulated Post-Script
|
220
|
+
lof: List of figures (LaTeX)
|
221
|
+
lot: List of tables (LaTeX)
|