[DRE-commits] [ruby-org] 89/303: added support for block comments (#+BEGIN_COMMENT/#+END_COMMENT)

Jérémy Bobbio lunar at alioth.debian.org
Fri Aug 9 17:33:33 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 e7b058c39b54952da1e6383027b58610c760083e
Author: Rüdiger Sonderfeld <ruediger at c-plusplus.de>
Date:   Wed Jul 20 19:13:48 2011 +0200

    added support for block comments (#+BEGIN_COMMENT/#+END_COMMENT)
---
 lib/org-ruby/line.rb                 |    4 +++-
 lib/org-ruby/parser.rb               |    9 +++++++++
 spec/html_examples/blockcomment.html |    3 +++
 spec/html_examples/blockcomment.org  |   15 +++++++++++++++
 4 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/lib/org-ruby/line.rb b/lib/org-ruby/line.rb
index 5f64ec6..2076f0e 100644
--- a/lib/org-ruby/line.rb
+++ b/lib/org-ruby/line.rb
@@ -36,7 +36,9 @@ module Orgmode
 
     # Tests if a line is a comment.
     def comment?
-      check_assignment_or_regexp(:comment, /^#/) and not begin_block? and not end_block?
+      return @assigned_paragraph_type == :comment if @assigned_paragraph_type
+      return block_type.casecmp("COMMENT") if begin_block? or end_block?
+      return @line =~ /^#/
     end
 
     # Tests if a line contains metadata instead of actual content.
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index ee4b038..6d87a16 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -105,6 +105,7 @@ module Orgmode
               previous_line.assigned_paragraph_type = :table_header if previous_line and previous_line.paragraph_type == :table_row
             end
             mode = :code if line.begin_block? and line.block_type == "EXAMPLE"
+            mode = :block_comment if line.begin_block? and line.block_type == "COMMENT"
             if (@current_headline) then
               @current_headline.body_lines << line
             else
@@ -112,6 +113,14 @@ module Orgmode
             end
           end
 
+        when :block_comment
+          line = Line.new line, self
+          if line.end_block? and line.block_type == "COMMENT"
+            mode = :normal
+          else
+            line.assigned_paragraph_type = :comment
+          end
+
         when :code
 
           # As long as we stay in code mode, force lines to be either blank or paragraphs.
diff --git a/spec/html_examples/blockcomment.html b/spec/html_examples/blockcomment.html
new file mode 100644
index 0000000..a2688fc
--- /dev/null
+++ b/spec/html_examples/blockcomment.html
@@ -0,0 +1,3 @@
+<p class="title">BLOCKCOMMENT</p>
+<p>Testing that the next part is ignored</p>
+<p>And now back to normal!</p>
diff --git a/spec/html_examples/blockcomment.org b/spec/html_examples/blockcomment.org
new file mode 100644
index 0000000..2e0ca72
--- /dev/null
+++ b/spec/html_examples/blockcomment.org
@@ -0,0 +1,15 @@
+BLOCKCOMMENT
+
+Testing that the next part is ignored
+
+#+BEGIN_COMMENT
+
+/Foo/
+
+#+BEGIN_SRC c++
+int main() { }
+#+END_SRC
+
+#+END_COMMENT
+
+And now back to 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