[DRE-commits] [ruby-org] 91/303: added support to deactivate subscript and superscript (#+OPTIONS: ^:nil). Works only for HTML export.

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 dbd0ed2957b28f5e30855e4de3078218b0df4a11
Author: Rüdiger Sonderfeld <ruediger at c-plusplus.de>
Date:   Wed Jul 20 20:04:51 2011 +0200

    added support to deactivate subscript and superscript (#+OPTIONS: ^:nil). Works only for HTML export.
---
 lib/org-ruby/html_output_buffer.rb       |   12 +++++++-----
 lib/org-ruby/parser.rb                   |    9 ++++++++-
 spec/html_examples/subsupscript-nil.html |    3 +++
 spec/html_examples/subsupscript-nil.org  |    6 ++++++
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb
index 8c177c4..f8111dd 100644
--- a/lib/org-ruby/html_output_buffer.rb
+++ b/lib/org-ruby/html_output_buffer.rb
@@ -145,11 +145,13 @@ module Orgmode
       str = @re_help.rewrite_emphasis(str) do |marker, s|
         "#{Tags[marker][:open]}#{s}#{Tags[marker][:close]}"
       end
-      str = @re_help.rewrite_subp(str) do |type, text|
-        if type == "_" then
-          "<sub>#{text}</sub>"
-        elsif type == "^" then
-          "<sup>#{text}</sup>"
+      if @options[:use_sub_superscripts] then
+        str = @re_help.rewrite_subp(str) do |type, text|
+          if type == "_" then
+            "<sub>#{text}</sub>"
+          elsif type == "^" then
+            "<sup>#{text}</sup>"
+          end
         end
       end
       str = @re_help.rewrite_images(str) do |link|
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index 6d87a16..752a226 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -69,6 +69,12 @@ module Orgmode
       "nil" != @options["|"]
     end
 
+    # Should we export sub/superscripts? (_{foo}/^{foo})
+    # only {} mode is currently supported.
+    def use_sub_superscripts?
+      @options["^"] != "nil" 
+    end
+
     # I can construct a parser object either with an array of lines
     # or with a single string that I will split along \n boundaries.
     def initialize(lines)
@@ -163,7 +169,8 @@ module Orgmode
       export_options = {
         :decorate_title => true,
         :export_heading_number => export_heading_number?,
-        :export_todo => export_todo?
+        :export_todo => export_todo?,
+        :use_sub_superscripts =>  use_sub_superscripts?
       }
       export_options[:skip_tables] = true if not export_tables?
       output = ""
diff --git a/spec/html_examples/subsupscript-nil.html b/spec/html_examples/subsupscript-nil.html
new file mode 100644
index 0000000..3bda423
--- /dev/null
+++ b/spec/html_examples/subsupscript-nil.html
@@ -0,0 +1,3 @@
+<p class="title">SUBSUPSCRIPT</p>
+<p>a^{b}</p>
+<p>a_{b}</p>
diff --git a/spec/html_examples/subsupscript-nil.org b/spec/html_examples/subsupscript-nil.org
new file mode 100644
index 0000000..77f6873
--- /dev/null
+++ b/spec/html_examples/subsupscript-nil.org
@@ -0,0 +1,6 @@
+#+OPTIONS: ^:nil
+SUBSUPSCRIPT
+
+a^{b}
+
+a_{b}

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