[DRE-commits] [ruby-org] 67/303: Supports option skip:t

Jérémy Bobbio lunar at alioth.debian.org
Fri Aug 9 17:33:29 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 c30a17ed0ce1e57a4114b4c95633d79b556a5fe9
Author: Brian Dewey <bdewey at gmail.com>
Date:   Tue Dec 29 21:08:04 2009 -0800

    Supports option skip:t
---
 History.txt                         |   10 ++++++----
 lib/org-ruby/headline.rb            |    3 ++-
 lib/org-ruby/parser.rb              |    7 ++++++-
 spec/html_examples/skip-header.html |    3 +++
 spec/html_examples/skip-header.org  |   28 ++++++++++++++++++++++++++++
 5 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/History.txt b/History.txt
index 87a379d..dccf2c6 100644
--- a/History.txt
+++ b/History.txt
@@ -1,11 +1,13 @@
 == 0.5.0 / 2009-12-29
 
-* Parse (but not necessarily *use*) in-buffer settings.
-* Understand the #+TITLE: directive.
+* Parse (but not necessarily *use*) in-buffer settings. The following
+  in-buffer settings *are* used:
+  * Understand the #+TITLE: directive.
+  * Exporting todo keywords (option todo:t)
+  * Numbering headlines (option num:t)
+  * Skipping text before the first headline (option skip:t)
 * Rewrite "file:(blah).org" links to "http:(blah).html" links. This
   makes the inter-links to other org-mode files work.
-* Supports the in-buffer setting for exporting todo keywords.
-* Supports the in-buffer setting for numbering headlines.
 * Uses <th> tags inside table rows that precede table separators.
 
 == 0.4.2 / 2009-12-29
diff --git a/lib/org-ruby/headline.rb b/lib/org-ruby/headline.rb
index 7f08d61..43ea64d 100644
--- a/lib/org-ruby/headline.rb
+++ b/lib/org-ruby/headline.rb
@@ -44,6 +44,7 @@ module Orgmode
           @tags.delete_at(0)                 # the first item will be empty; discard
           @headline_text.gsub!(TagsRegexp, "") # Removes the tags from the headline
         end
+        @keyword = nil
         if (@headline_text =~ KeywordsRegexp) then
           @headline_text = $'
           @keyword = $1
@@ -77,7 +78,7 @@ module Orgmode
         heading_number = @parser.get_next_headline_number(@level)
         output << "<span class=\"heading-number heading-number-#{@level}\">#{heading_number} </span>"
       end
-      if @parser and @parser.export_todo? then
+      if @parser and @parser.export_todo? and @keyword then
         output << "<span class=\"todo-keyword #{@keyword}\">#{@keyword} </span>"
       end
       output << "#{@headline_text}</h#{@level}>\n"
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index 54a69f2..02f7a47 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -38,6 +38,11 @@ module Orgmode
       "t" == @options["num"]
     end
 
+    # Should we skip exporting text before the first heading?
+    def skip_header_lines?
+      "t" == @options["skip"]
+    end
+
     # Gets the next headline number for a given level. The intent is
     # this function is called sequentially for each headline that
     # needs to get numbered. It does standard outline numbering.
@@ -143,7 +148,7 @@ module Orgmode
       else
         decorate = true
       end
-      output << Line.to_html(@header_lines, :decorate_title => decorate)
+      output << Line.to_html(@header_lines, :decorate_title => decorate) unless skip_header_lines?
       decorate = (output.length == 0)
       @headlines.each do |headline|
         output << headline.to_html(:decorate_title => decorate)
diff --git a/spec/html_examples/skip-header.html b/spec/html_examples/skip-header.html
new file mode 100644
index 0000000..e4e1859
--- /dev/null
+++ b/spec/html_examples/skip-header.html
@@ -0,0 +1,3 @@
+<p class="title">skip-header.org</p>
+<h1><span class="heading-number heading-number-1">1 </span>First heading</h1>
+<p>This should be the first text in the output.</p>
diff --git a/spec/html_examples/skip-header.org b/spec/html_examples/skip-header.org
new file mode 100644
index 0000000..9682a93
--- /dev/null
+++ b/spec/html_examples/skip-header.org
@@ -0,0 +1,28 @@
+#+TITLE:     skip-header.org
+#+AUTHOR:    
+#+EMAIL:     brian at BRIAN-DESK
+#+DATE:      2009-12-29 Tue
+#+DESCRIPTION: 
+#+KEYWORDS: 
+#+LANGUAGE:  en
+#+OPTIONS:   H:3 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS:   TeX:t LaTeX:nil skip:t d:nil todo:t pri:nil tags:not-in-toc
+#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
+#+EXPORT_SELECT_TAGS: export
+#+EXPORT_EXCLUDE_TAGS: noexport
+#+LINK_UP:   
+#+LINK_HOME: 
+This is header text.
+It exists in the org-file, but shouldn't show up in the HTML output.
+
+- Same with this list
+- Nope, shouldn't be in the output.
+
+#+BEGIN_EXAMPLE
+Even this code snippet shouldn't be there.
+Like a ninja. You can't see me.
+#+END_EXAMPLE
+
+* First heading
+
+  This should be the first text in 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