Module: IsoDoc::Function::Inline

Included in:
Common
Defined in:
lib/isodoc/function/inline.rb

Instance Method Summary collapse

Instance Method Details

#anchor_linkend(node, linkend) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/isodoc/function/inline.rb', line 29

def anchor_linkend(node, linkend)
  if node["citeas"].nil? && node["bibitemid"] &&
      get_anchors.has_key?(node["bibitemid"])
    return get_anchors.dig(node["bibitemid"] ,:xref)
  elsif node["target"] && get_anchors.has_key?(node["target"])
    linkend = get_anchors[node["target"]][:xref]
    container = get_anchors[node["target"]][:container]
    (container && get_note_container_id(node) != container) &&
      linkend = prefix_container(container, linkend, node["target"])
  end
  linkend
end

#callout_parse(node, out) ⇒ Object



21
22
23
# File 'lib/isodoc/function/inline.rb', line 21

def callout_parse(node, out)
  out << " &lt;#{node.text}&gt;"
end

#eref_localities(refs, target) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/isodoc/function/inline.rb', line 57

def eref_localities(refs, target)
  ret = ""
  refs.each do |r|
    ret += if r["type"] == "whole" then l10n(", #{@whole_of_text}")
           else
             eref_localities1(target, r["type"], r.at(ns("./referenceFrom")),
                              r.at(ns("./referenceTo")), @lang)
           end
  end
  ret
end

#eref_parse(node, out) ⇒ Object



69
70
71
72
73
74
75
76
77
78
# File 'lib/isodoc/function/inline.rb', line 69

def eref_parse(node, out)
  linkend = get_linkend(node)
  if node["type"] == "footnote"
    out.sup do |s|
      s.a(**{ "href": "#" + node["bibitemid"] }) { |l| l << linkend }
    end
  else
    out.a(**{ "href": "#" + node["bibitemid"] }) { |l| l << linkend }
  end
end

#error_parse(node, out) ⇒ Object



92
93
94
95
96
97
# File 'lib/isodoc/function/inline.rb', line 92

def error_parse(node, out)
  text = node.to_xml.gsub(/</, "&lt;").gsub(/>/, "&gt;")
  out.para do |p|
    p.b(**{ role: "strong" }) { |e| e << text }
  end
end

#get_linkend(node) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/isodoc/function/inline.rb', line 42

def get_linkend(node)
  link = anchor_linkend(node, docid_l10n(node["target"] || node["citeas"]))
  link += eref_localities(node.xpath(ns("./locality")), link)
  text = node.children.select { |c| c.text? && !c.text.empty? }
  link = text.join(" ") unless text.nil? || text.empty?
  # so not <origin bibitemid="ISO7301" citeas="ISO 7301">
  # <locality type="section"><reference>3.1</reference></locality></origin>
  link
end


11
12
13
14
15
16
17
18
19
# File 'lib/isodoc/function/inline.rb', line 11

def link_parse(node, out)
  out.a(**{ "href": node["target"] }) do |l|
    if node.text.empty?
      l << node["target"].sub(/^mailto:/, "")
    else
      node.children.each { |n| parse(n, l) }
    end
  end
end

#page_break(out) ⇒ Object



7
8
9
# File 'lib/isodoc/function/inline.rb', line 7

def page_break(out)
  out.br
end

#prefix_container(container, linkend, _target) ⇒ Object



25
26
27
# File 'lib/isodoc/function/inline.rb', line 25

def prefix_container(container, linkend, _target)
  l10n(get_anchors[container][:xref] + ", " + linkend)
end

#section_break(body) ⇒ Object



3
4
5
# File 'lib/isodoc/function/inline.rb', line 3

def section_break(body)
  body.br
end

#stem_parse(node, out) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/isodoc/function/inline.rb', line 80

def stem_parse(node, out)
  ooml = if node["type"] == "AsciiMath"
           "#{@openmathdelim}#{HTMLEntities.new.encode(node.text)}#{@closemathdelim}"
         elsif node["type"] == "MathML" then node.first_element_child.to_s
         else
           HTMLEntities.new.encode(node.text)
         end
  out.span **{ class: "stem" } do |span|
    span.parent.add_child ooml
  end
end

#xref_parse(node, out) ⇒ Object



52
53
54
55
# File 'lib/isodoc/function/inline.rb', line 52

def xref_parse(node, out)
  linkend = get_linkend(node)
  out.a(**{ "href": "#" + node["target"] }) { |l| l << linkend }
end