Class: Tocer::Transformers::Link
- Inherits:
-
Object
- Object
- Tocer::Transformers::Link
- Defined in:
- lib/tocer/transformers/link.rb
Overview
Transforms a Markdown header (embedded link) into a table of contents link.
Instance Method Summary collapse
- #call(url_suffix: "") ⇒ Object
-
#initialize(text, parser: Parsers::Header) ⇒ Link
constructor
A new instance of Link.
- #label ⇒ Object
- #url ⇒ Object
Constructor Details
Instance Method Details
#call(url_suffix: "") ⇒ Object
20 |
# File 'lib/tocer/transformers/link.rb', line 20 def call(url_suffix: "") = "#{indented_bullet}[#{label}](##{computed_url url_suffix})" |
#label ⇒ Object
16 |
# File 'lib/tocer/transformers/link.rb', line 16 def label = parser.content.gsub(, ) |
#url ⇒ Object
18 |
# File 'lib/tocer/transformers/link.rb', line 18 def url = label.downcase.gsub(/\s/, "-").gsub(/[^\w-]+/, "") |