[DRE-commits] [ruby-org] 121/303: Headlines marked with the COMMENT keyword are not exported as specified in the comment lines section from the org-mode documentation. <http://orgmode.org/org.html#Comment-lines>

Jérémy Bobbio lunar at alioth.debian.org
Fri Aug 9 17:33:40 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 8653d4375cebfac78feb79b2c4f1ef02b8a7136c
Author: Waldemar Quevedo <waldemar.quevedo at gmail.com>
Date:   Sun Nov 20 02:44:16 2011 +0900

    Headlines marked with the COMMENT keyword are not exported
    as specified in the comment lines section from the org-mode documentation.
    <http://orgmode.org/org.html#Comment-lines>
---
 lib/org-ruby/headline.rb              |    8 ++++++++
 lib/org-ruby/parser.rb                |    4 ++++
 spec/headline_spec.rb                 |    5 +++++
 spec/html_examples/comment-trees.html |    4 ++++
 spec/html_examples/comment-trees.org  |   13 +++++++++++++
 5 files changed, 34 insertions(+)

diff --git a/lib/org-ruby/headline.rb b/lib/org-ruby/headline.rb
index b3f609b..33481bb 100644
--- a/lib/org-ruby/headline.rb
+++ b/lib/org-ruby/headline.rb
@@ -41,6 +41,9 @@ module Orgmode
 
     KeywordsRegexp = Regexp.new("^(#{Keywords.join('|')})\$")
 
+    # This matches a headline marked as COMMENT
+    CommentHeadlineRegexp = /^COMMENT\s+/
+
     def initialize(line, parser = nil, offset=0)
       super(line, parser)
       @body_lines = []
@@ -74,6 +77,11 @@ module Orgmode
       line =~ LineRegexp
     end
 
+    # Determines if a headline has the COMMENT keyword.
+    def comment_headline?
+      @headline_text =~ CommentHeadlineRegexp
+    end
+
     # Overrides Line.paragraph_type.
     def paragraph_type
       :"heading#{@level}"
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index 7c5a02b..06a1870 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -329,6 +329,10 @@ module Orgmode
               inherit_export_level = headline.level
             end
           end
+          if headline.comment_headline?
+            headline.export_state = :exclude
+            inherit_export_level = headline.level
+          end
         end
       end
     end
diff --git a/spec/headline_spec.rb b/spec/headline_spec.rb
index bc0193b..7b7103b 100644
--- a/spec/headline_spec.rb
+++ b/spec/headline_spec.rb
@@ -56,5 +56,10 @@ describe Orgmode::Headline do
     h.headline_text.should eql("Feed cat")
     h.keyword.should eql("TODO")
   end
+
+  it "should recognize headlines marked as COMMENT" do
+    h = Orgmode::Headline.new "* COMMENT This headline is a comment"
+    h.comment_headline?.should_not be_nil
+  end
 end
 
diff --git a/spec/html_examples/comment-trees.html b/spec/html_examples/comment-trees.html
new file mode 100644
index 0000000..bfc6490
--- /dev/null
+++ b/spec/html_examples/comment-trees.html
@@ -0,0 +1,4 @@
+<h1 class="title">This headline is in the output</h1>
+<h1>This is in the output</h1>
+<h2>Yet, this is in the output</h2>
+<p>and this is also part of the output</p>
diff --git a/spec/html_examples/comment-trees.org b/spec/html_examples/comment-trees.org
new file mode 100644
index 0000000..e3e0d39
--- /dev/null
+++ b/spec/html_examples/comment-trees.org
@@ -0,0 +1,13 @@
+* This headline is in the output
+* COMMENT Commented headline should not be in the output
+This should not be in the output either.
+** This should not be in the output.
+*** Neither this 
+**** nor this
+** Not in the output
+* This is in the output
+** COMMENT But this is not
+This is not in the output
+*** Neither is this
+** Yet, this is in the output
+and this is also part of the output

-- 
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