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