Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Corrects HTML output for definition lists and tables.

  • Loading branch information...
commit 3ecb63e94f4257fad344c6980c6e2036aae484f2 1 parent 2145515
@vonavi authored
View
4 lib/org-ruby/html_output_buffer.rb
@@ -135,7 +135,7 @@ def flush!
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 @@ def output_footnotes!
@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"
View
15 lib/org-ruby/line.rb
@@ -214,11 +214,9 @@ def determine_paragraph_type
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 @@ def determine_paragraph_type
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
View
44 lib/org-ruby/output_buffer.rb
@@ -87,13 +87,15 @@ def prepare(line)
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 @@ def get_next_headline_number(level)
@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@.
def << (str)
if @buffer_mode && @buffer_mode != current_mode then
@@ -178,31 +168,25 @@ def maintain_mode_stack(line)
# 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 @@ def should_accumulate_output?(line)
# 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 @@ def should_accumulate_output?(line)
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
View
4 lib/org-ruby/parser.rb
@@ -276,9 +276,9 @@ def self.translate(lines, output_buffer)
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"
Please sign in to comment.
Something went wrong with that request. Please try again.