about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/oldweb.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/oldweb.rb b/lib/oldweb.rb
index a5da1cc..95b7171 100644
--- a/lib/oldweb.rb
+++ b/lib/oldweb.rb
@@ -31,6 +31,8 @@ class Oldweb
     RDoc::Text::TO_HTML_CHARACTERS[Encoding::UTF_8] =
       RDoc::Text::TO_HTML_CHARACTERS[Encoding::ASCII]
 
+    less_html!
+
     @store = store
     @options = options
     @base_dir = Pathname.pwd.expand_path
@@ -298,12 +300,13 @@ class Oldweb
       @res << "</h#{level}>"
     end
   end
-end
 
-# :stopdoc:
-class RDoc::Markup::ToHtml # :nodoc:
-  remove_method :accept_heading
-  remove_method :accept_verbatim
-  include Oldweb::LessHtml
+  def less_html! # :nodoc:
+    klass = RDoc::Markup::ToHtml
+    return if klass.include?(Oldweb::LessHtml)
+    klass.__send__(:remove_method, :accept_heading)
+    klass.__send__(:remove_method, :accept_verbatim)
+    klass.__send__(:include, Oldweb::LessHtml)
+  end
 end
 # :startdoc: