[DRE-commits] [ruby-org] 204/303: Corrects HTML output for definition lists and tables.
Jérémy Bobbio
lunar at alioth.debian.org
Fri Aug 9 17:33:58 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 3ecb63e94f4257fad344c6980c6e2036aae484f2
Author: vonavi <ivvl82 at gmail.com>
Date: Wed Dec 19 00:28:23 2012 +0200
Corrects HTML output for definition lists and tables.
---
lib/org-ruby/html_output_buffer.rb | 4 ++--
lib/org-ruby/line.rb | 15 ++++++++----
lib/org-ruby/output_buffer.rb | 44 +++++++++++++-----------------------
lib/org-ruby/parser.rb | 4 ++--
4 files changed, 30 insertions(+), 37 deletions(-)
diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb
index db9ee6b..0c6b47e 100644
--- a/lib/org-ruby/html_output_buffer.rb
+++ b/lib/org-ruby/html_output_buffer.rb
@@ -135,7 +135,7 @@ module Orgmode
escape_buffer!
if @buffer.length > 0 and @output_type == :horizontal_rule then
@output << "<hr />\n"
- elsif @buffer.length > 0 and @output_type == :definition_list then
+ elsif @buffer.length > 0 and @output_type == :definition_item then
unless buffer_mode_is_table? and skip_tables?
output_indentation
d = @buffer.split("::", 2)
@@ -182,7 +182,7 @@ module Orgmode
@footnotes.each do |name, defi|
@output << "<p class=\"footnote\"><sup><a class=\"footnum\" name=\"fn.#{name}\" href=\"#fnr.#{name}\">#{name}</a></sup>" \
<< inline_formatting(defi) \
- << "</p>\n"
+ << "\n</p>\n"
end
@output << "</div>\n</div>\n"
diff --git a/lib/org-ruby/line.rb b/lib/org-ruby/line.rb
index 9ec80d1..34ff634 100644
--- a/lib/org-ruby/line.rb
+++ b/lib/org-ruby/line.rb
@@ -214,11 +214,9 @@ module Orgmode
when code_block_line? # Do not try to guess the type of this line if it is accumulating source code
:src
when definition_list? # order is important! A definition_list is also an unordered_list!
- :definition_list
- when ordered_list?
- :ordered_list
- when unordered_list?
- :unordered_list
+ :definition_item
+ when (ordered_list? or unordered_list?)
+ :list_item
when property_drawer_begin_block?
:property_drawer_begin_block
when property_drawer_end_block?
@@ -247,6 +245,13 @@ module Orgmode
end
end
+ def major_mode
+ return :definition_list if definition_list? # order is important! A definition_list is also an unordered_list!
+ return :ordered_list if ordered_list?
+ return :unordered_list if unordered_list?
+ return :table if table?
+ end
+
######################################################################
private
diff --git a/lib/org-ruby/output_buffer.rb b/lib/org-ruby/output_buffer.rb
index 88f97c6..e614312 100644
--- a/lib/org-ruby/output_buffer.rb
+++ b/lib/org-ruby/output_buffer.rb
@@ -87,13 +87,15 @@ module Orgmode
flush!
maintain_mode_stack(line)
end
- @output_type = line.paragraph_type
+ if line.assigned_paragraph_type
+ @output_type = line.assigned_paragraph_type
+ else
+ @output_type = line.paragraph_type
+ end
push_mode(:inline_example, line) if line.inline_example? and current_mode != :inline_example and not line.property_drawer?
pop_mode(:inline_example) if current_mode == :inline_example and !line.inline_example?
push_mode(:property_drawer, line) if line.property_drawer? and current_mode != :property_drawer
pop_mode(:property_drawer) if current_mode == :property_drawer and line.property_drawer_end_block?
- push_mode(:table, line) if enter_table?
- pop_mode(:table) if exit_table?
@buffered_lines.push(line)
end
@@ -123,18 +125,6 @@ module Orgmode
@headline_number_stack.join(".")
end
- # Tests if we are entering a table mode.
- def enter_table?
- ((@output_type == :table_row) || (@output_type == :table_header) || (@output_type == :table_separator)) &&
- (current_mode != :table)
- end
-
- # Tests if we are existing a table mode.
- def exit_table?
- ((@output_type != :table_row) && (@output_type != :table_header) && (@output_type != :table_separator)) &&
- (current_mode == :table)
- end
-
# Accumulate the string @str at .
def << (str)
if @buffer_mode && @buffer_mode != current_mode then
@@ -178,31 +168,25 @@ module Orgmode
# Close previous tags on demand. Two blank lines close all tags.
while ((not @list_indent_stack.empty?) and
@list_indent_stack.last >= line.indent)
- unless (line.plain_list? and
- current_mode == line.paragraph_type and
- @list_indent_stack.last == line.indent)
+ unless (@list_indent_stack.last == line.indent and
+ current_mode == line.major_mode)
pop_mode
else
break
end
end
- # Open plain list.
- if line.plain_list?
+ # Opens the major mode of line if it exists.
+ if line.major_mode
if (@list_indent_stack.empty? or
@list_indent_stack.last < line.indent)
- push_mode(line.paragraph_type, line)
+ push_mode(line.major_mode, line)
@output << "\n"
end
end
# Open tag preceding text, including list item.
if (@list_indent_stack.empty? or
@list_indent_stack.last <= line.indent)
- if (line.paragraph_type == :ordered_list or
- line.paragraph_type == :unordered_list)
- push_mode(:list_item, line)
- elsif not line.paragraph_type == :blank
- push_mode(line.paragraph_type, line)
- end
+ push_mode(line.paragraph_type, line)
end
else # If blank line, close preceding paragraph
pop_mode if current_mode == :paragraph
@@ -219,6 +203,10 @@ module Orgmode
# Special case: Assign mode if not yet done.
return false if not current_mode
+ # Special case: Don't accumulate headings and horizontal rules.
+ return false if (HeadingModes.include?(current_mode) or
+ current_mode == :horizontal_rule)
+
# Special case: We are accumulating source code block content for colorizing
return true if line.paragraph_type == :src and @output_type == :src
@@ -232,7 +220,7 @@ module Orgmode
return false if line.indent <= indent
end
# Special case: Multiple "paragraphs" get accumulated.
- return true if current_mode == :paragraph
+ return true unless current_mode == :comment
end
false
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index 659a5af..9db2ac4 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -276,9 +276,9 @@ module Orgmode
when :table_row, :table_header
- output_buffer << line.line.lstrip
+ output_buffer << line.line.lstrip << "\n"
- when :unordered_list, :ordered_list, :definition_list, :src
+ when :src
output_buffer << line.output_text << "\n"
--
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