From 5ee15661dbc2da70927f588e310315233aff6eea Mon Sep 17 00:00:00 2001 From: murphy Date: Mon, 10 Apr 2006 03:06:50 +0000 Subject: Large update: Scanners for HTML, RHTML and Nitro-XHTML added. CSS style changes/enhancments (mainly the new background color for inline code, affects all Ruby code.) Demos and tests adjusted. Plugin: new PluginHost::default method. Scanner: - New setup method - ability to re-use a scanner - ability to keep the tokens - minor changes to token caching and string flattening Encoder: Error if token content is neither String nor Symbol. HTML encoder: - more warnings for unclosed tokens - output now UTF-8 Ruby Scanner: - bug: symbols before => now do not include =; {:foo=>bar} is valid Ruby code - try to close all open tokens - constants now all with specific namespace (for speed, I hope) Styles: new :entity/en class. Test suite now gives hinted HTML output. --- lib/coderay/helpers/plugin.rb | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'lib/coderay/helpers') diff --git a/lib/coderay/helpers/plugin.rb b/lib/coderay/helpers/plugin.rb index 246b9b4..c55e565 100644 --- a/lib/coderay/helpers/plugin.rb +++ b/lib/coderay/helpers/plugin.rb @@ -56,7 +56,6 @@ module PluginHost def require_helper plugin_id, helper_name path = path_to File.join(plugin_id, helper_name) - #$stderr.puts 'Loading helper: ' + path require path end @@ -125,6 +124,20 @@ module PluginHost end end + # Define the default plugin to use when no plugin is found + # for a given id. + # + # See also map. + # + # class MyColorHost < PluginHost + # map :navy => :dark_blue + # default :gray + # end + def default id + id = validate_id id + plugin_hash[nil] = id + end + # Every plugin must register itself for one or more # +ids+ by calling register_for, which calls this method. # @@ -152,10 +165,13 @@ protected id = validate_id(plugin_id) path = path_to id begin - #$stderr.puts 'Loading plugin: ' + path if $DEBUG require path rescue LoadError => boom - raise PluginNotFound, 'Could not load plugin %p: %s' % [id, boom] + if h.has_key? nil # default plugin + h[id] = h[nil] + else + raise PluginNotFound, 'Could not load plugin %p: %s' % [id, boom] + end else # Plugin should have registered by now unless h.has_key? id -- cgit v1.2.1