summaryrefslogtreecommitdiff
path: root/lib/coderay/encoders/yaml.rb
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-05-05 13:08:42 +0000
committermurphy <murphy@rubychan.de>2010-05-05 13:08:42 +0000
commit7b4acdd55492c8cb7db2fba4739b45d5955698de (patch)
treef8a1e7d50dbd5753909b98c3b3e516385537cdb8 /lib/coderay/encoders/yaml.rb
parenta97d39b3ca84484e45f3ff44a1ace6bdfb337c4c (diff)
downloadcoderay-7b4acdd55492c8cb7db2fba4739b45d5955698de.tar.gz
Fixes for YAML encoder, Filter, and tests and API enhancements for Duo.
Diffstat (limited to 'lib/coderay/encoders/yaml.rb')
-rw-r--r--lib/coderay/encoders/yaml.rb32
1 files changed, 29 insertions, 3 deletions
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