Top Level Namespace

Constant Summary collapse

Gem_Ruleset_Path =

enough that the main code can find these rules.

File.dirname(__FILE__) + "/rules"
Gem_Rulesets =
Dir.glob(Gem_Ruleset_Path + "/*")
Gedit_Mode =

if run with -g, insert a space between line and column, so that gedit linkparser.py at least parses the file and line number

if(ARGV.include?("-g"))
  ARGV.delete("-g")
  true
else
  false
end
PctCensored_phrases =

before stripping comments

Hash.new
PreCensored_phrases =

before stripping cites

Hash.new
Censored_phrases =

the rest.

Hash.new
PathList =
if(override_rule_paths) then 
  override_rule_paths
else
  (Gem_Rulesets ? Gem_Rulesets : [] ) + 
    Dir.glob("/etc/style-check.d/*") + 
    Dir.glob(ENV["HOME"] + "/.style-check.d/*") + 
    [ ENV["HOME"] + "/.style-censor", "./censor-dict", "/etc/style-censor", "./style-censor" ]
end
De_comment =
Regexp.new('(([^\\\\]%.*)|(^%.*))$')
De_command =

though newcommand could gobble both parameters…

Regexp.new('(~?\\\\(' + ignoredCommands.join('|') + ')(\[[^\]]*\])?\{[^{}]*\})')
De_verb =
Regexp.new('\\\\verb(.)[^\1]*\1')
De_math =
Regexp.new('[^\\\\]\$.*[^\\\\]\$|^\$.*[^\\\\]\$')
Input_files =
ARGV

Instance Method Summary collapse

Instance Method Details

#do_cns(line, file, linenum, phra_hash) ⇒ Object



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/style-check.rb', line 171

def do_cns(line, file, linenum, phra_hash)
  # if line =~ /\\caption/ && file =~ /Mapping/ then
    # puts "validating: '#{line}'"
  # end
  m = nil
  r = nil # so we can keep it as a side-effect of the detect call
  detected = nil
  windows_detect_bug_avoider = nil
  # if m = $prefilter.match(line) then
    if(detected = phra_hash.keys.detect { |r| m = r.match(line) and (line.index("\n") == nil or m.begin(0) < line.index("\n"))  } ) then
      matchedlines = ( m.end(0) <= ( line.index("\n") or 0 ) ) ? line.gsub(/\n.*/,'') : line.chomp
      puts "%s:%d:%s%d: %s (%s)" % [ file, linenum, Gedit_Mode ? ' ': '', m.begin(0)+1, matchedlines, m.to_s.tr("\n", ' ') ]
      $exit_status = 1 if(!phra_hash[detected] =~ /\?\s*$/) 
      if($VERBOSE && phra_hash[detected]) then
        puts "  " + phra_hash[detected]
        phra_hash[detected] = nil # don't print the reason more than once
      end
    end
  # end
end