class RDoc::Markup::ToLabel
Creates HTML-safe labels suitable for use in id attributes. Tidylinks are converted to their link part and cross-reference links have the suppression marks removed (\SomeClass is converted to SomeClass).
Public Class Methods
Source
# File lib/rdoc/markup/to_label.rb, line 16 def initialize markup = nil super nil, markup @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF @markup.add_regexp_handling(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK) add_tag :BOLD, '', '' add_tag :TT, '', '' add_tag :EM, '', '' @res = [] end
Creates a new formatter that will output HTML-safe labels
Calls superclass method
RDoc::Markup::Formatter::new
Public Instance Methods
Source
# File lib/rdoc/markup/to_label.rb, line 32 def convert text label = convert_flow @am.flow text CGI.escape(label).gsub('%', '-').sub(/^-/, '') end
Converts text
to an HTML-safe label
Source
# File lib/rdoc/markup/to_label.rb, line 42 def handle_regexp_CROSSREF target text = target.text text.sub(/^\\/, '') end
Converts the CROSSREF target
to plain text, removing the suppression marker, if any
Source
# File lib/rdoc/markup/to_label.rb, line 51 def handle_regexp_TIDYLINK target text = target.text return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/ $1 end
Converts the TIDYLINK target
to just the text part