Module: Asciidoctor::ISO::InlineAnchor

Included in:
Converter
Defined in:
lib/asciidoctor/iso/inline_anchor.rb

Instance Method Summary collapse

Instance Method Details

#inline_anchor(node) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/asciidoctor/iso/inline_anchor.rb', line 4

def inline_anchor(node)
  case node.type
  when :xref
    inline_anchor_xref node
  when :link
    inline_anchor_link node
  when :bibref
    inline_anchor_bibref node
  else
    warn %(asciidoctor: WARNING (#{current_location(node)}): unknown anchor type: #{node.type.inspect})
  end
end

#inline_anchor_bibref(node) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/asciidoctor/iso/inline_anchor.rb', line 47

def inline_anchor_bibref(node)
  eref_contents = node.target == node.text ? nil : node.text
  eref_attributes = {
    anchor: node.target,
  }

  noko do |xml|
    xml.ref eref_contents, **attr_code(eref_attributes)
  end.join
end


36
37
38
39
40
41
42
43
44
45
# File 'lib/asciidoctor/iso/inline_anchor.rb', line 36

def inline_anchor_link(node)
  eref_contents = node.target == node.text ? nil : node.text
  eref_attributes = {
    target: node.target,
  }

  noko do |xml|
    xml.eref eref_contents, **attr_code(eref_attributes)
  end.join
end

#inline_anchor_xref(node) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/asciidoctor/iso/inline_anchor.rb', line 17

def inline_anchor_xref(node)
  matched = /^fn(:  (?<text>.*))?$/.match node.text
  if matched.nil?
    format = "inline"
    xref_contents = node.text
  else
    format = "footnote"
    xref_contents = matched[:text]
  end
  xref_attributes = {
    target: node.target.gsub(/^#/, "").gsub(/(.)(\.xml)?#.*$/, "\\1"),
    format: format,
  }

  noko do |xml|
    xml.xref xref_contents, **attr_code(xref_attributes)
  end.join
end

#inline_callout(node) ⇒ Object



58
59
60
61
62
# File 'lib/asciidoctor/iso/inline_anchor.rb', line 58

def inline_callout(node)
  noko do |xml|
    xml.ref node.text
  end.join
end