[DRE-commits] [ruby-org] 224/303: No major mode is needed for blocks from now, block contents is accumulated much carefully.

Jérémy Bobbio lunar at alioth.debian.org
Fri Aug 9 17:34:02 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 f596ca1bcb6e4f106021710bb171cfe9a0027315
Author: vonavi <ivvl82 at gmail.com>
Date:   Fri Jan 11 23:39:09 2013 +0300

    No major mode is needed for blocks from now, block contents is accumulated much carefully.
---
 lib/org-ruby/line.rb          |   20 ++++++---------
 lib/org-ruby/output_buffer.rb |   56 ++++++++++++++++++++---------------------
 lib/org-ruby/parser.rb        |    2 +-
 3 files changed, 36 insertions(+), 42 deletions(-)

diff --git a/lib/org-ruby/line.rb b/lib/org-ruby/line.rb
index 0617a1b..1bb7dce 100644
--- a/lib/org-ruby/line.rb
+++ b/lib/org-ruby/line.rb
@@ -229,10 +229,14 @@ module Orgmode
         :property_drawer_item
       when metadata?
         :metadata
-      when begin_block?
-        :begin_block
-      when end_block?
-        :end_block
+      when (block_type and block_type.casecmp("QUOTE") == 0)
+        :blockquote
+      when (block_type and block_type.casecmp("CENTER") == 0)
+        :center
+      when (block_type and block_type.casecmp("EXAMPLE") == 0)
+        :example
+      when (block_type and block_type.casecmp("SRC") == 0)
+        :src
       when comment?
         :comment
       when table_separator?
@@ -260,14 +264,6 @@ module Orgmode
         :unordered_list
       when table?
         :table
-      when (block_type and block_type.casecmp("QUOTE") == 0)
-        :blockquote
-      when (block_type and block_type.casecmp("CENTER") == 0)
-        :center
-      when (block_type and block_type.casecmp("EXAMPLE") == 0)
-        :example
-      when (block_type and block_type.casecmp("SRC") == 0)
-        :src
       end
     end
 
diff --git a/lib/org-ruby/output_buffer.rb b/lib/org-ruby/output_buffer.rb
index e25878e..451184c 100644
--- a/lib/org-ruby/output_buffer.rb
+++ b/lib/org-ruby/output_buffer.rb
@@ -156,8 +156,7 @@ module Orgmode
       return true if ((line.paragraph_type == :inline_example) ^
                       (@output_type == :inline_example))
       # Boundary of begin...end block
-      return true if (@output_type == :begin_block or
-                      @output_type == :end_block)
+      return true if mode_is_block? @output_type
     end
 
     def maintain_mode_stack(line)
@@ -166,44 +165,43 @@ module Orgmode
                    current_mode == :paragraph or
                    current_mode == :inline_example)
 
+      # End-block line closes every mode within block
+      if line.end_block? and @mode_stack.include? line.paragraph_type
+        pop_mode until current_mode == line.paragraph_type
+      end
+
       if ((not line.paragraph_type == :blank) or
           @output_type == :blank)
         # Close previous tags on demand. Two blank lines close all tags.
         while ((not @list_indent_stack.empty?) and
-               @list_indent_stack.last > line.indent)
-          pop_mode
-        end
-        while ((not @list_indent_stack.empty?) and
-               @list_indent_stack.last == line.indent and
-               # item can't close its major mode
-               line.major_mode != current_mode and
-               # don't allow an arbitrary line to close block
+               @list_indent_stack.last >= line.indent and
+               # Don't allow an arbitrary line to close block
                (not mode_is_block? current_mode))
-          pop_mode
+          # Item can't close its major mode
+          if (@list_indent_stack.last == line.indent and
+              line.major_mode == current_mode)
+            break
+          else
+            pop_mode
+          end
         end
       end
 
+      # Special case: Only end-block line closes block
+      pop_mode if line.end_block? and line.paragraph_type == current_mode
+
       unless line.paragraph_type == :blank
-        # Opens the major mode of line if it exists.
-        if line.major_mode
-          if (@list_indent_stack.empty? or
-              @list_indent_stack.last < line.indent)
-            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)
-          # Don't push intrinsic mode of a block
-          push_mode(line.paragraph_type, line.indent) unless line.block_type
+            @list_indent_stack.last <= line.indent or
+            mode_is_block? current_mode)
+          # Opens the major mode of line if it exists
+          if @list_indent_stack.last != line.indent or mode_is_block? current_mode
+            push_mode(line.major_mode, line.indent) if line.major_mode
+          end
+          # Opens tag that precedes text immediately
+          push_mode(line.paragraph_type, line.indent) unless line.end_block?
         end
       end
-
-      # Special case: Only end-block line closes the block
-      if mode_is_block? current_mode
-        pop_mode if (line.end_block? and
-                     line.major_mode == current_mode)
-      end
     end
 
     def output_footnotes!
@@ -219,7 +217,7 @@ module Orgmode
       # Special case: Handles accumulating block content and example lines
       if mode_is_code? current_mode
         return true unless (line.end_block? and
-                            line.major_mode == current_mode)
+                            line.paragraph_type == current_mode)
       end
       return false if boundary_of_block?(line)
       return true if current_mode == :inline_example
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index 948e67a..1570c59 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -259,7 +259,7 @@ module Orgmode
           output_buffer << "\n" << line.output_text
         else
           case line.paragraph_type
-          when :metadata, :table_separator, :blank, :comment, :property_drawer_item, :property_drawer_begin_block, :property_drawer_end_block, :begin_block, :end_block
+          when :metadata, :table_separator, :blank, :comment, :property_drawer_item, :property_drawer_begin_block, :property_drawer_end_block, :blockquote, :center, :example, :src
             # Nothing
           else
             output_buffer << "\n" << line.output_text.strip

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