[DRE-commits] [ruby-org] 256/303: Adds option #+html: to incorporate raw HTML text.

Jérémy Bobbio lunar at alioth.debian.org
Fri Aug 9 17:34:08 UTC 2013


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository ruby-org.

commit eb7deb0148375fb8aac722916e7283c81dc1ebbd
Author: vonavi <ivvl82 at gmail.com>
Date:   Thu Jan 31 23:57:11 2013 +0200

    Adds option #+html: to incorporate raw HTML text.
---
 lib/org-ruby/html_output_buffer.rb |    6 ++++++
 lib/org-ruby/line.rb               |   18 ++++++++++++++++++
 lib/org-ruby/output_buffer.rb      |   16 ++++++++++------
 3 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb
index 27f1818..097bfcd 100644
--- a/lib/org-ruby/html_output_buffer.rb
+++ b/lib/org-ruby/html_output_buffer.rb
@@ -45,6 +45,7 @@ module Orgmode
       else
         @title_decoration = ""
       end
+      @buffer_tag = "HTML"
       @options = opts
       @new_paragraph = :start
       @footnotes = {}
@@ -144,6 +145,11 @@ module Orgmode
       when (mode_is_table? current_mode and skip_tables?)
         @logger.debug "SKIP       ==========> #{current_mode}"
 
+      when (current_mode == :raw_text and @buffer.length > 0)
+        @new_paragraph = true
+        @output << "\n" unless @new_paragraph == :start
+        @output << @buffer
+
       when @buffer.length > 0
         @buffer.lstrip!
         escape_buffer!
diff --git a/lib/org-ruby/line.rb b/lib/org-ruby/line.rb
index 5d4d9ea..ae31096 100644
--- a/lib/org-ruby/line.rb
+++ b/lib/org-ruby/line.rb
@@ -124,6 +124,7 @@ module Orgmode
       return strip_ordered_list_tag if ordered_list?
       return strip_unordered_list_tag if unordered_list?
       return @line.sub(InlineExampleRegexp, "") if inline_example?
+      return strip_raw_text_tag if raw_text?
       return line
     end
 
@@ -188,6 +189,21 @@ module Orgmode
       check_assignment_or_regexp(:inline_example, InlineExampleRegexp)
     end
 
+    RawTextRegexp = /^(\s*)#\+(\w+):\s*/
+
+    # Checks if this line is raw text.
+    def raw_text?
+      check_assignment_or_regexp(:raw_text, RawTextRegexp)
+    end
+
+    def raw_text_tag
+      $2.upcase if @line =~ RawTextRegexp
+    end
+
+    def strip_raw_text_tag
+      @line.sub(RawTextRegexp) { |match| $1 }
+    end
+
     InBufferSettingRegexp = /^#\+(\w+):\s*(.*)$/
 
     # call-seq:
@@ -237,6 +253,8 @@ module Orgmode
         when "SRC"     then :src
         when "COMMENT" then :comment
         end
+      when raw_text? # order is important! Raw text can be also a comment
+        :raw_text
       when comment?
         :comment
       when table_separator?
diff --git a/lib/org-ruby/output_buffer.rb b/lib/org-ruby/output_buffer.rb
index a828ef3..1b5c066 100644
--- a/lib/org-ruby/output_buffer.rb
+++ b/lib/org-ruby/output_buffer.rb
@@ -85,6 +85,8 @@ module Orgmode
         case line.paragraph_type
         when :metadata, :table_separator, :blank, :comment, :property_drawer_item, :property_drawer_begin_block, :property_drawer_end_block, :quote, :center, :example, :src
           # Nothing
+        when :raw_text
+          @buffer << line.output_text if line.raw_text_tag == @buffer_tag
         else
           @buffer << "\n"
           buffer_indentation
@@ -150,7 +152,8 @@ module Orgmode
       pop_mode if (mode_is_heading? current_mode or
                    current_mode == :paragraph or
                    current_mode == :horizontal_rule or
-                   current_mode == :inline_example)
+                   current_mode == :inline_example or
+                   current_mode == :raw_text)
 
       # End-block line closes every mode within block
       if line.end_block? and @mode_stack.include? line.paragraph_type
@@ -197,7 +200,7 @@ module Orgmode
 
     # Tests if the current line should be accumulated in the current
     # output buffer.
-    def should_accumulate_output?(line)
+    def should_accumulate_output? line
       # Special case: Assign mode if not yet done.
       return false unless current_mode
 
@@ -206,13 +209,14 @@ module Orgmode
         return true unless (line.end_block? and
                             line.paragraph_type == current_mode)
       end
-      return false if boundary_of_block?(line)
+      return false if boundary_of_block? line
       return true if current_mode == :inline_example
 
-      # Special case: Don't accumulate headings, comments and horizontal rules.
-      return false if (mode_is_heading?(@output_type) or
+      # Special case: Don't accumulate the following lines.
+      return false if (mode_is_heading? @output_type or
                        @output_type == :comment or
-                       @output_type == :horizontal_rule)
+                       @output_type == :horizontal_rule or
+                       @output_type == :raw_text)
 
       # Special case: Blank line at least splits paragraphs
       return false if @output_type == :blank

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-org.git



More information about the Pkg-ruby-extras-commits mailing list