Module: Asciidoctor::BeautifyUri::Placeholder

Defined in:
lib/asciidoctor/beautify_uri/placeholder.rb

Overview

DESIGN-asciidoctor-beautify-uri.adoc, "Resolution": "When resolution fails, the macro MUST render a visible placeholder showing that the reference could not be resolved."

Class Method Summary collapse

Class Method Details

.html(target) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/asciidoctor/beautify_uri/placeholder.rb', line 7

def self.html(target)
  escaped = CardRenderer.escape_html(target)
  <<~HTML
    <div class="uri-card uri-card--unresolved" style="display:inline-flex;align-items:center;gap:0.6rem;border:1px dashed rgba(27,30,36,0.4);border-radius:12px;padding:0.75rem 1.1rem;color:inherit;">
      <strong>&#9888;</strong>
      <span>Could not resolve <code>#{escaped}</code></span>
    </div>
  HTML
end

.pdf_block(parent, target) ⇒ Object

PDF has no HTML renderer to pass this through to (see pdf_card.rb) — compose the same warning as a real AsciiDoc node instead.



19
20
21
22
23
24
# File 'lib/asciidoctor/beautify_uri/placeholder.rb', line 19

def self.pdf_block(parent, target)
  ::Asciidoctor::Block.new(parent, :example,
    source: %(&#9888; Could not resolve `#{PdfCard.escape target}`),
    attributes: { 'role' => 'uri-card uri-card--unresolved' },
    subs: :normal)
end