trex 1.0.5 → 1.0.6

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.
Files changed (2) hide show
  1. data/lib/trex.rb +26 -4
  2. metadata +2 -2
data/lib/trex.rb CHANGED
@@ -251,20 +251,42 @@ class TReX
251
251
  self.check_source
252
252
 
253
253
  detexed = Tempfile.new(@options.source)
254
+ # strip away spell warnings occuring before the \begin{document}
255
+ documentStartLine = self.detect_document_start_line
254
256
  # strip all the latex commands using detex
255
- `detex #{@options.source} > #{detexed.path}`
257
+ `tail -n +#{documentStartLine} #{@options.source} | detex -e stcode,ccode,listing > #{detexed.path}`
256
258
 
257
259
  # run the spellchecker
258
260
  output = `atdtool #{detexed.path}`
259
261
  output = output.gsub(detexed.path, File.basename(@options.source))
260
-
261
- detexed.unlink
262
262
 
263
- puts output
263
+ detexed.unlink
264
+ output.lines do |line|
265
+ if line.match(/^ /)
266
+ puts line
267
+ else
268
+ /(?<file>[^:]+)\:(?<line>\d+)\:(?<rest>.*)/ =~ line
269
+ print file
270
+ print ':'
271
+ print line.to_i + documentStartLine - 1
272
+ print ':'
273
+ puts rest
274
+ end
275
+ end
264
276
  end
265
277
 
266
278
  # ------------------------------------------------------------------------
267
279
  protected
280
+
281
+ def detect_document_start_line
282
+ lineNumber = 0
283
+ File.open(@options.source) do |f|
284
+ f.each_line do |line|
285
+ return lineNumber if line.match(/^\\begin{document}/)
286
+ lineNumber += 1
287
+ end
288
+ end
289
+ end
268
290
 
269
291
  # Specify options
270
292
  def option_parser
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-05-29 00:00:00.000000000 Z
14
+ date: 2012-06-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: term-ansicolor