[DRE-commits] [ruby-org] 244/303: No need buffered lines from now.
Jérémy Bobbio
lunar at alioth.debian.org
Fri Aug 9 17:34:06 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 d370d5c2e35fc897c40bf95a971542055bfa317e
Author: vonavi <ivvl82 at gmail.com>
Date: Tue Jan 29 20:11:11 2013 +0200
No need buffered lines from now.
---
lib/org-ruby/html_output_buffer.rb | 34 ++++++++++++++++-----------------
lib/org-ruby/output_buffer.rb | 15 +--------------
lib/org-ruby/textile_output_buffer.rb | 25 ++++++++++++------------
3 files changed, 29 insertions(+), 45 deletions(-)
diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb
index d89b449..8228e61 100644
--- a/lib/org-ruby/html_output_buffer.rb
+++ b/lib/org-ruby/html_output_buffer.rb
@@ -149,22 +149,8 @@ module Orgmode
@new_paragraph = nil
@logger.debug "FLUSH ==========> #{current_mode}"
- case
- when @buffered_lines[0].kind_of?(Headline)
- headline = @buffered_lines[0]
- raise "Cannot be more than one headline!" if @buffered_lines.length > 1
- if @options[:export_heading_number] then
- level = headline.level
- heading_number = get_next_headline_number(level)
- @output << "<span class=\"heading-number heading-number-#{level}\">#{heading_number} </span>"
- end
- if @options[:export_todo] and headline.keyword then
- keyword = headline.keyword
- @output << "<span class=\"todo-keyword #{keyword}\">#{keyword} </span>"
- end
- @output << inline_formatting(@buffer)
-
- when current_mode == :definition_term
+ case current_mode
+ when :definition_term
d = @buffer.split("::", 2)
@output << inline_formatting(d[0].strip)
indent = @list_indent_stack.last
@@ -175,7 +161,7 @@ module Orgmode
@output << inline_formatting(d[1].strip)
@new_paragraph = nil
- when current_mode == :horizontal_rule
+ when :horizontal_rule
add_paragraph unless @new_paragraph == :start
@new_paragraph = true
@output << "<hr />"
@@ -184,7 +170,19 @@ module Orgmode
@output << inline_formatting(@buffer)
end
end
- clear_accumulation_buffer!
+ @buffer = ""
+ end
+
+ def add_line_attributes headline
+ if @options[:export_heading_number] then
+ level = headline.level
+ heading_number = get_next_headline_number(level)
+ @output << "<span class=\"heading-number heading-number-#{level}\">#{heading_number} </span>"
+ end
+ if @options[:export_todo] and headline.keyword then
+ keyword = headline.keyword
+ @output << "<span class=\"todo-keyword #{keyword}\">#{keyword} </span>"
+ end
end
def output_footnotes!
diff --git a/lib/org-ruby/output_buffer.rb b/lib/org-ruby/output_buffer.rb
index 302156d..dbc2981 100644
--- a/lib/org-ruby/output_buffer.rb
+++ b/lib/org-ruby/output_buffer.rb
@@ -22,10 +22,6 @@ module Orgmode
# without intervening newlines.
@buffer = ""
- # These are the Line objects that are currently in the
- # accumulation buffer.
- @buffered_lines = []
-
# This stack is used to do proper outline numbering of
# headlines.
@headline_number_stack = []
@@ -69,10 +65,10 @@ module Orgmode
flush!
maintain_mode_stack(line)
end
+ add_line_attributes(line) if line.kind_of? Headline
@output_type = line.assigned_paragraph_type || line.paragraph_type
# Adds the current line to the output buffer
- @buffered_lines.push(line)
if preserve_whitespace? and not line.begin_block?
@buffer << "\n" << line.output_text
else
@@ -87,15 +83,6 @@ module Orgmode
end
end
- # Flushes everything currently in the accumulation buffer into the
- # output buffer. Derived classes must override this to actually move
- # content into the output buffer with the appropriate markup. This
- # method just does common bookkeeping cleanup.
- def clear_accumulation_buffer!
- @buffer = ""
- @buffered_lines = []
- end
-
# Gets the next headline number for a given level. The intent is
# this function is called sequentially for each headline that
# needs to get numbered. It does standard outline numbering.
diff --git a/lib/org-ruby/textile_output_buffer.rb b/lib/org-ruby/textile_output_buffer.rb
index 871a68c..cdffe0e 100644
--- a/lib/org-ruby/textile_output_buffer.rb
+++ b/lib/org-ruby/textile_output_buffer.rb
@@ -89,36 +89,35 @@ module Orgmode
@output << @buffer << "\n"
when @buffer.length > 0
- case
- when @buffered_lines[0].kind_of?(Headline)
- headline = @buffered_lines[0]
- raise "Cannot be more than one headline!" if @buffered_lines.length > 1
- @output << "h#{headline.level}. "
-
- when current_mode == :paragraph
+ case current_mode
+ when :paragraph
@output << "p. " if @add_paragraph
@output << "p=. " if @mode_stack[0] == :center
@output << "bq. " if @mode_stack[0] == :quote
- when current_mode == :list_item
+ when :list_item
if @mode_stack[-2] == :ordered_list
@output << "#" * @mode_stack.count(:list_item) << " "
else # corresponds to unordered list
@output << "*" * @mode_stack.count(:list_item) << " "
end
- when (current_mode == :definition_term and @support_definition_list)
- @output << "-" * @mode_stack.count(:definition_term) << " "
- @buffer.sub!("::", ":=")
+ when :definition_term
+ if @support_definition_list
+ @output << "-" * @mode_stack.count(:definition_term) << " "
+ @buffer.sub!("::", ":=")
+ end
end
@output << inline_formatting(@buffer) << "\n"
when @output_type == :blank
@output << "\n"
end
- clear_accumulation_buffer!
+ @buffer = ""
end
-
+ def add_line_attributes headline
+ @output << "h#{headline.level}. "
+ end
end # class TextileOutputBuffer
end # module Orgmode
--
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