From 7b4acdd55492c8cb7db2fba4739b45d5955698de Mon Sep 17 00:00:00 2001 From: murphy Date: Wed, 5 May 2010 13:08:42 +0000 Subject: Fixes for YAML encoder, Filter, and tests and API enhancements for Duo. --- lib/coderay/encoders/yaml.rb | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'lib/coderay/encoders/yaml.rb') diff --git a/lib/coderay/encoders/yaml.rb b/lib/coderay/encoders/yaml.rb index 5564e58..49cf86c 100644 --- a/lib/coderay/encoders/yaml.rb +++ b/lib/coderay/encoders/yaml.rb @@ -11,11 +11,37 @@ module Encoders FILE_EXTENSION = 'yaml' protected - def compile tokens, options + def setup options require 'yaml' - @out = tokens.to_a.to_yaml + @out = [] end - + + def finish options + @out.to_a.to_yaml + end + + public + + def text_token text, kind + @out << [text, kind] + end + + def begin_group kind + @out << [:begin_group, kind] + end + + def end_group kind + @out << [:end_group, kind] + end + + def begin_line kind + @out << [:begin_line, kind] + end + + def end_line kind + @out << [:end_line, kind] + end + end end -- cgit v1.2.1