Class: JekyllHighlightCards::FreezeArchives::MarkupAnalyzer

Inherits:
Object
  • Object
show all
Includes:
ArchiveHelper, ExpressionEvaluator
Defined in:
lib/jekyll-highlight-cards/freeze_archives/markup_analyzer.rb

Overview

Classify {% linkcard %} / {% polaroid %} markup for freeze-archives.

A freeze candidate is a tag that has a literal archiveable target URL and does not already encode an archive (archive: / archive= / none). Liquid-dynamic targets are skipped (build-time fallback remains).

Instance Method Summary collapse

Methods included from ExpressionEvaluator

#evaluate_expression, #log_debug, #log_error, #log_info, #log_warn, #quote_wrapped?, #strip_outer_quotes, #variable_lookup?

Methods included from ArchiveHelper

#archive_enabled?, #archive_save_enabled?, #archive_url_for, #archive_user_agent

Constructor Details

#initialize(site: nil) ⇒ MarkupAnalyzer

Returns a new instance of MarkupAnalyzer.

Parameters:

  • site (Jekyll::Site, nil) (defaults to: nil)

    site for highlight_cards.noarchive



15
16
17
# File 'lib/jekyll-highlight-cards/freeze_archives/markup_analyzer.rb', line 15

def initialize(site: nil)
  @site = site
end

Instance Method Details

#analyze(tag, markup) ⇒ Hash?

Analyze tag markup for freeze eligibility

Parameters:

  • tag (String)

    "linkcard" or "polaroid"

  • markup (String)

    contents between the tag name and %}

Returns:

  • (Hash, nil)

    { target_url: String } when freezable, else nil



24
25
26
27
28
29
30
31
# File 'lib/jekyll-highlight-cards/freeze_archives/markup_analyzer.rb', line 24

def analyze(tag, markup)
  case tag.to_s
  when "linkcard"
    analyze_linkcard(markup)
  when "polaroid"
    analyze_polaroid(markup)
  end
end