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 17 def initialize(markup = nil) super nil, markup @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF @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 46 def convert(text) label = extract_plaintext(text) RDoc::Text.to_anchor(label) end
Converts text to an HTML-safe label using GitHub-style anchor formatting.
Source
# File lib/rdoc/markup/to_label.rb, line 56 def convert_legacy(text) label = extract_plaintext(text) CGI.escape(label).gsub('%', '-').sub(/^-/, '') end
Converts text to an HTML-safe label using legacy RDoc formatting. Used for generating backward-compatible anchor aliases.
Source
# File lib/rdoc/markup/to_label.rb, line 37 def extract_plaintext(text) @res = [] handle_inline(text) @res.join end
Source
# File lib/rdoc/markup/to_label.rb, line 25 def handle_PLAIN_TEXT(text) @res << text end
Source
# File lib/rdoc/markup/to_label.rb, line 29 def handle_REGEXP_HANDLING_TEXT(text) @res << text end
Source
# File lib/rdoc/markup/to_label.rb, line 33 def handle_TT(text) @res << text end
Source
# File lib/rdoc/markup/to_label.rb, line 66 def handle_regexp_CROSSREF(text) text.sub(/^\\/, '') end
Converts the CROSSREF target to plain text, removing the suppression marker, if any