Created
July 13, 2011 09:57
-
-
Save znz/1080016 to your computer and use it in GitHub Desktop.
作りかけというか作り始めの部分のみ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/a.org b/a.org | |
new file mode 100644 | |
index 0000000..ad3e428 | |
--- /dev/null | |
+++ b/a.org | |
@@ -0,0 +1,4 @@ | |
+* 1 | |
+- 2 | |
+3 | |
+- 4 | |
diff --git a/lib/rabbit/parser/org.rb b/lib/rabbit/parser/org.rb | |
new file mode 100644 | |
index 0000000..ec12a53 | |
--- /dev/null | |
+++ b/lib/rabbit/parser/org.rb | |
@@ -0,0 +1,61 @@ | |
+begin | |
+ require "org-ruby" | |
+rescue LoadError | |
+ require "rubygems" | |
+ require "org-ruby" | |
+end | |
+ | |
+require "rabbit/parser/base" | |
+ | |
+module Rabbit | |
+ module Parser | |
+ class Org < Base | |
+ unshift_loader(self) | |
+ class << self | |
+ def match?(source) | |
+ /^\* /.match(source.read) | |
+ end | |
+ end | |
+ | |
+ include Element | |
+ def parse | |
+ output = RabbitOutput.new(@canvas) | |
+ parser = Orgmode::Parser.new(@source.read) | |
+ parser.instance_eval do | |
+ Orgmode::Parser.translate(@header_lines, output) | |
+ @headlines.each do |headline| | |
+ Orgmode::Parser.translate(headline.body_lines, output) | |
+ end | |
+ output | |
+ end | |
+ end | |
+ end | |
+ end | |
+end | |
+ | |
+require 'rabbit/element' | |
+ | |
+module Rabbit | |
+ module Parser | |
+ class Org | |
+ class RabbitOutput < Orgmode::OutputBuffer | |
+ include Element | |
+ | |
+ def flush! | |
+ @logger.debug "FLUSH ==========> #{@buffer_mode}" | |
+ p [@buffer, @output_type, @buffer_mode] | |
+ case @output_type | |
+ when :heading1 | |
+ @slide = Slide.new(HeadLine.new(Text.new(@buffer))) | |
+ @body = Body.new | |
+ @slide << @body | |
+ @output << @slide | |
+ when :paragraph | |
+ @body << Text.new(@buffer) | |
+ end | |
+ clear_accumulation_buffer! | |
+ end | |
+ end | |
+ end | |
+ end | |
+end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment