Class: JekyllHighlightCards::FreezeArchives::TagLocator
- Inherits:
-
Object
- Object
- JekyllHighlightCards::FreezeArchives::TagLocator
- Defined in:
- lib/jekyll-highlight-cards/freeze_archives/tag_locator.rb
Overview
Locate {% linkcard %} / {% polaroid %} spans in source text.
Supports multiline tags. Returns structural spans for analysis/insert — does not decide freeze eligibility.
Constant Summary collapse
- TAG_PATTERN =
Optional +- after
{ %/ before%}is Liquid whitespace control — keep the trailing dash out of:markup(leading dash stays in the opener). /{%-?\s*(linkcard|polaroid)\s+([\s\S]*?)-?%}/
Instance Method Summary collapse
-
#locate(text) ⇒ Array<Hash>
Find highlight-card tag spans in
text.
Instance Method Details
#locate(text) ⇒ Array<Hash>
Find highlight-card tag spans in text
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jekyll-highlight-cards/freeze_archives/tag_locator.rb', line 18 def locate(text) spans = [] text.to_s.scan(TAG_PATTERN) do match = Regexp.last_match spans << { tag: match[1], markup: match[2], range: match.begin(0)...match.end(0) } end spans end |