Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Corrects the rest of HTML examples.

  • Loading branch information...
commit 2e96d42d40fa7a711b336c4e7cbebd4db3327659 1 parent c9f2edf
@vonavi authored
View
27 lib/org-ruby/html_output_buffer.rb
@@ -55,18 +55,19 @@ def initialize(output, opts = {})
# Output buffer is entering a new mode. Use this opportunity to
# write out one of the block tags in the HtmlBlockTag constant to
# put this information in the HTML stream.
- def push_mode(mode, line)
- @list_indent_stack.push(line.indent)
+ def push_mode(mode, indent = 0)
+ @list_indent_stack.push(indent)
if HtmlBlockTag[mode] then
- output_indentation
css_class = @title_decoration
css_class = " class=\"src\"" if mode == :src and @block_lang.empty?
css_class = " class=\"src src-#{@block_lang}\"" if mode == :src and not @block_lang.empty?
css_class = " class=\"example\"" if (mode == :example || mode == :inline_example)
css_class = " style=\"text-align: center\"" if mode == :center
- unless ((mode == :table and skip_tables?) or
+ skip = ((mode_is_table?(mode) and skip_tables?) or
(mode == :src and defined? Pygments))
+ unless skip
+ output_indentation
@logger.debug "#{mode}: <#{HtmlBlockTag[mode]}#{css_class}>\n"
@output << "<#{HtmlBlockTag[mode]}#{css_class}>"
end
@@ -74,6 +75,7 @@ def push_mode(mode, line)
@title_decoration = ""
end
super(mode)
+ skip
end
# We are leaving a mode. Close any tags that were opened when
@@ -81,9 +83,9 @@ def push_mode(mode, line)
def pop_mode(mode = nil)
m = super(mode)
if HtmlBlockTag[m] then
- output_indentation
- unless ((mode == :table and skip_tables?) or
- (mode == :src and defined? Pygments))
+ unless ((mode_is_table?(m) and skip_tables?) or
+ (m == :src and defined? Pygments))
+ output_indentation
@logger.debug "</#{HtmlBlockTag[m]}>\n"
@output << "</#{HtmlBlockTag[m]}>\n"
end
@@ -135,8 +137,8 @@ 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_item then
- unless buffer_mode_is_table? and skip_tables?
+ elsif @buffer.length > 0 and @buffer_mode == :definition_item then
+ unless mode_is_table?(@buffer_mode) and skip_tables?
output_indentation
d = @buffer.split("::", 2)
@output << "<#{HtmlBlockTag[:definition_term]}#{@title_decoration}>" << inline_formatting(d[0].strip) \
@@ -150,7 +152,7 @@ def flush!
@title_decoration = ""
end
elsif @buffer.length > 0 then
- unless buffer_mode_is_table? and skip_tables?
+ unless mode_is_table?(@buffer_mode) and skip_tables?
@logger.debug "FLUSH ==========> #{@buffer_mode}"
if (@buffered_lines[0].kind_of?(Headline)) then
headline = @buffered_lines[0]
@@ -198,8 +200,9 @@ def skip_tables?
@options[:skip_tables]
end
- def buffer_mode_is_table?
- @buffer_mode == :table
+ def mode_is_table?(mode)
+ (mode == :table or mode == :table_row or
+ mode == :table_separator or mode == :table_header)
end
def buffer_mode_is_src_block?
View
2  lib/org-ruby/line.rb
@@ -258,8 +258,6 @@ def determine_major_mode
:ordered_list
when unordered_list?
:unordered_list
- when property_drawer?
- :property_drawer
when table?
:table
when (begin_block? and block_type.casecmp("QUOTE") == 0)
View
9 lib/org-ruby/output_buffer.rb
@@ -78,12 +78,12 @@ def pop_mode(mode = nil)
# As a side effect, this may flush the current accumulated text.
def prepare(line)
@logger.debug "Looking at #{line.paragraph_type}(#{current_mode}) : #{line.to_s}"
+ # We try to get the lang from #+BEGIN_SRC blocks
+ @block_lang = line.block_lang if line.code_block?
if not should_accumulate_output?(line)
flush!
maintain_mode_stack(line)
end
- # We try to get the lang from #+BEGIN_SRC blocks
- @block_lang = line.block_lang if line.code_block?
if line.assigned_paragraph_type
@output_type = line.assigned_paragraph_type
else
@@ -179,14 +179,13 @@ def maintain_mode_stack(line)
if line.major_mode
if (@list_indent_stack.empty? or
@list_indent_stack.last < line.indent)
- push_mode(line.major_mode, line)
- @output << "\n"
+ @output << "\n" unless push_mode(line.major_mode, line.indent)
end
end
# Open tag that precedes text immediately
if (@list_indent_stack.empty? or
@list_indent_stack.last <= line.indent)
- push_mode(line.paragraph_type, line) unless line.begin_block?
+ push_mode(line.paragraph_type, line.indent) unless line.begin_block?
end
else # If blank line, close preceding paragraph
pop_mode if current_mode == :paragraph
View
6 lib/org-ruby/parser.rb
@@ -266,7 +266,11 @@ def self.translate(lines, output_buffer)
when :table_row, :table_header
- output_buffer << line.line.lstrip << "\n"
+ if output_buffer.preserve_whitespace?
+ output_buffer << line.line << "\n"
+ else
+ output_buffer << line.line.lstrip << "\n"
+ end
when :src
Please sign in to comment.
Something went wrong with that request. Please try again.