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

  • #res readonly Internal use only

Formatter - Inherited

#in_tt?

Are we currently inside tt tags?

Instance Method Summary

Formatter - Inherited

#accept_document

Adds document to the output.

#add_regexp_handling_RDOCLINK

Adds a regexp handling for links of the form rdoc-…:

#add_regexp_handling_TIDYLINK

Adds a regexp handling for links of the form <text> and <word>.

#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_regexp_handling

Converts added regexp handlings.

#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 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

Instance Attribute Details

#res (readonly)

This method is for internal use only.
[ GitHub ]

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

attr_reader :res # :nodoc:

Instance Method Details

#accept_blank_line

[ GitHub ]

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

alias accept_blank_line         ignore

#accept_block_quote

[ GitHub ]

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

alias accept_block_quote        ignore

#accept_heading

[ GitHub ]

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

alias accept_heading            ignore

#accept_list_end

[ GitHub ]

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

alias accept_list_end           ignore

#accept_list_item_end

[ GitHub ]

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

alias accept_list_item_end      ignore

#accept_list_item_start

[ GitHub ]

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

alias accept_list_item_start    ignore

#accept_list_start

[ GitHub ]

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

alias accept_list_start         ignore

#accept_paragraph

[ GitHub ]

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

alias accept_paragraph          ignore

#accept_raw

[ GitHub ]

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

alias accept_raw                ignore

#accept_rule

[ GitHub ]

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

alias accept_rule               ignore

#accept_verbatim

[ GitHub ]

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

alias accept_verbatim           ignore

#convert(text)

Converts text to an HTML-safe label

[ GitHub ]

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

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 70

alias end_accepting             ignore

#handle_regexp_CROSSREF(target)

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

[ GitHub ]

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

def handle_regexp_CROSSREF target
  text = target.text

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

#handle_regexp_HARD_BREAK

[ GitHub ]

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

alias handle_regexp_HARD_BREAK  ignore

#start_accepting

[ GitHub ]

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

alias start_accepting           ignore