[DRE-commits] [ruby-org] 214/303: Corrects Textile output.
Jérémy Bobbio
lunar at alioth.debian.org
Fri Aug 9 17:34:00 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 ffda755c61b227cd927176ba989e3ed5d5abe2b7
Author: vonavi <ivvl82 at gmail.com>
Date: Thu Dec 20 18:32:47 2012 +0200
Corrects Textile output.
---
lib/org-ruby/textile_output_buffer.rb | 48 +++++++++++++++++++--------------
1 file changed, 28 insertions(+), 20 deletions(-)
diff --git a/lib/org-ruby/textile_output_buffer.rb b/lib/org-ruby/textile_output_buffer.rb
index 3ee8c44..3740463 100644
--- a/lib/org-ruby/textile_output_buffer.rb
+++ b/lib/org-ruby/textile_output_buffer.rb
@@ -6,21 +6,29 @@ module Orgmode
def initialize(output)
super(output)
- @add_paragraph = false
+ @add_paragraph = true
@support_definition_list = true # TODO this should be an option
@footnotes = {}
end
- def push_mode(mode)
+ def push_mode(mode, indent)
+ @list_indent_stack.push(indent)
super(mode)
- @output << "bc.. " if mode_is_code(mode)
- @output << "\np=. " if mode == :center
+ @output << "bc.. " if mode_is_code? mode
+ if mode == :center or mode == :blockquote
+ @add_paragraph = false
+ @output << "\n"
+ end
+ true
end
def pop_mode(mode = nil)
m = super(mode)
- @add_paragraph = (mode_is_code(m))
- @output << "\n" if mode == :center
+ @list_indent_stack.pop
+ if m == :center or m == :blockquote
+ @add_paragraph = true
+ @output << "\n"
+ end
m
end
@@ -74,31 +82,31 @@ module Orgmode
# Flushes the current buffer
def flush!
- @buffer = @buffer.rstrip
@logger.debug "FLUSH ==========> #{@output_type}"
- if (@output_type == :blank) then
+ if @output_type == :blank and not preserve_whitespace?
@output << "\n"
elsif (@buffer.length > 0) then
- if @add_paragraph then
- @output << "p. " if @output_type == :paragraph
- @add_paragraph = false
+ @output << "p. " if @add_paragraph and current_mode == :paragraph
+ if @mode_stack[0] and current_mode == :paragraph
+ @output << "p=. " if @mode_stack[0] == :center
+ @output << "bq. " if @mode_stack[0] == :blockquote
end
- @output << "bq. " if current_mode == :blockquote
- if @output_type == :definition_list and @support_definition_list then
- @output << "-" * @list_indent_stack.length << " "
+ if current_mode == :definition_item and @support_definition_list
+ @output << "-" * @mode_stack.count(:definition_item) << " "
@buffer.sub!("::", ":=")
- elsif @output_type == :ordered_list then
- @output << "#" * @list_indent_stack.length << " "
- elsif @output_type == :unordered_list or \
- (@output_type == :definition_list and not @support_definition_list) then
- @output << "*" * @list_indent_stack.length << " "
+ elsif current_mode == :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
end
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"
+ @output << inline_formatting(@buffer)
end
end
clear_accumulation_buffer!
--
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