Skip to content

Commit

Permalink
Suppresses to pop mode for a blank line.
Browse files Browse the repository at this point in the history
  • Loading branch information
vonavi committed Jan 10, 2013
1 parent 3922887 commit b3ca932
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
19 changes: 9 additions & 10 deletions lib/org-ruby/html_output_buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,25 @@ def initialize(output, opts = {})
# write out one of the block tags in the HtmlBlockTag constant to
# put this information in the HTML stream.
def push_mode(mode, indent)
super(mode)
@list_indent_stack.push(indent)
if HtmlBlockTag[mode] then

skip_tag = ((mode_is_table?(mode) and skip_tables?) or
(mode == :src and defined? Pygments))
if HtmlBlockTag[mode] and not skip_tag
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

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
output_indentation
@logger.debug "#{mode}: <#{HtmlBlockTag[mode]}#{css_class}>\n"
@output << "<#{HtmlBlockTag[mode]}#{css_class}>"
# Entering a new mode obliterates the title decoration
@title_decoration = ""
end
super(mode)
skip
not skip_tag
end

# We are leaving a mode. Close any tags that were opened when
Expand Down
14 changes: 8 additions & 6 deletions lib/org-ruby/output_buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,27 @@ def maintain_mode_stack(line)
(not mode_is_block? current_mode))
pop_mode
end
end

unless line.paragraph_type == :blank
# 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)
@output << "\n" unless push_mode(line.major_mode, line.indent)
@output << "\n" if 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.indent) unless line.block_type
end
end

# Special case: Only end-block line closes the block
if mode_is_block? current_mode
pop_mode if (line.end_block? and
line.major_mode == current_mode)
end
# Special case: Only end-block line closes the block
if mode_is_block? current_mode
pop_mode if (line.end_block? and
line.major_mode == current_mode)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/org-ruby/textile_output_buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def push_mode(mode, indent)
@add_paragraph = false
@output << "\n"
end
true
false
end

def pop_mode(mode = nil)
Expand Down

0 comments on commit b3ca932

Please sign in to comment.