Maintenance of Ruby 2.0.0 ended on February 24, 2016. Read more

In Files

  • rdoc/markup/to_label.rb

Class/Module Index [+]



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

new(markup = nil) click to toggle source

Creates a new formatter that will output HTML-safe labels

               # File rdoc/markup/to_label.rb, line 15
def initialize markup = nil
  super nil, markup

  @markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
  @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK)

  add_tag :BOLD, '', ''
  add_tag :TT,   '', ''
  add_tag :EM,   '', ''

  @res = []

Public Instance Methods

convert(text) click to toggle source

Converts text to an HTML-safe label

               # File rdoc/markup/to_label.rb, line 31
def convert text
  label = convert_flow @am.flow text

  CGI.escape label
handle_special_CROSSREF(special) click to toggle source

Converts the CROSSREF special to plain text, removing the suppression marker, if any

               # File rdoc/markup/to_label.rb, line 41
def handle_special_CROSSREF special
  text = special.text

  text.sub(/^\/, '')

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit