[DRE-commits] [ruby-org] 225/303: Line translating was moved to "output_buffer.rb", and needless accessors were removed.
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 71cf766f13fbb9e2efa60f050534366c57901550
Author: vonavi <ivvl82 at gmail.com>
Date: Sat Jan 12 00:49:46 2013 +0300
Line translating was moved to "output_buffer.rb", and needless accessors were removed.
---
lib/org-ruby/output_buffer.rb | 49 ++++++++++++++++++++++++-----------------
lib/org-ruby/parser.rb | 15 +------------
2 files changed, 30 insertions(+), 34 deletions(-)
diff --git a/lib/org-ruby/output_buffer.rb b/lib/org-ruby/output_buffer.rb
index 451184c..612961d 100644
--- a/lib/org-ruby/output_buffer.rb
+++ b/lib/org-ruby/output_buffer.rb
@@ -8,40 +8,37 @@ module Orgmode
# add a newline character prior emitting the output.
class OutputBuffer
- # 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
-
- # These are the Line objects that are currently in the accumulation
- # buffer.
- attr_reader :buffered_lines
-
- # This is the output mode of the accumulation buffer.
- attr_reader :buffer_mode
-
# This is the overall output buffer
attr_reader :output
# This is the current type of output being accumulated.
attr_accessor :output_type
- # This stack is used to do proper outline numbering of headlines.
- attr_accessor :headline_number_stack
-
# Creates a new OutputBuffer object that is bound to an output object.
# The output will get flushed to =output=.
def initialize(output)
- @output = output
+ # This is the accumulation buffer. It's a holding pen so
+ # consecutive lines of the right type can get stuck together
+ # without intervening newlines.
@buffer = ""
+
+ # These are the Line objects that are currently in the
+ # accumulation buffer.
@buffered_lines = []
+
+ # This is the output mode of the accumulation buffer.
@buffer_mode = nil
+
+ # This stack is used to do proper outline numbering of
+ # headlines.
+ @headline_number_stack = []
+
+ @output = output
@output_type = :start
@list_indent_stack = []
@paragraph_modifier = nil
@cancel_modifier = false
@mode_stack = []
- @headline_number_stack = []
@logger = Logger.new(STDERR)
if ENV['DEBUG'] or $DEBUG
@@ -71,9 +68,9 @@ module Orgmode
m
end
- # Prepares the output buffer to receive content from a line.
- # As a side effect, this may flush the current accumulated text.
- def prepare(line)
+ def insert(line)
+ # Prepares the output buffer to receive content from a line.
+ # As a side effect, this may flush the current accumulated text.
@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.begin_block?
@@ -86,7 +83,19 @@ module Orgmode
else
@output_type = line.paragraph_type
end
+
+ # Adds the current line to the output buffer
@buffered_lines.push(line)
+ if preserve_whitespace? and not line.begin_block?
+ self << "\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, :blockquote, :center, :example, :src
+ # Nothing
+ else
+ self << "\n" << line.output_text.strip
+ end
+ end
end
# Flushes everything currently in the accumulation buffer into the
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index 1570c59..050bca6 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -251,20 +251,7 @@ module Orgmode
def self.translate(lines, output_buffer)
output_buffer.output_type = :start
lines.each do |line|
-
- # See if we're carrying paragraph payload, and output
- # it if we're about to switch to some other output type.
- output_buffer.prepare(line)
- if output_buffer.preserve_whitespace? and not line.begin_block?
- 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, :blockquote, :center, :example, :src
- # Nothing
- else
- output_buffer << "\n" << line.output_text.strip
- end
- end
+ output_buffer.insert(line)
end
output_buffer.flush!
output_buffer.pop_mode while output_buffer.current_mode
--
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