Class: Asciidoctor::Rouge::PassthroughsSubstitutor
- Inherits:
-
Object
- Object
- Asciidoctor::Rouge::PassthroughsSubstitutor
- Defined in:
- lib/asciidoctor/rouge/passthroughs_substitutor.rb
Overview
A substitutor for processing passthroughs inside listing blocks. It's basically just a facade for Asciidoctor's internal methods.
Constant Summary collapse
- PASS_START_MARK =
::Asciidoctor::Substitutors::PASS_START
- PASS_END_MARK =
::Asciidoctor::Substitutors::PASS_END
- PASS_SLOT_RX =
::Asciidoctor::Substitutors::HighlightedPassSlotRx
Class Method Summary collapse
-
.create(node) ⇒ PassthroughsSubstitutor
A passthroughs substitutor for the given node.
Instance Method Summary collapse
-
#extract(text) ⇒ String
Extracts passthrough regions from the given text for reinsertion after processing.
-
#restore(text) ⇒ String
Restores the extracted passthroughs by reinserting them into the placeholder positions.
Class Method Details
.create(node) ⇒ PassthroughsSubstitutor
Returns a passthroughs substitutor for the given node.
17 18 19 |
# File 'lib/asciidoctor/rouge/passthroughs_substitutor.rb', line 17 def self.create(node) new(node) end |
Instance Method Details
#extract(text) ⇒ String
Extracts passthrough regions from the given text for reinsertion after processing.
27 28 29 |
# File 'lib/asciidoctor/rouge/passthroughs_substitutor.rb', line 27 def extract(text) @node.extract_passthroughs(text) end |
#restore(text) ⇒ String
Restores the extracted passthroughs by reinserting them into the placeholder positions.
36 37 38 39 40 41 42 43 44 |
# File 'lib/asciidoctor/rouge/passthroughs_substitutor.rb', line 36 def restore(text) return text if @node.passthroughs.empty? # Fix passthrough placeholders that got caught up in syntax highlighting. text = text.gsub(PASS_SLOT_RX, "#{PASS_START_MARK}\\1#{PASS_END_MARK}") # Restore converted passthroughs. @node.restore_passthroughs(text) end |