diff options
author | murphy <murphy@rubychan.de> | 2009-06-20 16:14:07 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2009-06-20 16:14:07 +0000 |
commit | d2a880f331747a0764ebef408f2e2ab556d5d954 (patch) | |
tree | a746a02d994328a7ac0b7893557cf109c826a0a5 /lib/coderay/encoder.rb | |
parent | 8283feed20943a6b7863a38bcd8f2266310c91c3 (diff) | |
download | coderay-d2a880f331747a0764ebef408f2e2ab556d5d954.tar.gz |
* Improved implementation of Encoder *token callbacks.
* Documentation for these methods.
* Added two new encoders: CommentFilter < TokenFilter.
* Simplified Text encoder.
* Code cleanup in HTML encoder subclasses.
Diffstat (limited to 'lib/coderay/encoder.rb')
-rw-r--r-- | lib/coderay/encoder.rb | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/coderay/encoder.rb b/lib/coderay/encoder.rb index 07733a1..dd97067 100644 --- a/lib/coderay/encoder.rb +++ b/lib/coderay/encoder.rb @@ -142,10 +142,13 @@ module CodeRay end @out << out if defined?(@out) && @out end - + + # Called for each text token ([text, kind]), where text is a String. def text_token text, kind + '' end - + + # Called for each block (non-text) token ([action, kind]), where action is a Symbol. def block_token action, kind case action when :open @@ -158,7 +161,23 @@ module CodeRay end_line kind else raise 'unknown block action: %p' % action - end + end.to_s + end + + # Called for each block token at the start of the block ([:open, kind]). + def open_token kind + end + + # Called for each block token end of the block ([:close, kind]). + def close_token kind + end + + # Called for each line token block at the start of the line ([:begin_line, kind]). + def begin_line kind + end + + # Called for each line token block at the end of the line ([:end_line, kind]). + def end_line kind end # Called with merged options after encoding starts. |