123456789_123456789_123456789_123456789_123456789_

Class: RDoc::Markup::ToLabel

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Formatter
Instance Chain:
self, Formatter
Inherits: RDoc::Markup::Formatter
Defined in: lib/rdoc/markup/to_label.rb

Overview

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).

Class Method Summary

Formatter - Inherited

.gen_relative_url

Converts a target url to one that is relative to a given path.

.new

Creates a new Formatter.

Instance Attribute Summary

Formatter - Inherited

#in_tt?

Are we currently inside tt tags?

Instance Method Summary

Formatter - Inherited

#accept_document

Adds document to the output.

#add_special_RDOCLINK

Adds a special for links of the form rdoc-…:

#add_special_TIDYLINK

Adds a special for links of the form <text> and <#add_tag

Add a new set of tags for an attribute.

#annotate

Allows tag to be decorated with additional information.

#convert

Marks up content

#convert_flow

Converts flow items flow

#convert_special

Converts added specials.

#convert_string

Converts a string to be fancier if desired.

#ignore

Use ignore in your subclass to ignore the content of a node.

#off_tags

Turns off tags for item on #res

#on_tags

Turns on tags for item on #res

#parse_url

Extracts and a scheme, url and an anchor id from url and returns them.

#tt?

Is tag a tt tag?

Constructor Details

.new(markup = nil) ⇒ ToLabel

Creates a new formatter that will output HTML-safe labels

[ GitHub ]

  
# File 'lib/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 = []
end

Instance Method Details

#accept_blank_line

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 58

alias accept_blank_line         ignore

#accept_block_quote

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 59

alias accept_block_quote        ignore

#accept_heading

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 60

alias accept_heading            ignore

#accept_list_end

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 61

alias accept_list_end           ignore

#accept_list_item_end

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 62

alias accept_list_item_end      ignore

#accept_list_item_start

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 63

alias accept_list_item_start    ignore

#accept_list_start

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 64

alias accept_list_start         ignore

#accept_paragraph

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 65

alias accept_paragraph          ignore

#accept_raw

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 66

alias accept_raw                ignore

#accept_rule

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 67

alias accept_rule               ignore

#accept_verbatim

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 68

alias accept_verbatim           ignore

#convert(text)

Converts text to an HTML-safe label

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 31

def convert text
  label = convert_flow @am.flow text

  CGI.escape(label).gsub('%', '-').sub(/^-/, '')
end

#end_accepting

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 69

alias end_accepting             ignore

#handle_special_CROSSREF(special)

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

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 41

def handle_special_CROSSREF special
  text = special.text

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

#handle_special_HARD_BREAK

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 70

alias handle_special_HARD_BREAK ignore

#start_accepting

[ GitHub ]

  
# File 'lib/rdoc/markup/to_label.rb', line 71

alias start_accepting           ignore