[DRE-commits] [ruby-org] 47/303: Added very simple title decoration: The first paragraph or heading that gets output will have 'class="title"' appended to the output tag. If the file starts with a table or a list, there will be no title output for that file.

Jérémy Bobbio lunar at alioth.debian.org
Fri Aug 9 17:33:24 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 8a39e4c9d509164d29b426052a1c92d96715bab4
Author: Brian Dewey <bdewey at gmail.com>
Date:   Mon Dec 28 12:57:22 2009 -0800

    Added very simple title decoration: The first paragraph or heading that gets output
    will have 'class="title"' appended to the output tag. If the file starts with a table
    or a list, there will be no title output for that file.
---
 History.txt                               |    1 +
 Rakefile                                  |    1 +
 lib/org-ruby.rb                           |    2 +-
 lib/org-ruby/headline.rb                  |    9 +++++++--
 lib/org-ruby/html_output_buffer.rb        |   14 +++++++++++++-
 lib/org-ruby/line.rb                      |    4 ++--
 lib/org-ruby/parser.rb                    |    7 +++++--
 spec/html_examples/advanced-lists.html    |    2 +-
 spec/html_examples/block_code.html        |    2 +-
 spec/html_examples/blockquote.html        |    2 +-
 spec/html_examples/inline-formatting.html |    2 +-
 spec/html_examples/lists.html             |    2 +-
 spec/html_examples/tables.html            |    2 +-
 spec/html_examples/text.html              |    2 +-
 14 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/History.txt b/History.txt
index 02493ce..6fb6aa1 100644
--- a/History.txt
+++ b/History.txt
@@ -1,5 +1,6 @@
 == 0.4.0 / 2009-12-28
 
+* The first thing output in HTML gets the class "title"
 * HTML output is now indented
 * Proper support for multi-paragraph list items.
 * Fixed bugs:
diff --git a/Rakefile b/Rakefile
index 244756d..7a86087 100644
--- a/Rakefile
+++ b/Rakefile
@@ -20,6 +20,7 @@ Bones {
   colorize false                # Windows consoles won't colorize
   gem.need_tar false            # Can't TAR from Windows
   depend_on 'rubypants'
+  spec.opts ['-D', '--color']
 }
 
 
diff --git a/lib/org-ruby.rb b/lib/org-ruby.rb
index 0a81793..139a7cf 100644
--- a/lib/org-ruby.rb
+++ b/lib/org-ruby.rb
@@ -3,7 +3,7 @@ unless defined? ::OrgRuby
 module OrgRuby
 
   # :stopdoc:
-  VERSION = '0.3.0'
+  VERSION = '0.4.0'
   LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
   PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
   # :startdoc:
diff --git a/lib/org-ruby/headline.rb b/lib/org-ruby/headline.rb
index 6cf3603..dd33c76 100644
--- a/lib/org-ruby/headline.rb
+++ b/lib/org-ruby/headline.rb
@@ -66,8 +66,13 @@ module Orgmode
       output
     end
 
-    def to_html
-      output = "<h#{@level}>#{@headline_text}</h#{@level}>\n"
+    def to_html(opts = {})
+      if opts[:decorate_title]
+        decoration = " class=\"title\""
+      else
+        decoration = ""
+      end
+      output = "<h#{@level}#{decoration}>#{@headline_text}</h#{@level}>\n"
       output << Line.to_html(@body_lines)
       output
     end
diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb
index 08e4682..d1baf18 100644
--- a/lib/org-ruby/html_output_buffer.rb
+++ b/lib/org-ruby/html_output_buffer.rb
@@ -20,10 +20,21 @@ module Orgmode
       :code => "pre"
     }
 
+    def initialize(output, opts = {})
+      super(output)
+      if opts[:decorate_title] then
+        @title_decoration = " class=\"title\""
+      else
+        @title_decoration = ""
+      end
+    end
+
     def push_mode(mode)
       if ModeTag[mode] then
         output_indentation
         @output << "<#{ModeTag[mode]}>\n" 
+        # Entering a new mode obliterates the title decoration
+        @title_decoration = ""
       end
       super(mode)
     end
@@ -45,9 +56,10 @@ module Orgmode
       else
         if (@buffer.length > 0) then
           output_indentation
-          @output << "<#{HtmlBlockTag[@output_type]}>" \
+          @output << "<#{HtmlBlockTag[@output_type]}#{@title_decoration}>" \
             << inline_formatting(@buffer) \
             << "</#{HtmlBlockTag[@output_type]}>\n"
+          @title_decoration = ""
         end
       end
       @buffer = ""
diff --git a/lib/org-ruby/line.rb b/lib/org-ruby/line.rb
index bd7abc8..a96b4e8 100644
--- a/lib/org-ruby/line.rb
+++ b/lib/org-ruby/line.rb
@@ -118,9 +118,9 @@ module Orgmode
       translate(lines, output_buffer)
     end
 
-    def self.to_html(lines)
+    def self.to_html(lines, opts = { })
       output = ""
-      output_buffer = HtmlOutputBuffer.new(output)
+      output_buffer = HtmlOutputBuffer.new(output, opts)
       translate(lines, output_buffer)
     end
 
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index d43faec..d8df6e8 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -66,9 +66,12 @@ module Orgmode
     # Converts the loaded org-mode file to HTML.
     def to_html
       output = ""
-      output << Line.to_html(@header_lines)
+      decorate = true
+      output << Line.to_html(@header_lines, :decorate_title => decorate)
+      decorate = (output.length == 0)
       @headlines.each do |headline|
-        output << headline.to_html
+        output << headline.to_html(:decorate_title => decorate)
+        decorate = (output.length == 0)
       end
       rp = RubyPants.new(output)
       rp.to_html
diff --git a/spec/html_examples/advanced-lists.html b/spec/html_examples/advanced-lists.html
index 1e1d67e..8696320 100644
--- a/spec/html_examples/advanced-lists.html
+++ b/spec/html_examples/advanced-lists.html
@@ -1,4 +1,4 @@
-<p>Advanced Lists</p>
+<p class="title">Advanced Lists</p>
 <p><code>org-ruby</code> supports the following list features of <code>org-mode</code>:</p>
 <h1>Nested lists</h1>
 <ul>
diff --git a/spec/html_examples/block_code.html b/spec/html_examples/block_code.html
index 637b93d..0f96479 100644
--- a/spec/html_examples/block_code.html
+++ b/spec/html_examples/block_code.html
@@ -1,4 +1,4 @@
-<h1>Block Code</h1>
+<h1 class="title">Block Code</h1>
 <p>I need to get block code examples working. In <code>orgmode</code>, they look like this:</p>
 <pre>
 
diff --git a/spec/html_examples/blockquote.html b/spec/html_examples/blockquote.html
index ac559ef..ccdac05 100644
--- a/spec/html_examples/blockquote.html
+++ b/spec/html_examples/blockquote.html
@@ -1,4 +1,4 @@
-<p>BLOCKQUOTE</p>
+<p class="title">BLOCKQUOTE</p>
 <p>Testing that I can have block quotes:</p>
 <blockquote>
   <p><i>Example:</i></p>
diff --git a/spec/html_examples/inline-formatting.html b/spec/html_examples/inline-formatting.html
index c79cd1b..a299a87 100644
--- a/spec/html_examples/inline-formatting.html
+++ b/spec/html_examples/inline-formatting.html
@@ -1,4 +1,4 @@
-<p>Inline Formatting</p>
+<p class="title">Inline Formatting</p>
 <p>I want to make sure I handle all inline formatting. I need to handle <b>bold</b>, <i>italic</i>, <code>code</code>, <code>verbatim</code>, <span style="text-decoration:underline;">underline</span>, <del>strikethrough</del>.</p>
 <p>In addition, I need to make sure I can handle links. We’ve got simple links, like this:</p>
 <ul>
diff --git a/spec/html_examples/lists.html b/spec/html_examples/lists.html
index 30c692c..0410a7c 100644
--- a/spec/html_examples/lists.html
+++ b/spec/html_examples/lists.html
@@ -1,4 +1,4 @@
-<h1>Lists</h1>
+<h1 class="title">Lists</h1>
 <p>I want to make sure I have great support for lists.</p>
 <ul>
   <li>This is an unordered list</li>
diff --git a/spec/html_examples/tables.html b/spec/html_examples/tables.html
index 810ac55..d3f3c51 100644
--- a/spec/html_examples/tables.html
+++ b/spec/html_examples/tables.html
@@ -1,4 +1,4 @@
-<p>TABLES</p>
+<p class="title">TABLES</p>
 <p>Different types of ORG tables.</p>
 <h1>Simple table, no header.</h1>
 <table>
diff --git a/spec/html_examples/text.html b/spec/html_examples/text.html
index d05b2dd..08d0069 100644
--- a/spec/html_examples/text.html
+++ b/spec/html_examples/text.html
@@ -1,2 +1,2 @@
-<p>The simplest case: translating plain text.</p>
+<p class="title">The simplest case: translating plain text.</p>
 <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo d [...]

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