From 1b43644edc85a93bfc9228588c065c87f975cd93 Mon Sep 17 00:00:00 2001 From: aycabta Date: Wed, 17 Oct 2018 06:28:20 +0000 Subject: Merge rdoc-6.1.0.beta2 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/markup/attribute_manager.rb | 44 ++++++++++++++++----------------- lib/rdoc/markup/attributes.rb | 12 ++++----- lib/rdoc/markup/formatter.rb | 47 ++++++++++++++++++------------------ lib/rdoc/markup/heading.rb | 6 ++--- lib/rdoc/markup/inline.rb | 2 -- lib/rdoc/markup/regexp_handling.rb | 41 +++++++++++++++++++++++++++++++ lib/rdoc/markup/special.rb | 41 ------------------------------- lib/rdoc/markup/to_bs.rb | 6 ++--- lib/rdoc/markup/to_html.rb | 38 ++++++++++++++--------------- lib/rdoc/markup/to_html_crossref.rb | 20 +++++++-------- lib/rdoc/markup/to_html_snippet.rb | 18 +++++++------- lib/rdoc/markup/to_label.rb | 18 +++++++------- lib/rdoc/markup/to_markdown.rb | 14 +++++------ lib/rdoc/markup/to_rdoc.rb | 10 ++++---- lib/rdoc/markup/to_tt_only.rb | 4 +-- 15 files changed, 159 insertions(+), 162 deletions(-) delete mode 100644 lib/rdoc/markup/inline.rb create mode 100644 lib/rdoc/markup/regexp_handling.rb delete mode 100644 lib/rdoc/markup/special.rb (limited to 'lib/rdoc/markup') diff --git a/lib/rdoc/markup/attribute_manager.rb b/lib/rdoc/markup/attribute_manager.rb index a10f731615..f052bc8b01 100644 --- a/lib/rdoc/markup/attribute_manager.rb +++ b/lib/rdoc/markup/attribute_manager.rb @@ -53,10 +53,10 @@ class RDoc::Markup::AttributeManager attr_reader :protectable ## - # And this maps _special_ sequences to a name. A special sequence is - # something like a WikiWord + # And this maps _regexp handling_ sequences to a name. A regexp handling + # sequence is something like a WikiWord - attr_reader :special + attr_reader :regexp_handlings ## # Creates a new attribute manager that understands bold, emphasized and @@ -66,7 +66,7 @@ class RDoc::Markup::AttributeManager @html_tags = {} @matching_word_pairs = {} @protectable = %w[<] - @special = [] + @regexp_handlings = [] @word_pair_map = {} @attributes = RDoc::Markup::Attributes.new @@ -166,22 +166,22 @@ class RDoc::Markup::AttributeManager end ## - # Converts special sequences to RDoc attributes + # Converts regexp handling sequences to RDoc attributes - def convert_specials str, attrs - @special.each do |regexp, attribute| + def convert_regexp_handlings str, attrs + @regexp_handlings.each do |regexp, attribute| str.scan(regexp) do capture = $~.size == 1 ? 0 : 1 s, e = $~.offset capture - attrs.set_attrs s, e - s, attribute | @attributes.special + attrs.set_attrs s, e - s, attribute | @attributes.regexp_handling end end end ## - # Escapes special sequences of text to prevent conversion to RDoc + # Escapes regexp handling sequences of text to prevent conversion to RDoc def mask_protected_sequences # protect __send__, __FILE__, etc. @@ -193,7 +193,7 @@ class RDoc::Markup::AttributeManager end ## - # Unescapes special sequences of text + # Unescapes regexp handling sequences of text def unmask_protected_sequences @str.gsub!(/(.)#{PROTECT_ATTR}/, "\\1\000") @@ -233,17 +233,17 @@ class RDoc::Markup::AttributeManager end ## - # Adds a special handler for +pattern+ with +name+. A simple URL handler + # Adds a regexp handling for +pattern+ with +name+. A simple URL handler # would be: # - # @am.add_special(/((https?:)\S+\w)/, :HYPERLINK) + # @am.add_regexp_handling(/((https?:)\S+\w)/, :HYPERLINK) - def add_special pattern, name - @special << [pattern, @attributes.bitmap_for(name)] + def add_regexp_handling pattern, name + @regexp_handlings << [pattern, @attributes.bitmap_for(name)] end ## - # Processes +str+ converting attributes, HTML and specials + # Processes +str+ converting attributes, HTML and regexp handlings def flow str @str = str.dup @@ -252,9 +252,9 @@ class RDoc::Markup::AttributeManager @attrs = RDoc::Markup::AttrSpan.new @str.length - convert_attrs @str, @attrs - convert_html @str, @attrs - convert_specials @str, @attrs + convert_attrs @str, @attrs + convert_html @str, @attrs + convert_regexp_handlings @str, @attrs unmask_protected_sequences @@ -312,12 +312,12 @@ class RDoc::Markup::AttributeManager res << change_attribute(current_attr, new_attr) current_attr = new_attr - if (current_attr & @attributes.special) != 0 then + if (current_attr & @attributes.regexp_handling) != 0 then i += 1 while - i < str_len and (@attrs[i] & @attributes.special) != 0 + i < str_len and (@attrs[i] & @attributes.regexp_handling) != 0 - res << RDoc::Markup::Special.new(current_attr, - copy_string(start_pos, i)) + res << RDoc::Markup::RegexpHandling.new(current_attr, + copy_string(start_pos, i)) start_pos = i next end diff --git a/lib/rdoc/markup/attributes.rb b/lib/rdoc/markup/attributes.rb index ec30160d3d..ce014ce928 100644 --- a/lib/rdoc/markup/attributes.rb +++ b/lib/rdoc/markup/attributes.rb @@ -6,21 +6,21 @@ class RDoc::Markup::Attributes ## - # The special attribute type. See RDoc::Markup#add_special + # The regexp handling attribute type. See RDoc::Markup#add_regexp_handling - attr_reader :special + attr_reader :regexp_handling ## # Creates a new attributes set. def initialize - @special = 1 + @regexp_handling = 1 @name_to_bitmap = [ - [:_SPECIAL_, @special], + [:_REGEXP_HANDLING_, @regexp_handling], ] - @next_bitmap = @special << 1 + @next_bitmap = @regexp_handling << 1 end ## @@ -61,7 +61,7 @@ class RDoc::Markup::Attributes return enum_for __method__, bitmap unless block_given? @name_to_bitmap.each do |name, bit| - next if bit == @special + next if bit == @regexp_handling yield name.to_s if (bitmap & bit) != 0 end diff --git a/lib/rdoc/markup/formatter.rb b/lib/rdoc/markup/formatter.rb index 5dc71d2242..6dff96c7d0 100644 --- a/lib/rdoc/markup/formatter.rb +++ b/lib/rdoc/markup/formatter.rb @@ -50,7 +50,7 @@ class RDoc::Markup::Formatter @markup = markup || RDoc::Markup.new @am = @markup.attribute_manager - @am.add_special(/
/, :HARD_BREAK) + @am.add_regexp_handling(/
/, :HARD_BREAK) @attributes = @am.attributes @@ -78,23 +78,24 @@ class RDoc::Markup::Formatter end ## - # Adds a special for links of the form rdoc-...: + # Adds a regexp handling for links of the form rdoc-...: - def add_special_RDOCLINK - @markup.add_special(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK) + def add_regexp_handling_RDOCLINK + @markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK) end ## - # Adds a special for links of the form {}[] and [] + # Adds a regexp handling for links of the form {}[] and + # [] - def add_special_TIDYLINK - @markup.add_special(/(?: - \{.*?\} | # multi-word label - \b[^\s{}]+? # single-word label - ) + def add_regexp_handling_TIDYLINK + @markup.add_regexp_handling(/(?: + \{.*?\} | # multi-word label + \b[^\s{}]+? # single-word label + ) - \[\S+?\] # link target - /x, :TIDYLINK) + \[\S+?\] # link target + /x, :TIDYLINK) end ## @@ -133,8 +134,8 @@ class RDoc::Markup::Formatter when RDoc::Markup::AttrChanger then off_tags res, item on_tags res, item - when RDoc::Markup::Special then - res << convert_special(item) + when RDoc::Markup::RegexpHandling then + res << convert_regexp_handling(item) else raise "Unknown flow element: #{item.inspect}" end @@ -144,29 +145,29 @@ class RDoc::Markup::Formatter end ## - # Converts added specials. See RDoc::Markup#add_special + # Converts added regexp handlings. See RDoc::Markup#add_regexp_handling - def convert_special special - return special.text if in_tt? + def convert_regexp_handling target + return target.text if in_tt? handled = false - @attributes.each_name_of special.type do |name| - method_name = "handle_special_#{name}" + @attributes.each_name_of target.type do |name| + method_name = "handle_regexp_#{name}" if respond_to? method_name then - special.text = send method_name, special + target.text = send method_name, target handled = true end end unless handled then - special_name = @attributes.as_string special.type + target_name = @attributes.as_string target.type - raise RDoc::Error, "Unhandled special #{special_name}: #{special}" + raise RDoc::Error, "Unhandled regexp handling #{target_name}: #{target}" end - special.text + target.text end ## diff --git a/lib/rdoc/markup/heading.rb b/lib/rdoc/markup/heading.rb index 233774c5c4..93a3a52000 100644 --- a/lib/rdoc/markup/heading.rb +++ b/lib/rdoc/markup/heading.rb @@ -23,12 +23,12 @@ RDoc::Markup::Heading = return @to_html if @to_html markup = RDoc::Markup.new - markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF + markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF @to_html = RDoc::Markup::ToHtml.new nil - def @to_html.handle_special_CROSSREF special - special.text.sub(/^\\/, '') + def @to_html.handle_regexp_CROSSREF target + target.text.sub(/^\\/, '') end @to_html diff --git a/lib/rdoc/markup/inline.rb b/lib/rdoc/markup/inline.rb deleted file mode 100644 index aba7ec21ce..0000000000 --- a/lib/rdoc/markup/inline.rb +++ /dev/null @@ -1,2 +0,0 @@ -# frozen_string_literal: true -warn "requiring rdoc/markup/inline is deprecated and will be removed in RDoc 4." if $-w diff --git a/lib/rdoc/markup/regexp_handling.rb b/lib/rdoc/markup/regexp_handling.rb new file mode 100644 index 0000000000..6ed868c2c1 --- /dev/null +++ b/lib/rdoc/markup/regexp_handling.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true +## +# Hold details of a regexp handling sequence + +class RDoc::Markup::RegexpHandling + + ## + # Regexp handling type + + attr_reader :type + + ## + # Regexp handling text + + attr_accessor :text + + ## + # Creates a new regexp handling sequence of +type+ with +text+ + + def initialize(type, text) + @type, @text = type, text + end + + ## + # Regexp handlings are equal when the have the same text and type + + def ==(o) + self.text == o.text && self.type == o.type + end + + def inspect # :nodoc: + "#" % [ + object_id, @type, text.dump] + end + + def to_s # :nodoc: + "RegexpHandling: type=#{type} text=#{text.dump}" + end + +end + diff --git a/lib/rdoc/markup/special.rb b/lib/rdoc/markup/special.rb deleted file mode 100644 index 57261b44a7..0000000000 --- a/lib/rdoc/markup/special.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true -## -# Hold details of a special sequence - -class RDoc::Markup::Special - - ## - # Special type - - attr_reader :type - - ## - # Special text - - attr_accessor :text - - ## - # Creates a new special sequence of +type+ with +text+ - - def initialize(type, text) - @type, @text = type, text - end - - ## - # Specials are equal when the have the same text and type - - def ==(o) - self.text == o.text && self.type == o.type - end - - def inspect # :nodoc: - "#" % [ - object_id, @type, text.dump] - end - - def to_s # :nodoc: - "Special: type=#{type} text=#{text.dump}" - end - -end - diff --git a/lib/rdoc/markup/to_bs.rb b/lib/rdoc/markup/to_bs.rb index fea017e89d..f9b86487db 100644 --- a/lib/rdoc/markup/to_bs.rb +++ b/lib/rdoc/markup/to_bs.rb @@ -41,7 +41,7 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc end ## - # Turns on or off special handling for +convert_string+ + # Turns on or off regexp handling for +convert_string+ def annotate tag case tag @@ -54,9 +54,9 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc end ## - # Calls convert_string on the result of convert_special + # Calls convert_string on the result of convert_regexp_handling - def convert_special special + def convert_regexp_handling target convert_string super end diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index 79b13e1819..9ae0fff8a7 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -53,18 +53,18 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter @hard_break = "
\n" # external links - @markup.add_special(/(?:link:|https?:|mailto:|ftp:|irc:|www\.)\S+\w/, - :HYPERLINK) + @markup.add_regexp_handling(/(?:link:|https?:|mailto:|ftp:|irc:|www\.)\S+\w/, + :HYPERLINK) - add_special_RDOCLINK - add_special_TIDYLINK + add_regexp_handling_RDOCLINK + add_regexp_handling_TIDYLINK init_tags end - # :section: Special Handling + # :section: Regexp Handling # - # These methods handle special markup added by RDoc::Markup#add_special. + # These methods are used by regexp handling markup added by RDoc::Markup#add_regexp_handling. def handle_RDOCLINK url # :nodoc: case url @@ -91,14 +91,14 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter end ## - # +special+ is a
+ # +target+ is a
- def handle_special_HARD_BREAK special + def handle_regexp_HARD_BREAK target '
' end ## - # +special+ is a potential link. The following schemes are handled: + # +target+ is a potential link. The following schemes are handled: # # mailto::: # Inserted as-is. @@ -109,14 +109,14 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter # link::: # Reference to a local file relative to the output directory. - def handle_special_HYPERLINK(special) - url = special.text + def handle_regexp_HYPERLINK(target) + url = target.text gen_url url, url end ## - # +special+ is an rdoc-schemed link that will be converted into a hyperlink. + # +target+ is an rdoc-schemed link that will be converted into a hyperlink. # # For the +rdoc-ref+ scheme the named reference will be returned without # creating a link. @@ -124,16 +124,16 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter # For the +rdoc-label+ scheme the footnote and label prefixes are stripped # when creating a link. All other contents will be linked verbatim. - def handle_special_RDOCLINK special - handle_RDOCLINK special.text + def handle_regexp_RDOCLINK target + handle_RDOCLINK target.text end ## - # This +special+ is a link where the label is different from the URL + # This +target+ is a link where the label is different from the URL # label[url] or {long label}[url] - def handle_special_TIDYLINK(special) - text = special.text + def handle_regexp_TIDYLINK(target) + text = target.text return text unless text =~ /^\{(.*)\}\[(.*?)\]$/ or text =~ /^(\S+)\[(.*?)\]$/ @@ -186,7 +186,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter @res << "\n

