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
- 
    
      .new(markup = nil)  ⇒ ToLabel 
    
    constructor
    
Creates a new formatter that will output HTML-safe labels.
 
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
Instance Method Summary
- #accept_blank_line
 - #accept_block_quote
 - #accept_heading
 - #accept_list_end
 - #accept_list_item_end
 - #accept_list_item_start
 - #accept_list_start
 - #accept_paragraph
 - #accept_raw
 - #accept_rule
 - #accept_verbatim
 - 
    
      #convert(text)  
    
    
Converts
textto an HTML-safe label. - #end_accepting
 - 
    
      #handle_special_CROSSREF(special)  
    
    
Converts the CROSSREF
specialto plain text, removing the suppression marker, if any. - #handle_special_HARD_BREAK
 - 
    
      #handle_special_TIDYLINK(special)  
    
    
Converts the TIDYLINK
specialto just the text part. - #start_accepting
 
Formatter - Inherited
| #accept_document | Adds   | 
    |
| #add_special_RDOCLINK | Adds a special for links of the form rdoc-…:  | 
    |
| #add_special_TIDYLINK | Adds a special for links of the form   | 
      Add a new set of tags for an attribute.  | 
    
| #annotate | Allows   | 
    |
| #convert | Marks up   | 
    |
| #convert_flow | Converts flow items   | 
    |
| #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   | 
    |
| #on_tags | Turns on tags for   | 
    |
| #parse_url | Extracts and a scheme, url and an anchor id from   | 
    |
| #tt? | Is   | 
    
Constructor Details
    .new(markup = nil)  ⇒ ToLabel 
  
Creates a new formatter that will output HTML-safe labels
# File 'lib/rdoc/markup/to_label.rb', line 16
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 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
# 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_special_CROSSREF(special)
Converts the CROSSREF special to plain text, removing the suppression marker, if any
# File 'lib/rdoc/markup/to_label.rb', line 42
def handle_special_CROSSREF special text = special.text text.sub(/^\\/, '') end
#handle_special_HARD_BREAK
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 71
alias handle_special_HARD_BREAK ignore
#handle_special_TIDYLINK(special)
Converts the TIDYLINK special to just the text part
# File 'lib/rdoc/markup/to_label.rb', line 51
def handle_special_TIDYLINK special text = special.text return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/ $1 end
#start_accepting
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 72
alias start_accepting ignore