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
- #res readonly Internal use only
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 using GitHub-style anchor formatting. -
#convert_legacy(text)
Converts
textto an HTML-safe label using legacy::RDoc::RDocformatting. - #end_accepting
- #extract_plaintext(text)
- #handle_PLAIN_TEXT(text)
-
#handle_regexp_CROSSREF(text)
Converts the CROSSREF
targetto plain text, removing the suppression marker, if any. - #handle_REGEXP_HANDLING_TEXT(text)
- #handle_TT(text)
- #start_accepting
Formatter - Inherited
| #accept_document | Adds |
| #add_regexp_handling_RDOCLINK | Adds a regexp handling for links of the form rdoc-…: |
| #annotate | Allows |
| #apply_regexp_handling | Applies regexp handling to |
| #convert | Marks up |
| #convert_string | Converts a string to be fancier if desired. |
| #handle_BOLD | Called when processing bold nodes while traversing inline nodes from handle_inline. |
| #handle_BOLD_WORD | Called when processing bold word nodes while traversing inline nodes from handle_inline. |
| #handle_EM | Called when processing emphasis nodes while traversing inline nodes from handle_inline. |
| #handle_EM_WORD | Called when processing emphasis word nodes while traversing inline nodes from handle_inline. |
| #handle_HARD_BREAK | Called when processing a hard break while traversing inline nodes from handle_inline. |
| #handle_inline | Parses inline |
| #handle_PLAIN_TEXT | Called when processing plain text while traversing inline nodes from handle_inline. |
| #handle_REGEXP_HANDLING_TEXT | Called when processing regexp-handling-processed text while traversing inline nodes from handle_inline. |
| #handle_STRIKE | Called when processing strike nodes while traversing inline nodes from handle_inline. |
| #handle_TEXT | Called when processing text node while traversing inline nodes from handle_inline. |
| #handle_TIDYLINK | Called when processing tidylink nodes while traversing inline nodes from handle_inline. |
| #handle_TT | Called when processing tt nodes while traversing inline nodes from handle_inline. |
| #ignore | Use ignore in your subclass to ignore the content of a node. |
| #parse_url | Extracts and a scheme, url and an anchor id from |
| #traverse_inline_nodes | Traverses |
| #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 17
def initialize(markup = nil) super nil, markup @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF @res = [] end
Instance Attribute Details
#res (readonly)
# File 'lib/rdoc/markup/to_label.rb', line 12
attr_reader :res # :nodoc:
Instance Method Details
#accept_blank_line
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 70
alias accept_blank_line ignore
#accept_block_quote
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 71
alias accept_block_quote ignore
#accept_heading
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 72
alias accept_heading ignore
#accept_list_end
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 73
alias accept_list_end ignore
#accept_list_item_end
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 74
alias accept_list_item_end ignore
#accept_list_item_start
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 75
alias accept_list_item_start ignore
#accept_list_start
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 76
alias accept_list_start ignore
#accept_paragraph
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 77
alias accept_paragraph ignore
#accept_raw
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 78
alias accept_raw ignore
#accept_rule
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 79
alias accept_rule ignore
#accept_verbatim
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 80
alias accept_verbatim ignore
#convert(text)
Converts text to an HTML-safe label using GitHub-style anchor formatting.
# File 'lib/rdoc/markup/to_label.rb', line 46
def convert(text) label = extract_plaintext(text) RDoc::Text.to_anchor(label) end
#convert_legacy(text)
Converts text to an HTML-safe label using legacy ::RDoc::RDoc formatting. Used for generating backward-compatible anchor aliases.
# File 'lib/rdoc/markup/to_label.rb', line 56
def convert_legacy(text) label = extract_plaintext(text) CGI.escape(label).gsub('%', '-').sub(/^-/, '') end
#end_accepting
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 81
alias end_accepting ignore
#extract_plaintext(text)
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 37
def extract_plaintext(text) @res = [] handle_inline(text) @res.join end
#handle_PLAIN_TEXT(text)
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 25
def handle_PLAIN_TEXT(text) @res << text end
#handle_regexp_CROSSREF(text)
Converts the CROSSREF target to plain text, removing the suppression marker, if any
# File 'lib/rdoc/markup/to_label.rb', line 66
def handle_regexp_CROSSREF(text) text.sub(/^\\/, '') end
#handle_REGEXP_HANDLING_TEXT(text)
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 29
def handle_REGEXP_HANDLING_TEXT(text) @res << text end
#handle_TT(text)
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 33
def handle_TT(text) @res << text end
#start_accepting
[ GitHub ]# File 'lib/rdoc/markup/to_label.rb', line 82
alias start_accepting ignore