[DRE-commits] [ruby-org] 56/303: Got rid of the extraneous newline at the start of code blocks.

Jérémy Bobbio lunar at alioth.debian.org
Fri Aug 9 17:33:27 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 f90170113f4e74872af04966261f3d5c327b7f79
Author: Brian Dewey <bdewey at gmail.com>
Date:   Tue Dec 29 12:10:42 2009 -0800

    Got rid of the extraneous newline at the start of code blocks.
---
 History.txt                              |    1 +
 lib/org-ruby/html_output_buffer.rb       |    3 ++-
 lib/org-ruby/output_buffer.rb            |   21 ++++++++++++++++++---
 lib/org-ruby/textile_output_buffer.rb    |    1 +
 spec/html_examples/block_code.html       |    2 --
 spec/html_examples/code-comment.html     |    1 -
 spec/html_examples/escape-pre.html       |    1 -
 spec/html_examples/metadata-comment.html |    1 -
 8 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/History.txt b/History.txt
index 90bc2d2..38b405a 100644
--- a/History.txt
+++ b/History.txt
@@ -1,5 +1,6 @@
 == X.X.X / 2009-12-29
 
+* Got rid of the extraneous newline at the start of code blocks.
 * Everything now shows up in code blocks, even org-mode metadata.
 * Fixed bugs:
   * Regressed smart double quotes with HTML escaping. Added a test
diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb
index 12b3053..88e5495 100644
--- a/lib/org-ruby/html_output_buffer.rb
+++ b/lib/org-ruby/html_output_buffer.rb
@@ -50,7 +50,7 @@ module Orgmode
 
     def flush!
       escape_buffer!
-      if current_mode == :code then
+      if @buffer_mode == :code then
         # Whitespace is significant in :code mode. Always output the buffer
         # and do not do any additional translation.
         # 
@@ -69,6 +69,7 @@ module Orgmode
         end
       end
       @buffer = ""
+      @buffer_mode = nil
     end
 
     ######################################################################
diff --git a/lib/org-ruby/output_buffer.rb b/lib/org-ruby/output_buffer.rb
index f71e996..65ac9c5 100644
--- a/lib/org-ruby/output_buffer.rb
+++ b/lib/org-ruby/output_buffer.rb
@@ -8,9 +8,14 @@ module Orgmode
   # add a newline character prior emitting the output.
   class OutputBuffer
 
-    # This is the temporary buffer that we accumulate into.
+    # This is the accumulation buffer. It's a holding pen so
+    # consecutive lines of the right type can get stuck together
+    # without intervening newlines.
     attr_reader :buffer
 
+    # This is the output mode of the accumulation buffer.
+    attr_reader :buffer_mode
+
     # This is the overall output buffer
     attr_reader :output
 
@@ -22,17 +27,22 @@ module Orgmode
     def initialize(output)
       @output = output
       @buffer = ""
+      @buffer_mode = nil
       @output_type = :start
       @list_indent_stack = []
       @paragraph_modifier = nil
       @cancel_modifier = false
       @mode_stack = []
-      push_mode(:normal)
 
       @logger = Logger.new(STDERR)
-      @logger.level = Logger::WARN
+      if ENV['DEBUG']
+        @logger.level = Logger::DEBUG
+      else
+        @logger.level = Logger::WARN
+      end
 
       @re_help = RegexpHelper.new
+      push_mode(:normal)
     end
 
     Modes = [:normal, :ordered_list, :unordered_list, :blockquote, :code, :table]
@@ -83,6 +93,11 @@ module Orgmode
 
     # Accumulate the string @str at .
     def << (str)
+      if @buffer_mode && @buffer_mode != current_mode then
+        raise "Accumulation buffer is mixing modes: @buffer_mode == #{@buffer_mode}, current_mode == #{current_mode}"
+      else
+        @buffer_mode = current_mode
+      end
       @buffer << str
     end
 
diff --git a/lib/org-ruby/textile_output_buffer.rb b/lib/org-ruby/textile_output_buffer.rb
index 490ba9c..9d62790 100644
--- a/lib/org-ruby/textile_output_buffer.rb
+++ b/lib/org-ruby/textile_output_buffer.rb
@@ -60,6 +60,7 @@ module Orgmode
         @output << inline_formatting(@buffer) << "\n"
       end
       @buffer = ""
+      @buffer_mode = nil
     end
 
 
diff --git a/spec/html_examples/block_code.html b/spec/html_examples/block_code.html
index 0f94686..71c7456 100644
--- a/spec/html_examples/block_code.html
+++ b/spec/html_examples/block_code.html
@@ -2,7 +2,6 @@
 <p>I need to get block code examples working. In <code>orgmode</code>, they look like this:</p>
 <pre>
 
-
     def initialize(output)
       @output = output
       @buffer = ""
@@ -19,7 +18,6 @@
 <p>Putting in another paragraph for good measure.</p>
 <p>Code should also get cancelled by a list, thus:</p>
 <pre>
-
 This is my code!
 
 Another line!
diff --git a/spec/html_examples/code-comment.html b/spec/html_examples/code-comment.html
index e934998..31ddb47 100644
--- a/spec/html_examples/code-comment.html
+++ b/spec/html_examples/code-comment.html
@@ -1,7 +1,6 @@
 <h1 class="title">Code Comment</h1>
 <p>I need to be able to export things that look like org-mode comments inside of code blocks, like this:</p>
 <pre>
-
 #+TITLE:     orgmode_parser.org
 #+AUTHOR:    
 #+EMAIL:     brian at BRIAN-DESK
diff --git a/spec/html_examples/escape-pre.html b/spec/html_examples/escape-pre.html
index d8824a2..70ef701 100644
--- a/spec/html_examples/escape-pre.html
+++ b/spec/html_examples/escape-pre.html
@@ -1,5 +1,4 @@
 <pre>
-
 <li>[ ] &#8220;smart quotes&#8221;</li> 
 <li>[ ] I think I need this for &#8216;single quotes&#8217; too. Don&#8217;t I?</li> 
 <li>[ ] Em dashes would be great &#8212; wouldn&#8217;t they?</li> 
diff --git a/spec/html_examples/metadata-comment.html b/spec/html_examples/metadata-comment.html
index 562ab63..17bed02 100644
--- a/spec/html_examples/metadata-comment.html
+++ b/spec/html_examples/metadata-comment.html
@@ -1,7 +1,6 @@
 <h1 class="title">Metadata, etc.</h1>
 <p>I normally filter out things that look like metadata. Can’t do it any more. I need to see all of the following:</p>
 <pre>
-
 * DONE Handle inline formatting
   CLOSED: [2009-12-26 Sat 21:41]
   :PROPERTIES:

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