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 |
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
text
to an HTML-safe label. - #end_accepting
-
#handle_regexp_CROSSREF(target)
Converts the CROSSREF
target
to plain text, removing the suppression marker, if any. - #handle_regexp_HARD_BREAK
-
#handle_regexp_TIDYLINK(target)
Converts the TIDYLINK
target
to just the text part. - #start_accepting
Formatter
- Inherited
#accept_document | Adds |
|
#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 |
Add a new set of tags for an attribute. |
#annotate | Allows |
|
#convert | Marks up |
|
#convert_flow | Converts flow items |
|
#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 |
|
#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_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)
# 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
# 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
# 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
#handle_regexp_TIDYLINK(target)
Converts the TIDYLINK target
to just the text part
# File 'lib/rdoc/markup/to_label.rb', line 51
def handle_regexp_TIDYLINK target text = target.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