class HTMLProcessor
# called before parsing anything
def start_parsing(scope_name)
@line = ""
@offset = 0
@text= []
end
# called after parsing everything
def end_parsing(scope_name)
@text.each_with_index do |line, index|
@text[index] = "#{line}"
end
puts @text.join("")
end
# called before processing a line
def new_line(line_content)
@offset = 0
@line = line_content.clone
@text << @line
end
def open_tag(tag_name, position_in_current_line)
tag = ""
@line.insert(position_in_current_line + @offset, tag)
@offset += tag.size
end
def close_tag(tag_name, position_in_current_line)
tag = ""
@line.insert(position_in_current_line + @offset, tag)
@offset += tag.size
end
end
syntax = Textpow.syntax('ruby') # or 'source.ruby' or 'lib/textpow/syntax/source.ruby.syntax'
processor = HTMLProcessor.new
syntax.parse(text, processor)
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])