From fea5260ce014ee521955c5afc929f3cae71a4c73 Mon Sep 17 00:00:00 2001 From: murphy Date: Wed, 15 Mar 2006 21:58:19 +0000 Subject: Ruby scanner errors fixed. demo_dump and demo_encoder updated for new YAML version. Fixes in output.rb and numerization.rb --- demo/demo_dump.out | 2 +- demo/demo_encoder.out | 27 ++++++++++----------------- lib/coderay/encoders/html/numerization.rb | 4 ++-- lib/coderay/encoders/html/output.rb | 2 +- lib/coderay/scanners/ruby.rb | 8 ++++---- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/demo/demo_dump.out b/demo/demo_dump.out index d303b08..a032b50 100644 --- a/demo/demo_dump.out +++ b/demo/demo_dump.out @@ -1,4 +1,4 @@ -YAML: 2690 bytes +YAML: 2358 bytes Dump: 1058 bytes undumped:
diff --git a/demo/demo_encoder.out b/demo/demo_encoder.out index 3add7bc..aa35a61 100644 --- a/demo/demo_encoder.out +++ b/demo/demo_encoder.out @@ -31,30 +31,23 @@ space \ YAML: --- -- - - puts +- - puts - :ident -- - - " " +- - " " - :space -- - - "17" +- - "17" - :integer -- - - " " +- - " " - :space -- - - "+" +- - + - :operator -- - - " " +- - " " - :space -- - - "4" +- - "4" - :integer -- - - " - " +- - | + + - :space Dump: diff --git a/lib/coderay/encoders/html/numerization.rb b/lib/coderay/encoders/html/numerization.rb index f51b5d3..edce9eb 100644 --- a/lib/coderay/encoders/html/numerization.rb +++ b/lib/coderay/encoders/html/numerization.rb @@ -12,9 +12,9 @@ module CodeRay NUMERIZABLE_WRAPPINGS = { :table => [:div, :page], :inline => :all, - :list => [:div, :page], - nil => :all + :list => [:div, :page] } + NUMERIZABLE_WRAPPINGS.default = :all def numerize! mode = :table, options = {} return self unless mode diff --git a/lib/coderay/encoders/html/output.rb b/lib/coderay/encoders/html/output.rb index 36018a7..8096dc8 100644 --- a/lib/coderay/encoders/html/output.rb +++ b/lib/coderay/encoders/html/output.rb @@ -25,7 +25,7 @@ module CodeRay # # a = Output.new 'Code' # a.wrap! :page - def new string, css, element = nil + def new string, css = CSS.new, element = nil output = string.clone.extend self output.wrapped_in = element output.css = css diff --git a/lib/coderay/scanners/ruby.rb b/lib/coderay/scanners/ruby.rb index 6b4c8ea..8952422 100644 --- a/lib/coderay/scanners/ruby.rb +++ b/lib/coderay/scanners/ruby.rb @@ -134,7 +134,7 @@ module CodeRay module Scanners last_state = state # scan one token as normal code, then return here state = :initial else - raise 'else-case # reached; #%p not handled' % peek(1), tokens + raise_inspect 'else-case # reached; #%p not handled' % peek(1), tokens end when state.paren @@ -145,7 +145,7 @@ module CodeRay module Scanners tokens << [match, :function] else - raise 'else-case " reached; %p not handled, state = %p' % [match, state], tokens + raise_inspect 'else-case " reached; %p not handled, state = %p' % [match, state], tokens end next @@ -178,7 +178,7 @@ module CodeRay module Scanners type = :comment regexp_allowed = true else - raise 'else-case _ reached, because case %p was not handled' % [matched[0].chr], tokens + raise_inspect 'else-case _ reached, because case %p was not handled' % [matched[0].chr], tokens end tokens << [match, type] next @@ -274,7 +274,7 @@ module CodeRay module Scanners elsif fancy_allowed and match = scan(/#{FANCY_START}/o) type, interpreted = *FancyStringType.fetch(self[1]) do - raise 'Unknown fancy string: %%%p' % k, tokens + raise_inspect 'Unknown fancy string: %%%p' % k, tokens end tokens << [:open, type] state = StringState.new type, interpreted, self[2] -- cgit v1.2.1