summaryrefslogtreecommitdiff
path: root/lib/coderay/encoders/json.rb
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-05-01 01:31:56 +0000
committermurphy <murphy@rubychan.de>2010-05-01 01:31:56 +0000
commitfa975bbf5d40644d987887b4cf273a3f02612f03 (patch)
tree5ffada8100c1b6cb9057dec7985daaf6d1851396 /lib/coderay/encoders/json.rb
parente271dc13633fa6dba9fb87f415d72505af0cc88c (diff)
downloadcoderay-fa975bbf5d40644d987887b4cf273a3f02612f03.tar.gz
Direct Streaming! See #142 and Changes.textile.
Diffstat (limited to 'lib/coderay/encoders/json.rb')
-rw-r--r--lib/coderay/encoders/json.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/coderay/encoders/json.rb b/lib/coderay/encoders/json.rb
index 78f0ec0..bb09809 100644
--- a/lib/coderay/encoders/json.rb
+++ b/lib/coderay/encoders/json.rb
@@ -33,11 +33,23 @@ module Encoders
end
def text_token text, kind
- { :type => 'text', :text => text, :kind => kind }
+ @out << { :type => 'text', :text => text, :kind => kind }
end
- def block_token action, kind
- { :type => 'block', :action => action, :kind => kind }
+ def begin_group kind
+ @out << { :type => 'block', :action => 'open', :kind => kind }
+ end
+
+ def end_group kind
+ @out << { :type => 'block', :action => 'close', :kind => kind }
+ end
+
+ def begin_line kind
+ @out << { :type => 'block', :action => 'begin_line', :kind => kind }
+ end
+
+ def end_line kind
+ @out << { :type => 'block', :action => 'end_line', :kind => kind }
end
def finish options