[DRE-commits] [ruby-org] 276/303: Skip a HTML code block for non-HTML output.
Jérémy Bobbio
lunar at alioth.debian.org
Fri Aug 9 17:34:12 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 347cf8cfb7b9e4dc91ef176749ae9efdf64ab4e9
Author: vonavi <ivvl82 at gmail.com>
Date: Mon Feb 4 02:19:50 2013 +0200
Skip a HTML code block for non-HTML output.
---
lib/org-ruby/html_output_buffer.rb | 4 ++++
lib/org-ruby/output_buffer.rb | 11 ++++++++---
lib/org-ruby/parser.rb | 6 +++---
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb
index 7c40306..f0b20df 100644
--- a/lib/org-ruby/html_output_buffer.rb
+++ b/lib/org-ruby/html_output_buffer.rb
@@ -207,6 +207,10 @@ module Orgmode
return true
end
+ # Test if we're in an output mode in which whitespace is significant.
+ def preserve_whitespace?
+ super or current_mode == :html
+ end
######################################################################
private
diff --git a/lib/org-ruby/output_buffer.rb b/lib/org-ruby/output_buffer.rb
index 1115614..069437f 100644
--- a/lib/org-ruby/output_buffer.rb
+++ b/lib/org-ruby/output_buffer.rb
@@ -73,11 +73,16 @@ module Orgmode
@buffer << "\n" << line.output_text if line.raw_text_tag == @buffer_tag
when preserve_whitespace?
@buffer << "\n" << line.output_text unless line.block_type
+ when line.assigned_paragraph_type == :code
+ # If the line is contained within a code block but we should
+ # not preserve whitespaces, then we do nothing.
when (line.kind_of? Headline)
add_line_attributes line
- @buffer << "\n" << line.output_text
+ @buffer << "\n" << line.output_text.strip
when ([:definition_term, :list_item, :table_row, :table_header,
- :horizontal_rule, :paragraph].include? line.paragraph_type)
+ :horizontal_rule].include? line.paragraph_type)
+ @buffer << "\n" << line.output_text.strip
+ when line.paragraph_type == :paragraph
@buffer << "\n"
buffer_indentation
@buffer << line.output_text.strip
@@ -119,7 +124,7 @@ module Orgmode
# Test if we're in an output mode in which whitespace is significant.
def preserve_whitespace?
- [:example, :html, :inline_example, :raw_text, :src].include? current_mode
+ [:example, :inline_example, :raw_text, :src].include? current_mode
end
######################################################################
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index ea24ad8..b8e4f27 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -116,10 +116,10 @@ module Orgmode
end
table_header_set = false if !line.table?
- when :example, :src, :html
- # As long as we stay in code mode, force lines to be paragraphs.
+ when :example, :html, :src
+ # As long as we stay in code mode, force lines to be code.
# Don't try to interpret structural items, like headings and tables.
- line.assigned_paragraph_type = :paragraph
+ line.assigned_paragraph_type = :code
end
if mode == :normal
--
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