[DRE-commits] [ruby-org] 210/303: Corrects the rest of HTML examples.

Jérémy Bobbio lunar at alioth.debian.org
Fri Aug 9 17:33:59 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 2e96d42d40fa7a711b336c4e7cbebd4db3327659
Author: vonavi <ivvl82 at gmail.com>
Date:   Thu Dec 20 00:40:32 2012 +0200

    Corrects the rest of HTML examples.
---
 lib/org-ruby/html_output_buffer.rb |   27 +++++++++++++++------------
 lib/org-ruby/line.rb               |    2 --
 lib/org-ruby/output_buffer.rb      |    9 ++++-----
 lib/org-ruby/parser.rb             |    6 +++++-
 4 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb
index d7670c9..7f61be9 100644
--- a/lib/org-ruby/html_output_buffer.rb
+++ b/lib/org-ruby/html_output_buffer.rb
@@ -55,18 +55,19 @@ module Orgmode
     # Output buffer is entering a new mode. Use this opportunity to
     # write out one of the block tags in the HtmlBlockTag constant to
     # put this information in the HTML stream.
-    def push_mode(mode, line)
-      @list_indent_stack.push(line.indent)
+    def push_mode(mode, indent = 0)
+      @list_indent_stack.push(indent)
       if HtmlBlockTag[mode] then
-        output_indentation
         css_class = @title_decoration
         css_class = " class=\"src\"" if mode == :src and @block_lang.empty?
         css_class = " class=\"src src-#{@block_lang}\"" if mode == :src and not @block_lang.empty?
         css_class = " class=\"example\"" if (mode == :example || mode == :inline_example)
         css_class = " style=\"text-align: center\"" if mode == :center
 
-        unless ((mode == :table and skip_tables?) or
+        skip = ((mode_is_table?(mode) and skip_tables?) or
                 (mode == :src and defined? Pygments))
+        unless skip
+          output_indentation
           @logger.debug "#{mode}: <#{HtmlBlockTag[mode]}#{css_class}>\n"
           @output << "<#{HtmlBlockTag[mode]}#{css_class}>"
         end
@@ -74,6 +75,7 @@ module Orgmode
         @title_decoration = ""
       end
       super(mode)
+      skip
     end
 
     # We are leaving a mode. Close any tags that were opened when
@@ -81,9 +83,9 @@ module Orgmode
     def pop_mode(mode = nil)
       m = super(mode)
       if HtmlBlockTag[m] then
-        output_indentation
-        unless ((mode == :table and skip_tables?) or
-                (mode == :src and defined? Pygments))
+        unless ((mode_is_table?(m) and skip_tables?) or
+                (m == :src and defined? Pygments))
+          output_indentation
           @logger.debug "</#{HtmlBlockTag[m]}>\n"
           @output << "</#{HtmlBlockTag[m]}>\n"
         end
@@ -135,8 +137,8 @@ module Orgmode
         escape_buffer!
         if @buffer.length > 0 and @output_type == :horizontal_rule then
           @output << "<hr />\n"
-        elsif @buffer.length > 0 and @output_type == :definition_item then
-          unless buffer_mode_is_table? and skip_tables?
+        elsif @buffer.length > 0 and @buffer_mode == :definition_item then
+          unless mode_is_table?(@buffer_mode) and skip_tables?
             output_indentation
             d = @buffer.split("::", 2)
             @output << "<#{HtmlBlockTag[:definition_term]}#{@title_decoration}>" << inline_formatting(d[0].strip) \
@@ -150,7 +152,7 @@ module Orgmode
             @title_decoration = ""
           end
         elsif @buffer.length > 0 then
-          unless buffer_mode_is_table? and skip_tables?
+          unless mode_is_table?(@buffer_mode) and skip_tables?
             @logger.debug "FLUSH      ==========> #{@buffer_mode}"
             if (@buffered_lines[0].kind_of?(Headline)) then
               headline = @buffered_lines[0]
@@ -198,8 +200,9 @@ module Orgmode
       @options[:skip_tables]
     end
 
-    def buffer_mode_is_table?
-      @buffer_mode == :table
+    def mode_is_table?(mode)
+      (mode == :table or mode == :table_row or
+       mode == :table_separator or mode == :table_header)
     end
 
     def buffer_mode_is_src_block?
diff --git a/lib/org-ruby/line.rb b/lib/org-ruby/line.rb
index 0ecaffb..8dca0d7 100644
--- a/lib/org-ruby/line.rb
+++ b/lib/org-ruby/line.rb
@@ -258,8 +258,6 @@ module Orgmode
         :ordered_list
       when unordered_list?
         :unordered_list
-      when property_drawer?
-        :property_drawer
       when table?
         :table
       when (begin_block? and block_type.casecmp("QUOTE") == 0)
diff --git a/lib/org-ruby/output_buffer.rb b/lib/org-ruby/output_buffer.rb
index 8e40364..fbffddd 100644
--- a/lib/org-ruby/output_buffer.rb
+++ b/lib/org-ruby/output_buffer.rb
@@ -78,12 +78,12 @@ module Orgmode
     # As a side effect, this may flush the current accumulated text.
     def prepare(line)
       @logger.debug "Looking at #{line.paragraph_type}(#{current_mode}) : #{line.to_s}"
+      # We try to get the lang from #+BEGIN_SRC blocks
+      @block_lang = line.block_lang if line.code_block?
       if not should_accumulate_output?(line)
         flush!
         maintain_mode_stack(line)
       end
-      # We try to get the lang from #+BEGIN_SRC blocks
-      @block_lang = line.block_lang if line.code_block?
       if line.assigned_paragraph_type
         @output_type = line.assigned_paragraph_type
       else
@@ -179,14 +179,13 @@ module Orgmode
         if line.major_mode
           if (@list_indent_stack.empty? or
               @list_indent_stack.last < line.indent)
-            push_mode(line.major_mode, line)
-            @output << "\n"
+            @output << "\n" unless push_mode(line.major_mode, line.indent)
           end
         end
         # Open tag that precedes text immediately
         if (@list_indent_stack.empty? or
             @list_indent_stack.last <= line.indent)
-          push_mode(line.paragraph_type, line) unless line.begin_block?
+          push_mode(line.paragraph_type, line.indent) unless line.begin_block?
         end
       else # If blank line, close preceding paragraph
         pop_mode if current_mode == :paragraph
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index f11b293..7997724 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -266,7 +266,11 @@ module Orgmode
 
         when :table_row, :table_header
 
-          output_buffer << line.line.lstrip << "\n"
+          if output_buffer.preserve_whitespace?
+            output_buffer << line.line << "\n"
+          else
+            output_buffer << line.line.lstrip << "\n"
+          end
 
         when :src
 

-- 
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