From d2a880f331747a0764ebef408f2e2ab556d5d954 Mon Sep 17 00:00:00 2001 From: murphy Date: Sat, 20 Jun 2009 16:14:07 +0000 Subject: * 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. --- lib/coderay/encoder.rb | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'lib/coderay/encoder.rb') 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. -- cgit v1.2.1