diff options
author | murphy <murphy@rubychan.de> | 2006-04-10 03:06:50 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2006-04-10 03:06:50 +0000 |
commit | 5ee15661dbc2da70927f588e310315233aff6eea (patch) | |
tree | 08c959a52080e4cbcc873b49c8e5f1ed42a75ccf /lib/coderay/helpers/plugin.rb | |
parent | 132b75e58dba4c93278721d60f177cfbee7d0e46 (diff) | |
download | coderay-5ee15661dbc2da70927f588e310315233aff6eea.tar.gz |
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.
Diffstat (limited to 'lib/coderay/helpers/plugin.rb')
-rw-r--r-- | lib/coderay/helpers/plugin.rb | 22 |
1 files changed, 19 insertions, 3 deletions
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
|