[DRE-commits] [ruby-org] 187/303: Merge three methods 'to_textile' into that one
Jérémy Bobbio
lunar at alioth.debian.org
Fri Aug 9 17:33:55 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 7e2f010465968c8ea607b82a2f756e7f5323fb6e
Author: vonavi <ivvl82 at gmail.com>
Date: Sat Oct 6 13:47:34 2012 +0300
Merge three methods 'to_textile' into that one
---
lib/org-ruby/headline.rb | 7 -------
lib/org-ruby/line.rb | 6 ------
lib/org-ruby/parser.rb | 9 ++++++---
lib/org-ruby/textile_output_buffer.rb | 8 +++++++-
4 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/lib/org-ruby/headline.rb b/lib/org-ruby/headline.rb
index 3b2ed7a..c48d112 100644
--- a/lib/org-ruby/headline.rb
+++ b/lib/org-ruby/headline.rb
@@ -85,13 +85,6 @@ module Orgmode
:"heading#{@level}"
end
- # Converts this headline and its body to textile.
- def to_textile
- output = "h#{@level}. #{@headline_text}\n"
- output << Line.to_textile(@body_lines[1..-1])
- output
- end
-
######################################################################
private
diff --git a/lib/org-ruby/line.rb b/lib/org-ruby/line.rb
index 564666a..54a8761 100644
--- a/lib/org-ruby/line.rb
+++ b/lib/org-ruby/line.rb
@@ -223,12 +223,6 @@ module Orgmode
return :paragraph
end
- def self.to_textile(lines)
- output = ""
- output_buffer = TextileOutputBuffer.new(output)
- Parser.translate(lines, output_buffer)
- end
-
######################################################################
private
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index 1e2ad6d..d2266cc 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -158,7 +158,7 @@ module Orgmode
line = Line.new line, self
if line.end_block? and line.code_block?
- mode = :normal
+ mode = :normal
else
line.assigned_paragraph_type = :src
end
@@ -195,9 +195,11 @@ module Orgmode
# Saves the loaded orgmode file as a textile file.
def to_textile
output = ""
- output << Line.to_textile(@header_lines)
+ output_buffer = TextileOutputBuffer.new(output)
+
+ Parser.translate(@header_lines, output_buffer)
@headlines.each do |headline|
- output << headline.to_textile
+ Parser.translate(headline.body_lines, output_buffer)
end
output
end
@@ -248,6 +250,7 @@ module Orgmode
# Converts an array of lines to the appropriate format.
# Writes the output to +output_buffer+.
def self.translate(lines, output_buffer)
+ output_buffer.output_type = :start
lines.each do |line|
# See if we're carrying paragraph payload, and output
diff --git a/lib/org-ruby/textile_output_buffer.rb b/lib/org-ruby/textile_output_buffer.rb
index 0e69960..e11688d 100644
--- a/lib/org-ruby/textile_output_buffer.rb
+++ b/lib/org-ruby/textile_output_buffer.rb
@@ -92,7 +92,13 @@ module Orgmode
(@output_type == :definition_list and not @support_definition_list) then
@output << "*" * @list_indent_stack.length << " "
end
- @output << inline_formatting(@buffer) << "\n"
+ if (@buffered_lines[0].kind_of?(Headline)) then
+ headline = @buffered_lines[0]
+ raise "Cannot be more than one headline!" if @buffered_lines.length > 1
+ @output << "h#{headline.level}. #{headline.headline_text}\n"
+ else
+ @output << inline_formatting(@buffer) << "\n"
+ end
end
clear_accumulation_buffer!
end
--
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