)]
delete[delete(-)plain(#)]
comment( # License:: LGPL / ask the author)
delete[delete(-)plain(# Version:: 1.0 (2006-Feb-3\))]
insert[insert(+)plain(# Version:: 1.1 (2006-Oct-19\))]
comment( #)
comment( # A WordList is a Hash with some additional features.)
comment( # It is intended to be used for keyword recognition.)
comment( #)
comment( # WordList is highly optimized to be used in Scanners,)
delete[delete(-)plain(# typically to decide whether a given ident is a keyword.)]
insert[insert(+)plain(# typically to decide whether a given ident is a special token.)]
comment( #)
comment( # For case insensitive words use CaseIgnoringWordList.)
comment( #)
change[change(@@)plain( -47,25 +51,30 )change(@@)]
comment( # ...)
comment( class WordList < Hash)
comment( )
delete[delete(-)plain( # Create a WordList for the given +words+.)]
delete[delete(-)plain( #)]
delete[delete(-)plain( # This WordList responds to [] with +true+, if the word is)]
delete[delete(-)plain( # in +words+, and with +false+ otherwise.)]
delete[delete(-)plain( def self.for words)]
delete[delete(-)plain( new.add words)]
delete[delete(-)plain( end)]
delete[delete(-)]
comment( # Creates a new WordList with +default+ as default value.)
delete[delete(-)plain( def initialize default = false, &block)]
delete[delete(-)plain( super default, &block)]
insert[insert(+)plain( # )]
insert[insert(+)plain( # You can activate +caching+ to store the results for every [] request.)]
insert[insert(+)plain( # )]
insert[insert(+)plain( # With caching, methods like +include?+ or +delete+ may no longer behave)]
insert[insert(+)plain( # as you expect. Therefore, it is recommended to use the [] method only.)]
insert[insert(+)plain( def initialize default = false, caching = false, &block)]
insert[insert(+)plain( if block)]
insert[insert(+)plain( raise ArgumentError, 'Can\\'t combine block with caching.' if caching)]
insert[insert(+)plain( super(&block\))]
insert[insert(+)plain( else)]
insert[insert(+)plain( if caching)]
insert[insert(+)plain( super(\) do |h, k|)]
insert[insert(+)plain( h[k] = h.fetch k, default)]
insert[insert(+)plain( end)]
insert[insert(+)plain( else)]
insert[insert(+)plain( super default)]
insert[insert(+)plain( end)]
insert[insert(+)plain( end)]
comment( end)
comment( )
delete[delete(-)plain( # Checks if a word is included.)]
delete[delete(-)plain( def include? word)]
delete[delete(-)plain( has_key? word)]
delete[delete(-)plain( end)]
delete[delete(-)]
comment( # Add words to the list and associate them with +kind+.)
insert[insert(+)plain( # )]
insert[insert(+)plain( # Returns +self+, so you can concat add calls.)]
comment( def add words, kind = true)
comment( words.each do |word|)
comment( self[word] = kind)
change[change(@@)plain( -78,24 +87,30 )change(@@)]
comment( )
comment( # A CaseIgnoringWordList is like a WordList, only that)
comment( # keys are compared case-insensitively.)
insert[insert(+)plain(# )]
insert[insert(+)plain(# Ignoring the text case is realized by sending the +downcase+ message to)]
insert[insert(+)plain(# all keys.)]
insert[insert(+)plain(# )]
insert[insert(+)plain(# Caching usually makes a CaseIgnoringWordList faster, but it has to be)]
insert[insert(+)plain(# activated explicitely.)]
comment( class CaseIgnoringWordList < WordList)
comment( )
delete[delete(-)plain( # Creates a new WordList with +default+ as default value.)]
delete[delete(-)plain( #)]
delete[delete(-)plain( # Text case is ignored.)]
delete[delete(-)plain( def initialize default = false, &block)]
delete[delete(-)plain( block ||= proc do |h, k|)]
delete[delete(-)plain( h[k] = h.fetch k.downcase, default)]
insert[insert(+)plain( # Creates a new case-insensitive WordList with +default+ as default value.)]
insert[insert(+)plain( # )]
insert[insert(+)plain( # You can activate caching to store the results for every [] request.)]
insert[insert(+)plain( def initialize default = false, caching = false)]
insert[insert(+)plain( if caching)]
insert[insert(+)plain( super(default, false\) do |h, k|)]
insert[insert(+)plain( h[k] = h.fetch k.downcase, default)]
insert[insert(+)plain( end)]
insert[insert(+)plain( else)]
insert[insert(+)plain( def self.[] key # :nodoc:)]
insert[insert(+)plain( super(key.downcase\))]
insert[insert(+)plain( end)]
comment( end)
delete[delete(-)plain( super default)]
comment( end)
comment( )
delete[delete(-)plain( # Checks if a word is included.)]
delete[delete(-)plain( def include? word)]
delete[delete(-)plain( has_key? word.downcase)]
delete[delete(-)plain( end)]
delete[delete(-)]
delete[delete(-)plain( # Add words to the list and associate them with +kind+.)]
insert[insert(+)plain( # Add +words+ to the list and associate them with +kind+.)]
comment( def add words, kind = true)
comment( words.each do |word|)
comment( self[word.downcase] = kind)
change[change(@@)plain( -104,3 +119,5 )change(@@)]
comment( end)
comment( )
comment( end)
insert[insert(+)]
insert[insert(+)plain(end)]
change[change(\\ )plain(No newline at end of file)]
head[head(Index: )plain(lib/coderay/styles/cycnus.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/styles/cycnus.rb (revision 200\))]
head[head(+++ )plain(lib/coderay/styles/cycnus.rb (revision 250\))]
change[change(@@)plain( -42,12 +42,14 )change(@@)]
comment( MAIN)
comment( )
comment( TOKEN_COLORS = <<-'TOKENS')
insert[insert(+)plain(.debug { color:white ! important; background:blue ! important; })]
insert[insert(+)]
comment( .af { color:#00C })
comment( .an { color:#007 })
comment( .av { color:#700 })
comment( .aw { color:#C00 })
comment( .bi { color:#509; font-weight:bold })
delete[delete(-)plain(.c { color:#888 })]
insert[insert(+)plain(.c { color:#666; })]
comment( )
comment( .ch { color:#04D })
comment( .ch .k { color:#04D })
change[change(@@)plain( -83,7 +85,7 )change(@@)]
comment( .la { color:#970; font-weight:bold })
comment( .lv { color:#963 })
comment( .oc { color:#40E; font-weight:bold })
delete[delete(-)plain(.on { color:#000; font-weight:bold })]
insert[insert(+)plain(.of { color:#000; font-weight:bold })]
comment( .op { })
comment( .pc { color:#038; font-weight:bold })
comment( .pd { color:#369; font-weight:bold })
head[head(Index: )plain(lib/coderay/styles/murphy.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/styles/murphy.rb (revision 200\))]
head[head(+++ )plain(lib/coderay/styles/murphy.rb (revision 250\))]
change[change(@@)plain( -47,7 +47,7 )change(@@)]
comment( .av { color:#700; })
comment( .aw { color:#C00; })
comment( .bi { color:#509; font-weight:bold; })
delete[delete(-)plain(.c { color:#666; })]
insert[insert(+)plain(.c { color:#555; background-color: black; })]
comment( )
comment( .ch { color:#88F; })
comment( .ch .k { color:#04D; })
change[change(@@)plain( -77,7 +77,7 )change(@@)]
comment( .la { color:#970; font-weight:bold; })
comment( .lv { color:#963; })
comment( .oc { color:#40E; font-weight:bold; })
delete[delete(-)plain(.on { color:#000; font-weight:bold; })]
insert[insert(+)plain(.of { color:#000; font-weight:bold; })]
comment( .op { })
comment( .pc { color:#08f; font-weight:bold; })
comment( .pd { color:#369; font-weight:bold; })
head[head(Index: )plain(lib/coderay/tokens.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/tokens.rb (revision 200\))]
head[head(+++ )plain(lib/coderay/tokens.rb (revision 250\))]
change[change(@@)plain( -115,7 +115,7 )change(@@)]
comment( # tokens.each_text_token { |text, kind| text.replace html_escape(text\) })
comment( def each_text_token)
comment( each do |text, kind|)
delete[delete(-)plain( next unless text.respond_to? :to_str)]
insert[insert(+)plain( next unless text.is_a? ::String)]
comment( yield text, kind)
comment( end)
comment( end)
change[change(@@)plain( -252,7 +252,7 )change(@@)]
comment( #)
comment( # You can configure the level of compression,)
comment( # but the default value 7 should be what you want)
delete[delete(-)plain( # in most cases as it is a good comprimise between)]
insert[insert(+)plain( # in most cases as it is a good compromise between)]
comment( # speed and compression rate.)
comment( #)
comment( # See GZip module.)
change[change(@@)plain( -267,9 +267,20 )change(@@)]
comment( # Should be equal to the input size before)
comment( # scanning.)
comment( def text_size)
delete[delete(-)plain( map { |t, k| t }.join.size)]
insert[insert(+)plain( size = 0)]
insert[insert(+)plain( each_text_token do |t, k|)]
insert[insert(+)plain( size + t.size)]
insert[insert(+)plain( end)]
insert[insert(+)plain( size)]
comment( end)
comment( )
insert[insert(+)plain( # The total size of the tokens.)]
insert[insert(+)plain( # Should be equal to the input size before)]
insert[insert(+)plain( # scanning.)]
insert[insert(+)plain( def text)]
insert[insert(+)plain( map { |t, k| t if t.is_a? ::String }.join)]
insert[insert(+)plain( end)]
insert[insert(+)]
comment( # Include this module to give an object an #undump)
comment( # method.)
comment( #)
change[change(@@)plain( -342,7 +353,7 )change(@@)]
comment( #)
comment( # Returns self.)
comment( def << token)
delete[delete(-)plain( @callback.call token)]
insert[insert(+)plain( @callback.call(*token\))]
comment( @size += 1)
comment( self)
comment( end)
change[change(@@)plain( -365,4 +376,8 )change(@@)]
comment( )
comment( end)
comment( )
insert[insert(+)plain( )]
insert[insert(+)plain( # Token name abbreviations)]
insert[insert(+)plain( require 'coderay/token_classes')]
insert[insert(+)]
comment( end)
head[head(Index: )plain(lib/coderay/duo.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/duo.rb (revision 200\))]
head[head(+++ )plain(lib/coderay/duo.rb (revision 250\))]
change[change(@@)plain( -4,26 +4,84 )change(@@)]
comment( #)
comment( # $Id: scanner.rb 123 2006-03-21 14:46:34Z murphy $)
comment( #)
delete[delete(-)plain( # TODO: Doc.)]
insert[insert(+)plain( # A Duo is a convenient way to use CodeRay. You just create a Duo,)]
insert[insert(+)plain( # giving it a lang (language of the input code\) and a format (desired)]
insert[insert(+)plain( # output format\), and call Duo#highlight with the code.)]
insert[insert(+)plain( # )]
insert[insert(+)plain( # Duo makes it easy to re-use both scanner and encoder for a repetitive)]
insert[insert(+)plain( # task. It also provides a very easy interface syntax:)]
insert[insert(+)plain( # )]
insert[insert(+)plain( # require 'coderay')]
insert[insert(+)plain( # CodeRay::Duo[:python, :div].highlight 'import this')]
insert[insert(+)plain( # )]
insert[insert(+)plain( # Until you want to do uncommon things with CodeRay, I recommend to use)]
insert[insert(+)plain( # this method, since it takes care of everything.)]
comment( class Duo)
comment( )
delete[delete(-)plain( attr_accessor :scanner, :encoder)]
delete[delete(-)]
delete[delete(-)plain( def initialize lang, format, options = {})]
delete[delete(-)plain( @scanner = CodeRay.scanner lang, CodeRay.get_scanner_options(options\))]
delete[delete(-)plain( @encoder = CodeRay.encoder format, options)]
insert[insert(+)plain( attr_accessor :lang, :format, :options)]
insert[insert(+)plain( )]
insert[insert(+)plain( # Create a new Duo, holding a lang and a format to highlight code.)]
insert[insert(+)plain( # )]
insert[insert(+)plain( # simple:)]
insert[insert(+)plain( # CodeRay::Duo[:ruby, :page].highlight 'bla 42')]
insert[insert(+)plain( # )]
insert[insert(+)plain( # streaming:)]
insert[insert(+)plain( # CodeRay::Duo[:ruby, :page].highlight 'bar 23', :stream => true)]
insert[insert(+)plain( # )]
insert[insert(+)plain( # with options:)]
insert[insert(+)plain( # CodeRay::Duo[:ruby, :html, :hint => :debug].highlight '????::??')]
insert[insert(+)plain( # )]
insert[insert(+)plain( # alternative syntax without options:)]
insert[insert(+)plain( # CodeRay::Duo[:ruby => :statistic].encode 'class << self; end')]
insert[insert(+)plain( # )]
insert[insert(+)plain( # alternative syntax with options:)]
insert[insert(+)plain( # CodeRay::Duo[{ :ruby => :statistic }, :do => :something].encode 'abc')]
insert[insert(+)plain( # )]
insert[insert(+)plain( # The options are forwarded to scanner and encoder)]
insert[insert(+)plain( # (see CodeRay.get_scanner_options\).)]
insert[insert(+)plain( def initialize lang = nil, format = nil, options = {})]
insert[insert(+)plain( if format == nil and lang.is_a? Hash and lang.size == 1)]
insert[insert(+)plain( @lang = lang.keys.first)]
insert[insert(+)plain( @format = lang[@lang])]
insert[insert(+)plain( else)]
insert[insert(+)plain( @lang = lang)]
insert[insert(+)plain( @format = format)]
insert[insert(+)plain( end)]
insert[insert(+)plain( @options = options)]
comment( end)
comment( )
comment( class << self)
insert[insert(+)plain( # To allow calls like Duo[:ruby, :html].highlight.)]
comment( alias [] new)
comment( end)
comment( )
delete[delete(-)plain( def encode code)]
delete[delete(-)plain( @scanner.string = code)]
delete[delete(-)plain( @encoder.encode_tokens(scanner.tokenize\))]
insert[insert(+)plain( # The scanner of the duo. Only created once.)]
insert[insert(+)plain( def scanner)]
insert[insert(+)plain( @scanner ||= CodeRay.scanner @lang, CodeRay.get_scanner_options(@options\))]
comment( end)
insert[insert(+)plain( )]
insert[insert(+)plain( # The encoder of the duo. Only created once.)]
insert[insert(+)plain( def encoder)]
insert[insert(+)plain( @encoder ||= CodeRay.encoder @format, @options)]
insert[insert(+)plain( end)]
insert[insert(+)plain( )]
insert[insert(+)plain( # Tokenize and highlight the code using +scanner+ and +encoder+.)]
insert[insert(+)plain( #)]
insert[insert(+)plain( # If the :stream option is set, the Duo will go into streaming mode,)]
insert[insert(+)plain( # saving memory for the cost of time.)]
insert[insert(+)plain( def encode code, options = { :stream => false })]
insert[insert(+)plain( stream = options.delete :stream)]
insert[insert(+)plain( options = @options.merge options)]
insert[insert(+)plain( if stream)]
insert[insert(+)plain( encoder.encode_stream(code, @lang, options\))]
insert[insert(+)plain( else)]
insert[insert(+)plain( scanner.code = code)]
insert[insert(+)plain( encoder.encode_tokens(scanner.tokenize, options\))]
insert[insert(+)plain( end)]
insert[insert(+)plain( end)]
comment( alias highlight encode)
comment( )
comment( end)
comment( )
comment( end)
insert[insert(+)]
head[head(Index: )plain(lib/coderay/scanner.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/scanner.rb (revision 200\))]
head[head(+++ )plain(lib/coderay/scanner.rb (revision 250\))]
change[change(@@)plain( -66,8 +66,18 )change(@@)]
comment( end)
comment( )
comment( def normify code)
delete[delete(-)plain( code = code.to_s.to_unix)]
insert[insert(+)plain( code = code.to_s)]
insert[insert(+)plain( code.force_encoding 'binary' if code.respond_to? :force_encoding)]
insert[insert(+)plain( code.to_unix)]
comment( end)
insert[insert(+)plain( )]
insert[insert(+)plain( def file_extension extension = nil)]
insert[insert(+)plain( if extension)]
insert[insert(+)plain( @file_extension = extension.to_s)]
insert[insert(+)plain( else)]
insert[insert(+)plain( @file_extension ||= plugin_id.to_s)]
insert[insert(+)plain( end)]
insert[insert(+)plain( end )]
comment( )
comment( end)
comment( )
change[change(@@)plain( -117,9 +127,6 )change(@@)]
comment( setup)
comment( end)
comment( )
delete[delete(-)plain( # More mnemonic accessor name for the input string.)]
delete[delete(-)plain( alias code string)]
delete[delete(-)]
comment( def reset)
comment( super)
comment( reset_instance)
change[change(@@)plain( -131,6 +138,10 )change(@@)]
comment( reset_instance)
comment( end)
comment( )
insert[insert(+)plain( # More mnemonic accessor name for the input string.)]
insert[insert(+)plain( alias code string)]
insert[insert(+)plain( alias code= string=)]
insert[insert(+)]
comment( # Scans the code and returns all tokens in a Tokens object.)
comment( def tokenize new_string=nil, options = {})
comment( options = @options.merge(options\))
change[change(@@)plain( -148,6 +159,11 )change(@@)]
comment( def tokens)
comment( @cached_tokens ||= tokenize)
comment( end)
insert[insert(+)plain( )]
insert[insert(+)plain( # Whether the scanner is in streaming mode.)]
insert[insert(+)plain( def streaming?)]
insert[insert(+)plain( !!@options[:stream])]
insert[insert(+)plain( end)]
comment( )
comment( # Traverses the tokens.)
comment( def each &block)
change[change(@@)plain( -195,7 +211,7 )change(@@)]
comment( raise ScanError, <<-EOE % [)
comment( )
comment( )
delete[delete(-)plain(***ERROR in %s: %s)]
insert[insert(+)plain(***ERROR in %s: %s (after %d tokens\))]
comment( )
comment( tokens:)
comment( %s)
change[change(@@)plain( -211,13 +227,14 )change(@@)]
comment( ***ERROR***)
comment( )
comment( EOE)
delete[delete(-)plain( File.basename(caller[0]\),)]
delete[delete(-)plain( msg,)]
delete[delete(-)plain( tokens.last(10\).map { |t| t.inspect }.join("\\n"\),)]
delete[delete(-)plain( line, pos,)]
delete[delete(-)plain( matched, state, bol?, eos?,)]
delete[delete(-)plain( string[pos-ambit,ambit],)]
delete[delete(-)plain( string[pos,ambit],)]
insert[insert(+)plain( File.basename(caller[0]\),)]
insert[insert(+)plain( msg,)]
insert[insert(+)plain( tokens.size,)]
insert[insert(+)plain( tokens.last(10\).map { |t| t.inspect }.join("\\n"\),)]
insert[insert(+)plain( line, pos,)]
insert[insert(+)plain( matched, state, bol?, eos?,)]
insert[insert(+)plain( string[pos-ambit,ambit],)]
insert[insert(+)plain( string[pos,ambit],)]
comment( ])
comment( end)
comment( )
head[head(Index: )plain(lib/coderay/for_redcloth.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/for_redcloth.rb (revision 0\))]
head[head(+++ )plain(lib/coderay/for_redcloth.rb (revision 250\))]
change[change(@@)plain( -0,0 +1,72 )change(@@)]
insert[insert(+)plain(module CodeRay # :nodoc:)]
insert[insert(+)plain( )]
insert[insert(+)plain( # A little hack to enable CodeRay highlighting in RedCloth.)]
insert[insert(+)plain( # )]
insert[insert(+)plain( # Usage:)]
insert[insert(+)plain( # require 'coderay')]
insert[insert(+)plain( # require 'coderay/for_redcloth')]
insert[insert(+)plain( # RedCloth.new('@[ruby]puts "Hello, World!"@'\).to_html)]
insert[insert(+)plain( # )]
insert[insert(+)plain( # Make sure you have RedCloth 4.0.3 activated, for example by calling)]
insert[insert(+)plain( # require 'rubygems')]
insert[insert(+)plain( # before RedCloth is loaded and before calling CodeRay.for_redcloth.)]
insert[insert(+)plain( module ForRedCloth)]
insert[insert(+)plain( )]
insert[insert(+)plain( def self.install)]
insert[insert(+)plain( gem 'RedCloth', '>= 4.0.3' rescue nil)]
insert[insert(+)plain( require 'redcloth')]
insert[insert(+)plain( raise 'CodeRay.for_redcloth needs RedCloth 4.0.3 or later.' unless RedCloth::VERSION.to_s >= '4.0.3')]
insert[insert(+)plain( RedCloth::TextileDoc.send :include, ForRedCloth::TextileDoc)]
insert[insert(+)plain( RedCloth::Formatters::HTML.module_eval do)]
insert[insert(+)plain( def unescape(html\))]
insert[insert(+)plain( replacements = {)]
insert[insert(+)plain( '&' => '&',)]
insert[insert(+)plain( '"' => '"',)]
insert[insert(+)plain( '>' => '>',)]
insert[insert(+)plain( '<' => '<',)]
insert[insert(+)plain( })]
insert[insert(+)plain( html.gsub(/&(?:amp|quot|[gl]t\);/\) { |entity| replacements[entity] })]
insert[insert(+)plain( end)]
insert[insert(+)plain( undef_method :code, :bc_open, :bc_close, :escape_pre)]
insert[insert(+)plain( def code(opts\) # :nodoc:)]
insert[insert(+)plain( opts[:block] = true)]
insert[insert(+)plain( if opts[:lang] && !filter_coderay)]
insert[insert(+)plain( require 'coderay')]
insert[insert(+)plain( @in_bc ||= nil)]
insert[insert(+)plain( format = @in_bc ? :div : :span)]
insert[insert(+)plain( highlighted_code = CodeRay.encode opts[:text], opts[:lang], format, :stream => true)]
insert[insert(+)plain( highlighted_code.sub!(/\\A<(span|div\)/\) { |m| m + pba(@in_bc || opts\) })]
insert[insert(+)plain( highlighted_code = unescape(highlighted_code\) unless @in_bc)]
insert[insert(+)plain( highlighted_code)]
insert[insert(+)plain( else)]
insert[insert(+)plain( "#{opts[:text]}
")]
insert[insert(+)plain( end)]
insert[insert(+)plain( end)]
insert[insert(+)plain( def bc_open(opts\) # :nodoc:)]
insert[insert(+)plain( opts[:block] = true)]
insert[insert(+)plain( @in_bc = opts)]
insert[insert(+)plain( opts[:lang] ? '' : "")]
insert[insert(+)plain( end)]
insert[insert(+)plain( def bc_close(opts\) # :nodoc:)]
insert[insert(+)plain( @in_bc = nil)]
insert[insert(+)plain( opts[:lang] ? '' : "
\\n")]
insert[insert(+)plain( end)]
insert[insert(+)plain( def escape_pre(text\))]
insert[insert(+)plain( if @in_bc ||= nil)]
insert[insert(+)plain( text)]
insert[insert(+)plain( else)]
insert[insert(+)plain( html_esc(text, :html_escape_preformatted\))]
insert[insert(+)plain( end)]
insert[insert(+)plain( end)]
insert[insert(+)plain( end)]
insert[insert(+)plain( end)]
insert[insert(+)]
insert[insert(+)plain( module TextileDoc # :nodoc:)]
insert[insert(+)plain( attr_accessor :filter_coderay)]
insert[insert(+)plain( end)]
insert[insert(+)plain( )]
insert[insert(+)plain( end)]
insert[insert(+)plain( )]
insert[insert(+)plain(end)]
insert[insert(+)]
insert[insert(+)plain(CodeRay::ForRedCloth.install)]
change[change(\\ )plain(No newline at end of file)]
head[head(Index: )plain(lib/coderay/scanners/ruby/patterns.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/scanners/ruby/patterns.rb (revision 200\))]
head[head(+++ )plain(lib/coderay/scanners/ruby/patterns.rb (revision 250\))]
change[change(@@)plain( -14,19 +14,14 )change(@@)]
comment( )
comment( DEF_KEYWORDS = %w[ def ])
comment( UNDEF_KEYWORDS = %w[ undef ])
insert[insert(+)plain( ALIAS_KEYWORDS = %w[ alias ])]
comment( MODULE_KEYWORDS = %w[class module])
comment( DEF_NEW_STATE = WordList.new(:initial\).)
comment( add(DEF_KEYWORDS, :def_expected\).)
comment( add(UNDEF_KEYWORDS, :undef_expected\).)
insert[insert(+)plain( add(ALIAS_KEYWORDS, :alias_expected\).)]
comment( add(MODULE_KEYWORDS, :module_expected\))
comment( )
delete[delete(-)plain( IDENTS_ALLOWING_REGEXP = %w[)]
delete[delete(-)plain( and or not while until unless if then elsif when sub sub! gsub gsub!)]
delete[delete(-)plain( scan slice slice! split)]
delete[delete(-)plain( ])]
delete[delete(-)plain( REGEXP_ALLOWED = WordList.new(false\).)]
delete[delete(-)plain( add(IDENTS_ALLOWING_REGEXP, :set\))]
delete[delete(-)]
comment( PREDEFINED_CONSTANTS = %w[)
comment( nil true false self)
comment( DATA ARGV ARGF __FILE__ __LINE__)
change[change(@@)plain( -41,19 +36,20 )change(@@)]
comment( METHOD_NAME = / #{IDENT} [?!]? /ox)
comment( METHOD_NAME_OPERATOR = /)
comment( \\*\\*? # multiplication and power)
delete[delete(-)plain( | [-+]@? # plus, minus)]
delete[delete(-)plain( | [\\/%&|^`~] # division, modulo or format strings, &and, |or, ^xor, `system`, tilde)]
insert[insert(+)plain( | [-+~]@? # plus, minus, tilde with and without @)]
insert[insert(+)plain( | [\\/%&|^`] # division, modulo or format strings, &and, |or, ^xor, `system`)]
comment( | \\[\\]=? # array getter and setter)
comment( | << | >> # append or shift left, shift right)
comment( | <=?>? | >=? # comparison, rocket operator)
delete[delete(-)plain( | ===? # simple equality and case equality)]
insert[insert(+)plain( | ===? | =~ # simple equality, case equality, match)]
insert[insert(+)plain( | ![~=@]? # negation with and without @, not-equal and not-match)]
comment( /ox)
comment( METHOD_NAME_EX = / #{IDENT} (?:[?!]|=(?!>\)\)? | #{METHOD_NAME_OPERATOR} /ox)
comment( INSTANCE_VARIABLE = / @ #{IDENT} /ox)
comment( CLASS_VARIABLE = / @@ #{IDENT} /ox)
comment( OBJECT_VARIABLE = / @@? #{IDENT} /ox)
comment( GLOBAL_VARIABLE = / \\$ (?: #{IDENT} | [1-9]\\d* | 0\\w* | [~&+`'=\\/,;_.<>!@$?*":\\\\] | -[a-zA-Z_0-9] \) /ox)
delete[delete(-)plain( PREFIX_VARIABLE = / #{GLOBAL_VARIABLE} |#{OBJECT_VARIABLE} /ox)]
insert[insert(+)plain( PREFIX_VARIABLE = / #{GLOBAL_VARIABLE} | #{OBJECT_VARIABLE} /ox)]
comment( VARIABLE = / @?@? #{IDENT} | #{GLOBAL_VARIABLE} /ox)
comment( )
comment( QUOTE_TO_TYPE = {)
change[change(@@)plain( -73,7 +69,7 )change(@@)]
comment( EXPONENT = / [eE] [+-]? #{DECIMAL} /ox)
comment( FLOAT_SUFFIX = / #{EXPONENT} | \\. #{DECIMAL} #{EXPONENT}? /ox)
comment( FLOAT_OR_INT = / #{DECIMAL} (?: #{FLOAT_SUFFIX} (\) \)? /ox)
delete[delete(-)plain( NUMERIC = / [-+]? (?: (?=0\) (?: #{OCTAL} | #{HEXADECIMAL} | #{BINARY} \) | #{FLOAT_OR_INT} \) /ox)]
insert[insert(+)plain( NUMERIC = / (?: (?=0\) (?: #{OCTAL} | #{HEXADECIMAL} | #{BINARY} \) | #{FLOAT_OR_INT} \) /ox)]
comment( )
comment( SYMBOL = /)
comment( :)
change[change(@@)plain( -83,6 +79,7 )change(@@)]
comment( | ['"])
comment( \))
comment( /ox)
insert[insert(+)plain( METHOD_NAME_OR_SYMBOL = / #{METHOD_NAME_EX} | #{SYMBOL} /ox)]
comment( )
comment( # TODO investigste \\M, \\c and \\C escape sequences)
comment( # (?: M-\\\\C-|C-\\\\M-|M-\\\\c|c\\\\M-|c|C-|M-\)? (?: \\\\ (?: [0-7]{3} | x[0-9A-Fa-f]{2} | . \) \))
change[change(@@)plain( -111,7 +108,7 )change(@@)]
comment( (?:)
comment( ( [A-Za-z_0-9]+ \) # $2 = delim)
comment( |)
delete[delete(-)plain( ( ["'`] \) # $3 = quote, type)]
insert[insert(+)plain( ( ["'`\\/] \) # $3 = quote, type)]
comment( ( [^\\n]*? \) \\3 # $4 = delim)
comment( \))
comment( /mx)
change[change(@@)plain( -129,15 +126,14 )change(@@)]
comment( /mx)
comment( )
comment( # Checks for a valid value to follow. This enables)
delete[delete(-)plain( # fancy_allowed in method calls.)]
insert[insert(+)plain( # value_expected in method calls without parentheses.)]
comment( VALUE_FOLLOWS = /)
delete[delete(-)plain( \\s+)]
insert[insert(+)plain( (?>[ \\t\\f\\v]+\))]
comment( (?:)
comment( [%\\/][^\\s=])
delete[delete(-)plain( |)]
delete[delete(-)plain( <<-?\\S)]
delete[delete(-)plain( |)]
delete[delete(-)plain( #{CHARACTER})]
insert[insert(+)plain( | <<-?\\S)]
insert[insert(+)plain( | [-+] \\d)]
insert[insert(+)plain( | #{CHARACTER})]
comment( \))
comment( /x)
comment( )
head[head(Index: )plain(lib/coderay/scanners/ruby.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/scanners/ruby.rb (revision 200\))]
head[head(+++ )plain(lib/coderay/scanners/ruby.rb (revision 250\))]
change[change(@@)plain( -18,6 +18,7 )change(@@)]
comment( include Streamable)
comment( )
comment( register_for :ruby)
insert[insert(+)plain( file_extension 'rb')]
comment( )
comment( helper :patterns)
comment( )
change[change(@@)plain( -90,15 +91,15 )change(@@)]
comment( end)
comment( )
comment( when '#')
delete[delete(-)plain( case peek(1\)[0])]
delete[delete(-)plain( when ?{)]
insert[insert(+)plain( case peek(1\))]
insert[insert(+)plain( when '{')]
comment( inline_block_stack << [state, depth, heredocs])
comment( value_expected = true)
comment( state = :initial)
comment( depth = 1)
comment( tokens << [:open, :inline])
comment( tokens << [match + getch, :inline_delimiter])
delete[delete(-)plain( when ?$, ?@)]
insert[insert(+)plain( when '$', '@')]
comment( tokens << [match, :escape])
comment( last_state = state # scan one token as normal code, then return here)
comment( state = :initial)
change[change(@@)plain( -121,36 +122,37 )change(@@)]
comment( # }}})
comment( else)
comment( # {{{)
delete[delete(-)plain( if match = scan(/ [ \\t\\f]+ | \\\\? \\n | \\# .* /x\) or)]
delete[delete(-)plain( ( bol? and match = scan(/#{patterns::RUBYDOC_OR_DATA}/o\) \))]
delete[delete(-)plain( case m = match[0])]
delete[delete(-)plain( when ?\\s, ?\\t, ?\\f)]
delete[delete(-)plain( match << scan(/\\s*/\) unless eos? or heredocs)]
delete[delete(-)plain( kind = :space)]
delete[delete(-)plain( when ?\\n, ?\\\\)]
delete[delete(-)plain( kind = :space)]
delete[delete(-)plain( if m == ?\\n)]
delete[delete(-)plain( value_expected = true # FIXME not quite true)]
delete[delete(-)plain( state = :initial if state == :undef_comma_expected)]
delete[delete(-)plain( end)]
delete[delete(-)plain( if heredocs)]
delete[delete(-)plain( unscan # heredoc scanning needs \\n at start)]
delete[delete(-)plain( state = heredocs.shift)]
delete[delete(-)plain( tokens << [:open, state.type])]
delete[delete(-)plain( heredocs = nil if heredocs.empty?)]
delete[delete(-)plain( next)]
delete[delete(-)plain( else)]
delete[delete(-)plain( match << scan(/\\s*/\) unless eos?)]
delete[delete(-)plain( end)]
delete[delete(-)plain( when ?#, ?=, ?_)]
delete[delete(-)plain( kind = :comment)]
delete[delete(-)plain( value_expected = true)]
insert[insert(+)plain( if match = scan(/[ \\t\\f]+/\))]
insert[insert(+)plain( kind = :space)]
insert[insert(+)plain( match << scan(/\\s*/\) unless eos? || heredocs)]
insert[insert(+)plain( value_expected = true if match.index(?\\n\) # FIXME not quite true)]
insert[insert(+)plain( tokens << [match, kind])]
insert[insert(+)plain( next)]
insert[insert(+)plain( )]
insert[insert(+)plain( elsif match = scan(/\\\\?\\n/\))]
insert[insert(+)plain( kind = :space)]
insert[insert(+)plain( if match == "\\n")]
insert[insert(+)plain( value_expected = true # FIXME not quite true)]
insert[insert(+)plain( state = :initial if state == :undef_comma_expected)]
insert[insert(+)plain( end)]
insert[insert(+)plain( if heredocs)]
insert[insert(+)plain( unscan # heredoc scanning needs \\n at start)]
insert[insert(+)plain( state = heredocs.shift)]
insert[insert(+)plain( tokens << [:open, state.type])]
insert[insert(+)plain( heredocs = nil if heredocs.empty?)]
insert[insert(+)plain( next)]
comment( else)
delete[delete(-)plain( raise_inspect 'else-case _ reached, because case %p was)]
delete[delete(-)plain( not handled' % [matched[0].chr], tokens)]
insert[insert(+)plain( match << scan(/\\s*/\) unless eos?)]
comment( end)
comment( tokens << [match, kind])
comment( next)
insert[insert(+)plain( )]
insert[insert(+)plain( elsif match = scan(/\\#.*/\) or)]
insert[insert(+)plain( ( bol? and match = scan(/#{patterns::RUBYDOC_OR_DATA}/o\) \))]
insert[insert(+)plain( kind = :comment)]
insert[insert(+)plain( value_expected = true)]
insert[insert(+)plain( tokens << [match, kind])]
insert[insert(+)plain( next)]
comment( )
comment( elsif state == :initial)
comment( )
change[change(@@)plain( -167,19 +169,19 )change(@@)]
comment( end)
comment( end)
comment( ## experimental!)
delete[delete(-)plain( value_expected = :set if)]
delete[delete(-)plain( patterns::REGEXP_ALLOWED[match] or check(/#{patterns::VALUE_FOLLOWS}/o\))]
insert[insert(+)plain( value_expected = :set if check(/#{patterns::VALUE_FOLLOWS}/o\))]
comment( )
comment( elsif last_token_dot and match = scan(/#{patterns::METHOD_NAME_OPERATOR}/o\))
comment( kind = :ident)
comment( value_expected = :set if check(/#{patterns::VALUE_FOLLOWS}/o\))
comment( )
comment( # OPERATORS #)
delete[delete(-)plain( elsif not last_token_dot and match = scan(/ ==?=? | \\.\\.?\\.? | [\\(\\\)\\[\\]\\{\\}] | :: | , /x\))]
insert[insert(+)plain( # TODO: match (\), [], {} as one single operator)]
insert[insert(+)plain( elsif not last_token_dot and match = scan(/ \\.\\.\\.? | (?:\\.|::\)(\) | [,\\(\\\)\\[\\]\\{\\}] | ==?=? /x\))]
comment( if match !~ / [.\\\)\\]\\}] /x or match =~ /\\.\\.\\.?/)
comment( value_expected = :set)
comment( end)
delete[delete(-)plain( last_token_dot = :set if match == '.' or match == '::')]
insert[insert(+)plain( last_token_dot = :set if self[1])]
comment( kind = :operator)
comment( unless inline_block_stack.empty?)
comment( case match)
change[change(@@)plain( -210,8 +212,9 )change(@@)]
comment( interpreted = true)
comment( state = patterns::StringState.new :regexp, interpreted, match)
comment( )
delete[delete(-)plain( elsif match = scan(/#{patterns::NUMERIC}/o\))]
delete[delete(-)plain( kind = if self[1] then :float else :integer end)]
insert[insert(+)plain( # elsif match = scan(/[-+]?#{patterns::NUMERIC}/o\))]
insert[insert(+)plain( elsif match = value_expected ? scan(/[-+]?#{patterns::NUMERIC}/o\) : scan(/#{patterns::NUMERIC}/o\))]
insert[insert(+)plain( kind = self[1] ? :float : :integer)]
comment( )
comment( elsif match = scan(/#{patterns::SYMBOL}/o\))
comment( case delim = match[1])
change[change(@@)plain( -285,6 +288,18 )change(@@)]
comment( next)
comment( end)
comment( )
insert[insert(+)plain( elsif state == :module_expected)]
insert[insert(+)plain( if match = scan(/<\))]
insert[insert(+)plain( kind = :operator)]
insert[insert(+)plain( else)]
insert[insert(+)plain( state = :initial)]
insert[insert(+)plain( if match = scan(/ (?:#{patterns::IDENT}::\)* #{patterns::IDENT} /ox\))]
insert[insert(+)plain( kind = :class)]
insert[insert(+)plain( else)]
insert[insert(+)plain( next)]
insert[insert(+)plain( end)]
insert[insert(+)plain( end)]
insert[insert(+)]
comment( elsif state == :undef_expected)
comment( state = :undef_comma_expected)
comment( if match = scan(/#{patterns::METHOD_NAME_EX}/o\))
change[change(@@)plain( -306,6 +321,15 )change(@@)]
comment( next)
comment( end)
comment( )
insert[insert(+)plain( elsif state == :alias_expected)]
insert[insert(+)plain( if match = scan(/(#{patterns::METHOD_NAME_OR_SYMBOL}\)([ \\t]+\)(#{patterns::METHOD_NAME_OR_SYMBOL}\)/o\))]
insert[insert(+)plain( tokens << [self[1], (self[1][0] == ?: ? :symbol : :method\)])]
insert[insert(+)plain( tokens << [self[2], :space])]
insert[insert(+)plain( tokens << [self[3], (self[3][0] == ?: ? :symbol : :method\)])]
insert[insert(+)plain( end)]
insert[insert(+)plain( state = :initial)]
insert[insert(+)plain( next)]
insert[insert(+)]
comment( elsif state == :undef_comma_expected)
comment( if match = scan(/,/\))
comment( kind = :operator)
change[change(@@)plain( -315,24 +339,14 )change(@@)]
comment( next)
comment( end)
comment( )
delete[delete(-)plain( elsif state == :module_expected)]
delete[delete(-)plain( if match = scan(/<\))]
delete[delete(-)plain( kind = :operator)]
delete[delete(-)plain( else)]
delete[delete(-)plain( state = :initial)]
delete[delete(-)plain( if match = scan(/ (?:#{patterns::IDENT}::\)* #{patterns::IDENT} /ox\))]
delete[delete(-)plain( kind = :class)]
delete[delete(-)plain( else)]
delete[delete(-)plain( next)]
delete[delete(-)plain( end)]
delete[delete(-)plain( end)]
delete[delete(-)]
comment( end)
comment( # }}})
insert[insert(+)plain( )]
insert[insert(+)plain( unless kind == :error)]
insert[insert(+)plain( value_expected = value_expected == :set)]
insert[insert(+)plain( last_token_dot = last_token_dot == :set)]
insert[insert(+)plain( end)]
comment( )
delete[delete(-)plain( value_expected = value_expected == :set)]
delete[delete(-)plain( last_token_dot = last_token_dot == :set)]
delete[delete(-)]
comment( if $DEBUG and not kind)
comment( raise_inspect 'Error token %p in line %d' %)
comment( [[match, kind], line], tokens, state)
head[head(Index: )plain(lib/coderay/scanners/c.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/scanners/c.rb (revision 200\))]
head[head(+++ )plain(lib/coderay/scanners/c.rb (revision 250\))]
change[change(@@)plain( -4,6 +4,8 )change(@@)]
comment( class C < Scanner)
comment( )
comment( register_for :c)
insert[insert(+)plain( )]
insert[insert(+)plain( include Streamable)]
comment( )
comment( RESERVED_WORDS = [)
comment( 'asm', 'break', 'case', 'continue', 'default', 'do', 'else',)
change[change(@@)plain( -42,7 +44,7 )change(@@)]
comment( )
comment( kind = nil)
comment( match = nil)
delete[delete(-)]
insert[insert(+)plain( )]
comment( case state)
comment( )
comment( when :initial)
head[head(Index: )plain(lib/coderay/scanners/scheme.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/scanners/scheme.rb (revision 0\))]
head[head(+++ )plain(lib/coderay/scanners/scheme.rb (revision 250\))]
change[change(@@)plain( -0,0 +1,142 )change(@@)]
insert[insert(+)plain(module CodeRay)]
insert[insert(+)plain( module Scanners)]
insert[insert(+)]
insert[insert(+)plain( # Scheme scanner for CodeRay (by closure\).)]
insert[insert(+)plain( # Thanks to murphy for putting CodeRay into public.)]
insert[insert(+)plain( class Scheme < Scanner)]
insert[insert(+)plain( )]
insert[insert(+)plain( register_for :scheme)]
insert[insert(+)plain( file_extension :scm)]
insert[insert(+)]
insert[insert(+)plain( CORE_FORMS = %w[)]
insert[insert(+)plain( lambda let let* letrec syntax-case define-syntax let-syntax)]
insert[insert(+)plain( letrec-syntax begin define quote if or and cond case do delay)]
insert[insert(+)plain( quasiquote set! cons force call-with-current-continuation call/cc)]
insert[insert(+)plain( ])]
insert[insert(+)]
insert[insert(+)plain( IDENT_KIND = CaseIgnoringWordList.new(:ident\).)]
insert[insert(+)plain( add(CORE_FORMS, :reserved\))]
insert[insert(+)plain( )]
insert[insert(+)plain( #IDENTIFIER_INITIAL = /[a-z!@\\$%&\\*\\/\\:<=>\\?~_\\^]/i)]
insert[insert(+)plain( #IDENTIFIER_SUBSEQUENT = /#{IDENTIFIER_INITIAL}|\\d|\\.|\\+|-/)]
insert[insert(+)plain( #IDENTIFIER = /#{IDENTIFIER_INITIAL}#{IDENTIFIER_SUBSEQUENT}*|\\+|-|\\.{3}/)]
insert[insert(+)plain( IDENTIFIER = /[a-zA-Z!@$%&*\\/:<=>?~_^][\\w!@$%&*\\/:<=>?~^.+\\-]*|[+-]|\\.\\.\\./)]
insert[insert(+)plain( DIGIT = /\\d/)]
insert[insert(+)plain( DIGIT10 = DIGIT)]
insert[insert(+)plain( DIGIT16 = /[0-9a-f]/i)]
insert[insert(+)plain( DIGIT8 = /[0-7]/)]
insert[insert(+)plain( DIGIT2 = /[01]/)]
insert[insert(+)plain( RADIX16 = /\\#x/i)]
insert[insert(+)plain( RADIX8 = /\\#o/i)]
insert[insert(+)plain( RADIX2 = /\\#b/i)]
insert[insert(+)plain( RADIX10 = /\\#d/i)]
insert[insert(+)plain( EXACTNESS = /#i|#e/i)]
insert[insert(+)plain( SIGN = /[\\+-]?/)]
insert[insert(+)plain( EXP_MARK = /[esfdl]/i)]
insert[insert(+)plain( EXP = /#{EXP_MARK}#{SIGN}#{DIGIT}+/)]
insert[insert(+)plain( SUFFIX = /#{EXP}?/)]
insert[insert(+)plain( PREFIX10 = /#{RADIX10}?#{EXACTNESS}?|#{EXACTNESS}?#{RADIX10}?/)]
insert[insert(+)plain( PREFIX16 = /#{RADIX16}#{EXACTNESS}?|#{EXACTNESS}?#{RADIX16}/)]
insert[insert(+)plain( PREFIX8 = /#{RADIX8}#{EXACTNESS}?|#{EXACTNESS}?#{RADIX8}/)]
insert[insert(+)plain( PREFIX2 = /#{RADIX2}#{EXACTNESS}?|#{EXACTNESS}?#{RADIX2}/)]
insert[insert(+)plain( UINT10 = /#{DIGIT10}+#*/)]
insert[insert(+)plain( UINT16 = /#{DIGIT16}+#*/)]
insert[insert(+)plain( UINT8 = /#{DIGIT8}+#*/)]
insert[insert(+)plain( UINT2 = /#{DIGIT2}+#*/)]
insert[insert(+)plain( DECIMAL = /#{DIGIT10}+#+\\.#*#{SUFFIX}|#{DIGIT10}+\\.#{DIGIT10}*#*#{SUFFIX}|\\.#{DIGIT10}+#*#{SUFFIX}|#{UINT10}#{EXP}/)]
insert[insert(+)plain( UREAL10 = /#{UINT10}\\/#{UINT10}|#{DECIMAL}|#{UINT10}/)]
insert[insert(+)plain( UREAL16 = /#{UINT16}\\/#{UINT16}|#{UINT16}/)]
insert[insert(+)plain( UREAL8 = /#{UINT8}\\/#{UINT8}|#{UINT8}/)]
insert[insert(+)plain( UREAL2 = /#{UINT2}\\/#{UINT2}|#{UINT2}/)]
insert[insert(+)plain( REAL10 = /#{SIGN}#{UREAL10}/)]
insert[insert(+)plain( REAL16 = /#{SIGN}#{UREAL16}/)]
insert[insert(+)plain( REAL8 = /#{SIGN}#{UREAL8}/)]
insert[insert(+)plain( REAL2 = /#{SIGN}#{UREAL2}/)]
insert[insert(+)plain( IMAG10 = /i|#{UREAL10}i/)]
insert[insert(+)plain( IMAG16 = /i|#{UREAL16}i/)]
insert[insert(+)plain( IMAG8 = /i|#{UREAL8}i/)]
insert[insert(+)plain( IMAG2 = /i|#{UREAL2}i/)]
insert[insert(+)plain( COMPLEX10 = /#{REAL10}@#{REAL10}|#{REAL10}\\+#{IMAG10}|#{REAL10}-#{IMAG10}|\\+#{IMAG10}|-#{IMAG10}|#{REAL10}/)]
insert[insert(+)plain( COMPLEX16 = /#{REAL16}@#{REAL16}|#{REAL16}\\+#{IMAG16}|#{REAL16}-#{IMAG16}|\\+#{IMAG16}|-#{IMAG16}|#{REAL16}/)]
insert[insert(+)plain( COMPLEX8 = /#{REAL8}@#{REAL8}|#{REAL8}\\+#{IMAG8}|#{REAL8}-#{IMAG8}|\\+#{IMAG8}|-#{IMAG8}|#{REAL8}/)]
insert[insert(+)plain( COMPLEX2 = /#{REAL2}@#{REAL2}|#{REAL2}\\+#{IMAG2}|#{REAL2}-#{IMAG2}|\\+#{IMAG2}|-#{IMAG2}|#{REAL2}/)]
insert[insert(+)plain( NUM10 = /#{PREFIX10}?#{COMPLEX10}/)]
insert[insert(+)plain( NUM16 = /#{PREFIX16}#{COMPLEX16}/)]
insert[insert(+)plain( NUM8 = /#{PREFIX8}#{COMPLEX8}/)]
insert[insert(+)plain( NUM2 = /#{PREFIX2}#{COMPLEX2}/)]
insert[insert(+)plain( NUM = /#{NUM10}|#{NUM16}|#{NUM8}|#{NUM2}/)]
insert[insert(+)plain( )]
insert[insert(+)plain( private)]
insert[insert(+)plain( def scan_tokens tokens,options)]
insert[insert(+)plain( )]
insert[insert(+)plain( state = :initial)]
insert[insert(+)plain( ident_kind = IDENT_KIND)]
insert[insert(+)plain( )]
insert[insert(+)plain( until eos?)]
insert[insert(+)plain( kind = match = nil)]
insert[insert(+)plain( )]
insert[insert(+)plain( case state)]
insert[insert(+)plain( when :initial)]
insert[insert(+)plain( if scan(/ \\s+ | \\\\\\n /x\))]
insert[insert(+)plain( kind = :space)]
insert[insert(+)plain( elsif scan(/['\\(\\[\\\)\\]]|#\\(/\))]
insert[insert(+)plain( kind = :operator_fat)]
insert[insert(+)plain( elsif scan(/;.*/\))]
insert[insert(+)plain( kind = :comment)]
insert[insert(+)plain( elsif scan(/#\\\\(?:newline|space|.?\)/\))]
insert[insert(+)plain( kind = :char)]
insert[insert(+)plain( elsif scan(/#[ft]/\))]
insert[insert(+)plain( kind = :pre_constant)]
insert[insert(+)plain( elsif scan(/#{IDENTIFIER}/o\))]
insert[insert(+)plain( kind = ident_kind[matched])]
insert[insert(+)plain( elsif scan(/\\./\))]
insert[insert(+)plain( kind = :operator)]
insert[insert(+)plain( elsif scan(/"/\))]
insert[insert(+)plain( tokens << [:open, :string])]
insert[insert(+)plain( state = :string)]
insert[insert(+)plain( tokens << ['"', :delimiter])]
insert[insert(+)plain( next)]
insert[insert(+)plain( elsif scan(/#{NUM}/o\) and not matched.empty?)]
insert[insert(+)plain( kind = :integer)]
insert[insert(+)plain( elsif getch)]
insert[insert(+)plain( kind = :error)]
insert[insert(+)plain( end)]
insert[insert(+)plain( )]
insert[insert(+)plain( when :string)]
insert[insert(+)plain( if scan(/[^"\\\\]+/\) or scan(/\\\\.?/\))]
insert[insert(+)plain( kind = :content)]
insert[insert(+)plain( elsif scan(/"/\))]
insert[insert(+)plain( tokens << ['"', :delimiter])]
insert[insert(+)plain( tokens << [:close, :string])]
insert[insert(+)plain( state = :initial)]
insert[insert(+)plain( next)]
insert[insert(+)plain( else)]
insert[insert(+)plain( raise_inspect "else case \\" reached; %p not handled." % peek(1\),)]
insert[insert(+)plain( tokens, state)]
insert[insert(+)plain( end)]
insert[insert(+)plain( )]
insert[insert(+)plain( else)]
insert[insert(+)plain( raise "else case reached")]
insert[insert(+)plain( end)]
insert[insert(+)plain( )]
insert[insert(+)plain( match ||= matched)]
insert[insert(+)plain( if $DEBUG and not kind)]
insert[insert(+)plain( raise_inspect 'Error token %p in line %d' %)]
insert[insert(+)plain( [[match, kind], line], tokens)]
insert[insert(+)plain( end)]
insert[insert(+)plain( raise_inspect 'Empty token', tokens, state unless match)]
insert[insert(+)plain( )]
insert[insert(+)plain( tokens << [match, kind])]
insert[insert(+)plain( )]
insert[insert(+)plain( end # until eos)]
insert[insert(+)plain( )]
insert[insert(+)plain( if state == :string)]
insert[insert(+)plain( tokens << [:close, :string])]
insert[insert(+)plain( end)]
insert[insert(+)plain( )]
insert[insert(+)plain( tokens)]
insert[insert(+)plain( )]
insert[insert(+)plain( end #scan_tokens)]
insert[insert(+)plain( end #class)]
insert[insert(+)plain( end #module scanners)]
insert[insert(+)plain(end #module coderay)]
change[change(\\ )plain(No newline at end of file)]
head[head(Index: )plain(lib/coderay/scanners/delphi.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/scanners/delphi.rb (revision 200\))]
head[head(+++ )plain(lib/coderay/scanners/delphi.rb (revision 250\))]
change[change(@@)plain( -29,13 +29,18 )change(@@)]
comment( 'virtual', 'write', 'writeonly')
comment( ])
comment( )
delete[delete(-)plain( IDENT_KIND = CaseIgnoringWordList.new(:ident\).)]
insert[insert(+)plain( IDENT_KIND = CaseIgnoringWordList.new(:ident, caching=true\).)]
comment( add(RESERVED_WORDS, :reserved\).)
comment( add(DIRECTIVES, :directive\))
insert[insert(+)plain( )]
insert[insert(+)plain( NAME_FOLLOWS = CaseIgnoringWordList.new(false, caching=true\).)]
insert[insert(+)plain( add(%w(procedure function .\)\))]
comment( )
insert[insert(+)plain( private)]
comment( def scan_tokens tokens, options)
comment( )
comment( state = :initial)
insert[insert(+)plain( last_token = '')]
comment( )
comment( until eos?)
comment( )
change[change(@@)plain( -45,19 +50,29 )change(@@)]
comment( if state == :initial)
comment( )
comment( if scan(/ \\s+ /x\))
delete[delete(-)plain( kind = :space)]
insert[insert(+)plain( tokens << [matched, :space])]
insert[insert(+)plain( next)]
comment( )
comment( elsif scan(%r! \\{ \\$ [^}]* \\}? | \\(\\* \\$ (?: .*? \\*\\\) | .* \) !mx\))
delete[delete(-)plain( kind = :preprocessor)]
insert[insert(+)plain( tokens << [matched, :preprocessor])]
insert[insert(+)plain( next)]
comment( )
comment( elsif scan(%r! // [^\\n]* | \\{ [^}]* \\}? | \\(\\* (?: .*? \\*\\\) | .* \) !mx\))
delete[delete(-)plain( kind = :comment)]
insert[insert(+)plain( tokens << [matched, :comment])]
insert[insert(+)plain( next)]
comment( )
delete[delete(-)plain( elsif scan(/ [-+*\\/=<>:;,.@\\^|\\(\\\)\\[\\]]+ /x\))]
insert[insert(+)plain( elsif match = scan(/ <[>=]? | >=? | :=? | [-+=*\\/;,@\\^|\\(\\\)\\[\\]] | \\.\\. /x\))]
comment( kind = :operator)
insert[insert(+)plain( )]
insert[insert(+)plain( elsif match = scan(/\\./\))]
insert[insert(+)plain( kind = :operator)]
insert[insert(+)plain( if last_token == 'end')]
insert[insert(+)plain( tokens << [match, kind])]
insert[insert(+)plain( next)]
insert[insert(+)plain( end)]
comment( )
comment( elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x\))
delete[delete(-)plain( kind = IDENT_KIND[match])]
insert[insert(+)plain( kind = NAME_FOLLOWS[last_token] ? :ident : IDENT_KIND[match])]
comment( )
comment( elsif match = scan(/ ' ( [^\\n']|'' \) (?:'|$\) /x\))
comment( tokens << [:open, :char])
change[change(@@)plain( -101,6 +116,7 )change(@@)]
comment( state = :initial)
comment( next)
comment( elsif scan(/\\n/\))
insert[insert(+)plain( tokens << [:close, :string])]
comment( kind = :error)
comment( state = :initial)
comment( else)
change[change(@@)plain( -119,6 +135,7 )change(@@)]
comment( end)
comment( raise_inspect 'Empty token', tokens unless match)
comment( )
insert[insert(+)plain( last_token = match)]
comment( tokens << [match, kind])
comment( )
comment( end)
head[head(Index: )plain(lib/coderay/scanners/debug.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/scanners/debug.rb (revision 0\))]
head[head(+++ )plain(lib/coderay/scanners/debug.rb (revision 250\))]
change[change(@@)plain( -0,0 +1,60 )change(@@)]
insert[insert(+)plain(module CodeRay)]
insert[insert(+)plain(module Scanners)]
insert[insert(+)]
insert[insert(+)plain( # = Debug Scanner)]
insert[insert(+)plain( class Debug < Scanner)]
insert[insert(+)]
insert[insert(+)plain( include Streamable)]
insert[insert(+)plain( register_for :debug)]
insert[insert(+)]
insert[insert(+)plain( protected)]
insert[insert(+)plain( def scan_tokens tokens, options)]
insert[insert(+)]
insert[insert(+)plain( opened_tokens = [])]
insert[insert(+)]
insert[insert(+)plain( until eos?)]
insert[insert(+)]
insert[insert(+)plain( kind = nil)]
insert[insert(+)plain( match = nil)]
insert[insert(+)]
insert[insert(+)plain( if scan(/\\s+/\))]
insert[insert(+)plain( tokens << [matched, :space])]
insert[insert(+)plain( next)]
insert[insert(+)plain( )]
insert[insert(+)plain( elsif scan(/ (\\w+\) \\( ( [^\\\)\\\\]* ( \\\\. [^\\\)\\\\]* \)* \) \\\) /x\))]
insert[insert(+)plain( kind = self[1].to_sym)]
insert[insert(+)plain( match = self[2].gsub(/\\\\(.\)/, '\\1'\))]
insert[insert(+)plain( )]
insert[insert(+)plain( elsif scan(/ (\\w+\) < /x\))]
insert[insert(+)plain( kind = self[1].to_sym)]
insert[insert(+)plain( opened_tokens << kind)]
insert[insert(+)plain( match = :open)]
insert[insert(+)plain( )]
insert[insert(+)plain( elsif scan(/ > /x\))]
insert[insert(+)plain( kind = opened_tokens.pop)]
insert[insert(+)plain( match = :close)]
insert[insert(+)plain( )]
insert[insert(+)plain( else)]
insert[insert(+)plain( kind = :error)]
insert[insert(+)plain( getch)]
insert[insert(+)]
insert[insert(+)plain( end)]
insert[insert(+)plain( )]
insert[insert(+)plain( match ||= matched)]
insert[insert(+)plain( if $DEBUG and not kind)]
insert[insert(+)plain( raise_inspect 'Error token %p in line %d' %)]
insert[insert(+)plain( [[match, kind], line], tokens)]
insert[insert(+)plain( end)]
insert[insert(+)plain( raise_inspect 'Empty token', tokens unless match)]
insert[insert(+)]
insert[insert(+)plain( tokens << [match, kind])]
insert[insert(+)plain( )]
insert[insert(+)plain( end)]
insert[insert(+)plain( )]
insert[insert(+)plain( tokens)]
insert[insert(+)plain( end)]
insert[insert(+)]
insert[insert(+)plain( end)]
insert[insert(+)]
insert[insert(+)plain(end)]
insert[insert(+)plain(end)]
head[head(Index: )plain(lib/coderay/scanners/rhtml.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/scanners/rhtml.rb (revision 200\))]
head[head(+++ )plain(lib/coderay/scanners/rhtml.rb (revision 250\))]
change[change(@@)plain( -51,10 +51,10 )change(@@)]
comment( start_tag = match[/\\A<%[-=]?/])
comment( end_tag = match[/-?%?>?\\z/])
comment( tokens << [:open, :inline])
delete[delete(-)plain( tokens << [start_tag, :delimiter])]
insert[insert(+)plain( tokens << [start_tag, :inline_delimiter])]
comment( code = match[start_tag.size .. -1 - end_tag.size])
comment( @ruby_scanner.tokenize code)
delete[delete(-)plain( tokens << [end_tag, :delimiter] unless end_tag.empty?)]
insert[insert(+)plain( tokens << [end_tag, :inline_delimiter] unless end_tag.empty?)]
comment( tokens << [:close, :inline])
comment( )
comment( else)
head[head(Index: )plain(lib/coderay/scanners/nitro_xhtml.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/scanners/nitro_xhtml.rb (revision 200\))]
head[head(+++ )plain(lib/coderay/scanners/nitro_xhtml.rb (revision 250\))]
change[change(@@)plain( -95,20 +95,20 )change(@@)]
comment( delimiter = CLOSING_PAREN[start_tag[1,1]])
comment( end_tag = match[-1,1] == delimiter ? delimiter : '')
comment( tokens << [:open, :inline])
delete[delete(-)plain( tokens << [start_tag, :delimiter])]
insert[insert(+)plain( tokens << [start_tag, :inline_delimiter])]
comment( code = match[start_tag.size .. -1 - end_tag.size])
comment( @ruby_scanner.tokenize code)
delete[delete(-)plain( tokens << [end_tag, :delimiter] unless end_tag.empty?)]
insert[insert(+)plain( tokens << [end_tag, :inline_delimiter] unless end_tag.empty?)]
comment( tokens << [:close, :inline])
comment( )
comment( elsif match = scan(/#{NITRO_RUBY_BLOCK}/o\))
comment( start_tag = '' ? '?>' : '')
comment( tokens << [:open, :inline])
delete[delete(-)plain( tokens << [start_tag, :delimiter])]
insert[insert(+)plain( tokens << [start_tag, :inline_delimiter])]
comment( code = match[start_tag.size .. -(end_tag.size\)-1])
comment( @ruby_scanner.tokenize code)
delete[delete(-)plain( tokens << [end_tag, :delimiter] unless end_tag.empty?)]
insert[insert(+)plain( tokens << [end_tag, :inline_delimiter] unless end_tag.empty?)]
comment( tokens << [:close, :inline])
comment( )
comment( elsif entity = scan(/#{NITRO_ENTITY}/o\))
head[head(Index: )plain(lib/coderay/scanners/plaintext.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay/scanners/plaintext.rb (revision 200\))]
head[head(+++ )plain(lib/coderay/scanners/plaintext.rb (revision 250\))]
change[change(@@)plain( -4,6 +4,8 )change(@@)]
comment( class Plaintext < Scanner)
comment( )
comment( register_for :plaintext, :plain)
insert[insert(+)plain( )]
insert[insert(+)plain( include Streamable)]
comment( )
comment( def scan_tokens tokens, options)
comment( text = (scan_until(/\\z/\) || ''\))
head[head(Index: )plain(lib/coderay.rb)]
head[head(===================================================================)]
head[head(--- )plain(lib/coderay.rb (revision 200\))]
head[head(+++ )plain(lib/coderay.rb (revision 250\))]
change[change(@@)plain( -24,8 +24,8 )change(@@)]
comment( #)
comment( # == Usage)
comment( #)
delete[delete(-)plain(# Remember you need RubyGems to use CodeRay. Run Ruby with -rubygems option)]
delete[delete(-)plain(# if required.)]
insert[insert(+)plain(# Remember you need RubyGems to use CodeRay, unless you have it in your load path. Run Ruby with)]
insert[insert(+)plain(# -rubygems option if required.)]
comment( #)
comment( # === Highlight Ruby code in a string as html)
comment( # )
change[change(@@)plain( -44,19 +44,15 )change(@@)]
comment( # )
comment( # You can include this div in your page. The used CSS styles can be printed with)
comment( # )
delete[delete(-)plain(# % ruby -rcoderay -e "print CodeRay::Encoders[:html]::CSS")]
insert[insert(+)plain(# % coderay_stylesheet)]
comment( # )
comment( # === Highlight without typing too much)
delete[delete(-)plain(#)]
insert[insert(+)plain(# )]
comment( # If you are one of the hasty (or lazy, or extremely curious\) people, just run this file:)
delete[delete(-)plain(#)]
delete[delete(-)plain(# % ruby -rubygems coderay.rb)]
comment( # )
delete[delete(-)plain(# If the output was to fast for you, try)]
insert[insert(+)plain(# % ruby -rubygems /path/to/coderay/coderay.rb > example.html)]
comment( # )
delete[delete(-)plain(# % ruby -rubygems coderay.rb > example.html)]
delete[delete(-)plain(#)]
delete[delete(-)plain(# and look at the file it created.)]
insert[insert(+)plain(# and look at the file it created in your browser.)]
comment( # )
comment( # = CodeRay Module)
comment( #)
change[change(@@)plain( -111,7 +107,7 )change(@@)]
comment( #)
comment( # CodeRay.scan_stream:: Scan in stream mode.)
comment( #)
delete[delete(-)plain(# == All-in-One Encoding)]
insert[insert(+)plain(# == All-in-One Encoding)]
comment( #)
comment( # CodeRay.encode:: Highlight a string with a given input and output format.)
comment( #)
change[change(@@)plain( -121,11 +117,16 )change(@@)]
comment( # for this Encoder must only be done once.)
comment( #)
comment( # CodeRay.encoder:: Create an Encoder instance with format and options.)
insert[insert(+)plain(# CodeRay.scanner:: Create an Scanner instance for lang, with '' as default code.)]
comment( #)
delete[delete(-)plain(# There is no CodeRay.scanner method because Scanners are bound to an input string)]
delete[delete(-)plain(# on creation; you can't re-use them with another string.)]
insert[insert(+)plain(# To make use of CodeRay.scanner, use CodeRay::Scanner::code=.)]
comment( #)
delete[delete(-)plain(# The scanning methods provide more flexibility; we recommend to use these.)]
insert[insert(+)plain(# The scanning methods provide more flexibility; we recommend to use these.)]
insert[insert(+)plain(# )]
insert[insert(+)plain(# == Reusing Scanners and Encoders)]
insert[insert(+)plain(# )]
insert[insert(+)plain(# If you want to re-use scanners and encoders (because that is faster\), see)]
insert[insert(+)plain(# CodeRay::Duo for the most convenient (and recommended\) interface.)]
comment( module CodeRay)
comment( )
comment( # Version: Major.Minor.Teeny[.Revision])
change[change(@@)plain( -133,7 +134,7 )change(@@)]
comment( # Minor: odd for beta, even for stable)
comment( # Teeny: development state)
comment( # Revision: Subversion Revision number (generated on rake\))
delete[delete(-)plain( VERSION = '0.7.4')]
insert[insert(+)plain( VERSION = '0.7.9')]
comment( )
comment( require 'coderay/tokens')
comment( require 'coderay/scanner')
change[change(@@)plain( -170,7 +171,7 )change(@@)]
comment( def scan_file filename, lang = :auto, options = {}, &block)
comment( file = IO.read filename)
comment( if lang == :auto)
delete[delete(-)plain( require 'coderay/helpers/filetype')]
insert[insert(+)plain( require 'coderay/helpers/file_type')]
comment( lang = FileType.fetch filename, :plaintext, true)
comment( end)
comment( scan file, lang, options = {}, &block)
change[change(@@)plain( -314,6 +315,7 )change(@@)]
comment( # Run a test script.)
comment( if $0 == __FILE__)
comment( $stderr.print 'Press key to print demo.'; gets)
delete[delete(-)plain( code = File.read($0\)[/module CodeRay.*/m])]
insert[insert(+)plain( # Just use this file as an example of Ruby code.)]
insert[insert(+)plain( code = File.read(__FILE__\)[/module CodeRay.*/m])]
comment( print CodeRay.scan(code, :ruby\).html)
comment( end)
head[head(Property changes on: )plain(lib)]
head[head(___________________________________________________________________)]
head[head(Added: )plain(svn:externals)]
insert[insert( +)plain( term http://term-ansicolor.rubyforge.org/svn/trunk/lib/term/)]