" text = paragraph.text @hard_break text = text.gsub(/\r?\n/, ' ') - @res << wrap(to_html(text)) + @res << to_html(text) @res << "

\n" end @@ -312,7 +312,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter ## # Generate a link to +url+ with content +text+. Handles the special cases - # for img: and link: described under handle_special_HYPERLINK + # for img: and link: described under handle_regexp_HYPERLINK def gen_url url, text scheme, url, id = parse_url url diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb index cc93021540..6020263799 100644 --- a/lib/rdoc/markup/to_html_crossref.rb +++ b/lib/rdoc/markup/to_html_crossref.rb @@ -40,7 +40,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml @show_hash = @options.show_hash crossref_re = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP - @markup.add_special crossref_re, :CROSSREF + @markup.add_regexp_handling crossref_re, :CROSSREF @cross_reference = RDoc::CrossReference.new @context end @@ -68,8 +68,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml # example, ToHtml is found, even without the RDoc::Markup:: prefix, # because we look for it in module Markup first. - def handle_special_CROSSREF(special) - name = special.text + def handle_regexp_CROSSREF(target) + name = target.text return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails @@ -87,22 +87,22 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml # Handles rdoc-ref: scheme links and allows RDoc::Markup::ToHtml to # handle other schemes. - def handle_special_HYPERLINK special - return cross_reference $' if special.text =~ /\Ardoc-ref:/ + def handle_regexp_HYPERLINK target + return cross_reference $' if target.text =~ /\Ardoc-ref:/ super end ## - # +special+ is an rdoc-schemed link that will be converted into a hyperlink. + # +target+ is an rdoc-schemed link that will be converted into a hyperlink. # For the rdoc-ref scheme the cross-reference will be looked up and the # given name will be used. # # All other contents are handled by - # {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_special_RDOCLINK] + # {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_regexp_RDOCLINK] - def handle_special_RDOCLINK special - url = special.text + def handle_regexp_RDOCLINK target + url = target.text case url when /\Ardoc-ref:/ then @@ -126,8 +126,6 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml # Creates an HTML link to +name+ with the given +text+. def link name, text - original_name = name - if name =~ /(.*[^#:])@/ then name = $1 label = $' diff --git a/lib/rdoc/markup/to_html_snippet.rb b/lib/rdoc/markup/to_html_snippet.rb index 24aa1d32d9..4eb36592b7 100644 --- a/lib/rdoc/markup/to_html_snippet.rb +++ b/lib/rdoc/markup/to_html_snippet.rb @@ -44,7 +44,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml @mask = 0 @paragraphs = 0 - @markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF + @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF end ## @@ -71,7 +71,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml text = paragraph.text @hard_break - @res << "#{para}#{wrap to_html text}\n" + @res << "#{para}#{to_html text}\n" add_paragraph end @@ -123,16 +123,16 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml end ## - # Removes escaping from the cross-references in +special+ + # Removes escaping from the cross-references in +target+ - def handle_special_CROSSREF special - special.text.sub(/\A\\/, '') + def handle_regexp_CROSSREF target + target.text.sub(/\A\\/, '') end ## - # +special+ is a
+ # +target+ is a
- def handle_special_HARD_BREAK special + def handle_regexp_HARD_BREAK target @characters -= 4 '
' end @@ -226,8 +226,8 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml when String then text = convert_string item res << truncate(text) - when RDoc::Markup::Special then - text = convert_special item + when RDoc::Markup::RegexpHandling then + text = convert_regexp_handling item res << truncate(text) else raise "Unknown flow element: #{item.inspect}" diff --git a/lib/rdoc/markup/to_label.rb b/lib/rdoc/markup/to_label.rb index 9f179013f2..3d95ccc2e2 100644 --- a/lib/rdoc/markup/to_label.rb +++ b/lib/rdoc/markup/to_label.rb @@ -16,8 +16,8 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter def initialize markup = nil super nil, markup - @markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF - @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK) + @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF + @markup.add_regexp_handling(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK) add_tag :BOLD, '', '' add_tag :TT, '', '' @@ -36,20 +36,20 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter end ## - # Converts the CROSSREF +special+ to plain text, removing the suppression + # Converts the CROSSREF +target+ to plain text, removing the suppression # marker, if any - def handle_special_CROSSREF special - text = special.text + def handle_regexp_CROSSREF target + text = target.text text.sub(/^\\/, '') end ## - # Converts the TIDYLINK +special+ to just the text part + # Converts the TIDYLINK +target+ to just the text part - def handle_special_TIDYLINK special - text = special.text + def handle_regexp_TIDYLINK target + text = target.text return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/ @@ -68,7 +68,7 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter alias accept_rule ignore alias accept_verbatim ignore alias end_accepting ignore - alias handle_special_HARD_BREAK ignore + alias handle_regexp_HARD_BREAK ignore alias start_accepting ignore end diff --git a/lib/rdoc/markup/to_markdown.rb b/lib/rdoc/markup/to_markdown.rb index d471032f9f..7932815405 100644 --- a/lib/rdoc/markup/to_markdown.rb +++ b/lib/rdoc/markup/to_markdown.rb @@ -19,8 +19,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc @headings[5] = ['##### ', ''] @headings[6] = ['###### ', ''] - add_special_RDOCLINK - add_special_TIDYLINK + add_regexp_handling_RDOCLINK + add_regexp_handling_TIDYLINK @hard_break = " \n" end @@ -37,7 +37,7 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc ## # Adds a newline to the output - def handle_special_HARD_BREAK special + def handle_regexp_HARD_BREAK target " \n" end @@ -166,8 +166,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc ## # Converts the RDoc markup tidylink into a Markdown.style link. - def handle_special_TIDYLINK special - text = special.text + def handle_regexp_TIDYLINK target + text = target.text return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/ @@ -184,8 +184,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc ## # Converts the rdoc-...: links into a Markdown.style links. - def handle_special_RDOCLINK special - handle_rdoc_link special.text + def handle_regexp_RDOCLINK target + handle_rdoc_link target.text end end diff --git a/lib/rdoc/markup/to_rdoc.rb b/lib/rdoc/markup/to_rdoc.rb index 1cb4d6bab2..3aee85afbe 100644 --- a/lib/rdoc/markup/to_rdoc.rb +++ b/lib/rdoc/markup/to_rdoc.rb @@ -45,7 +45,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter def initialize markup = nil super nil, markup - @markup.add_special(/\\\S/, :SUPPRESSED_CROSSREF) + @markup.add_regexp_handling(/\\\S/, :SUPPRESSED_CROSSREF) @width = 78 init_tags @@ -253,10 +253,10 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter end ## - # Removes preceding \\ from the suppressed crossref +special+ + # Removes preceding \\ from the suppressed crossref +target+ - def handle_special_SUPPRESSED_CROSSREF special - text = special.text + def handle_regexp_SUPPRESSED_CROSSREF target + text = target.text text = text.sub('\\', '') unless in_tt? text end @@ -264,7 +264,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter ## # Adds a newline to the output - def handle_special_HARD_BREAK special + def handle_regexp_HARD_BREAK target "\n" end diff --git a/lib/rdoc/markup/to_tt_only.rb b/lib/rdoc/markup/to_tt_only.rb index 4f43546e3d..9235d33f04 100644 --- a/lib/rdoc/markup/to_tt_only.rb +++ b/lib/rdoc/markup/to_tt_only.rb @@ -91,8 +91,8 @@ class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter when RDoc::Markup::AttrChanger then off_tags res, item on_tags res, item - when RDoc::Markup::Special then - @res << convert_special(item) if in_tt? # TODO can this happen? + when RDoc::Markup::RegexpHandling then + @res << convert_regexp_handling(item) if in_tt? # TODO can this happen? else raise "Unknown flow element: #{item.inspect}" end -- cgit v1.2.3