aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/ri/ri_formatter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rdoc/ri/ri_formatter.rb')
-rw-r--r--lib/rdoc/ri/ri_formatter.rb30
1 files changed, 22 insertions, 8 deletions
diff --git a/lib/rdoc/ri/ri_formatter.rb b/lib/rdoc/ri/ri_formatter.rb
index 1e70529bfe..b3024d4c6c 100644
--- a/lib/rdoc/ri/ri_formatter.rb
+++ b/lib/rdoc/ri/ri_formatter.rb
@@ -1,11 +1,16 @@
module RI
- class RiFormatter
+ class TextFormatter
+
+ def TextFormatter.create(options, indent)
+ new(options, indent)
+ end
attr_reader :indent
- def initialize(width, indent)
- @width = width
- @indent = indent
+ def initialize(options, indent)
+ @options = options
+ @width = options.width
+ @indent = indent
end
@@ -23,7 +28,7 @@ module RI
def wrap(txt, prefix=@indent, linelen=@width)
return unless txt && !txt.empty?
- work = txt.dup
+ work = conv_markup(txt)
textLen = linelen - prefix.length
patt = Regexp.new("^(.{0,#{textLen}})[ \n]")
next_prefix = prefix.tr("^ ", " ")
@@ -53,9 +58,6 @@ module RI
# convert HTML entities back to ASCII
def conv_html(txt)
txt.
- gsub(%r{<tt>(.*?)</tt>}) { "+#$1+" } .
- gsub(%r{<b>(.*?)</b>}) { "*#$1*" } .
- gsub(%r{<em>(.*?)</em>}) { "_#$1_" } .
gsub(/&gt;/, '>').
gsub(/&lt;/, '<').
gsub(/&quot;/, '"').
@@ -63,6 +65,15 @@ module RI
end
+ # convert markup into display form
+ def conv_markup(txt)
+ txt.
+ gsub(%r{<tt>(.*?)</tt>}) { "+#$1+" } .
+ gsub(%r{<code>(.*?)</code>}) { "+#$1+" } .
+ gsub(%r{<b>(.*?)</b>}) { "*#$1*" } .
+ gsub(%r{<em>(.*?)</em>}) { "_#$1_" }
+ end
+
######################################################################
def display_list(list)
@@ -167,4 +178,7 @@ module RI
end
end
end
+
end
+
+