[DRE-commits] [ruby-org] 134/303: added 5 hyphens (horizontal rule) to line.rb and html output - missing textile output functionality

Jérémy Bobbio lunar at alioth.debian.org
Fri Aug 9 17:33:43 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 e6a14748d7e40ebeca5beb2b8798ae29bbb23415
Author: Neil Smithline <github.com at neilsmithline.com>
Date:   Thu Mar 29 15:19:13 2012 -0400

    added 5 hyphens (horizontal rule) to line.rb and html output - missing textile output functionality
---
 lib/org-ruby/html_output_buffer.rb      |    5 +++--
 lib/org-ruby/line.rb                    |    7 +++++++
 spec/html_examples/horizontal_rule.html |    3 +++
 spec/html_examples/horizontal_rule.org  |    3 +++
 spec/line_spec.rb                       |   10 ++++++++++
 5 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb
index 2d5a3bb..3252dc1 100644
--- a/lib/org-ruby/html_output_buffer.rb
+++ b/lib/org-ruby/html_output_buffer.rb
@@ -93,7 +93,9 @@ module Orgmode
         @logger.debug "FLUSH CODE ==========> #{@buffer.inspect}"
         @output << @buffer << "\n"
       else
-        if @buffer.length > 0 and @output_type == :definition_list then
+        if @buffer.length > 0 and @output_type == :horizontal_rule then
+          @output << "<hr />\n"
+        elsif @buffer.length > 0 and @output_type == :definition_list then
           unless buffer_mode_is_table? and skip_tables?
             output_indentation
             d = @buffer.split("::", 2)
@@ -169,7 +171,6 @@ module Orgmode
       @buffer.gsub!(/&/, "&")
       @buffer.gsub!(/</, "<")
       @buffer.gsub!(/>/, ">")
-      @buffer.gsub!(/^ *-{5,} *$/, "<hr/>")
     end
 
     def output_indentation
diff --git a/lib/org-ruby/line.rb b/lib/org-ruby/line.rb
index 05cb046..db6f233 100644
--- a/lib/org-ruby/line.rb
+++ b/lib/org-ruby/line.rb
@@ -94,6 +94,12 @@ module Orgmode
       check_assignment_or_regexp(:definition_list, DefinitionListRegexp)
     end
 
+    HorizontalRuleRegexp = /^\s*-{5,}\s*$/
+
+    def horizontal_rule?
+      check_assignment_or_regexp(:horizontal_rule, HorizontalRuleRegexp)
+    end
+
     OrderedListRegexp = /^\s*\d+(\.|\))\s+/
 
     def ordered_list?
@@ -208,6 +214,7 @@ module Orgmode
       return :table_row if table_row?
       return :table_header if table_header?
       return :inline_example if inline_example?
+      return :horizontal_rule if horizontal_rule?
       return :paragraph
     end
 
diff --git a/spec/html_examples/horizontal_rule.html b/spec/html_examples/horizontal_rule.html
new file mode 100644
index 0000000..755fce1
--- /dev/null
+++ b/spec/html_examples/horizontal_rule.html
@@ -0,0 +1,3 @@
+<p class="title">Test that 5 hyphens</p>
+<hr />
+<p>produce a horizontal rule.</p>
diff --git a/spec/html_examples/horizontal_rule.org b/spec/html_examples/horizontal_rule.org
new file mode 100644
index 0000000..e5af6df
--- /dev/null
+++ b/spec/html_examples/horizontal_rule.org
@@ -0,0 +1,3 @@
+Test that 5 hyphens
+-----
+produce a horizontal rule.
diff --git a/spec/line_spec.rb b/spec/line_spec.rb
index 99c7113..78d51fd 100644
--- a/spec/line_spec.rb
+++ b/spec/line_spec.rb
@@ -50,6 +50,16 @@ describe Orgmode::Line do
     end
   end
 
+  it "should recognize horizontal rules" do
+    Orgmode::Line.new("-----").horizontal_rule?.should be_true
+    # More than 5 hyphens are allowed.
+    Orgmode::Line.new("----------").horizontal_rule?.should be_true
+    # Whitespace before and after is also allowed.
+    Orgmode::Line.new("   \t ----- \t\t\t").horizontal_rule?.should be_true
+    # But only four hyphens should not match.
+    Orgmode::Line.new("----").horizontal_rule?.should_not be_true
+  end
+
   it "should recognize table rows" do
     Orgmode::Line.new("| One   | Two   | Three |").table_row?.should be_true
     Orgmode::Line.new("  |-------+-------+-------|\n").table_separator?.should be_true

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