Module: IsoDoc::IEEE::BaseConvert

Included in:
HtmlConvert, WordConvert
Defined in:
lib/isodoc/ieee/base_convert.rb

Instance Method Summary collapse

Instance Method Details

#bracket_if_num(num) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/isodoc/ieee/base_convert.rb', line 70

def bracket_if_num(num)
  return nil if num.nil?

  num = num.text.sub(/^\[/, "").sub(/\]$/, "")
  return "[#{num}]" if /^B?\d+$/.match?(num)

  num
end

#clause_attrs(node) ⇒ Object



7
8
9
# File 'lib/isodoc/ieee/base_convert.rb', line 7

def clause_attrs(node)
  { id: node["id"], type: node["type"] }
end

#example_label(_node, div, name) ⇒ Object



79
80
81
82
83
84
85
86
# File 'lib/isodoc/ieee/base_convert.rb', line 79

def example_label(_node, div, name)
  return if name.nil?

  name << ":"
  div.p **{ class: "example-title" } do |p|
    name.children.each { |n| parse(n, p) }
  end
end

#formula_where(dlist, out) ⇒ Object



63
64
65
66
67
68
# File 'lib/isodoc/ieee/base_convert.rb', line 63

def formula_where(dlist, out)
  return unless dlist

  parse(dlist, out)
  out.parent.at("./dl")["class"] = "formula_dl"
end

#middle_clause(_docxml = nil) ⇒ Object



23
24
25
26
# File 'lib/isodoc/ieee/base_convert.rb', line 23

def middle_clause(_docxml = nil)
  "//clause[parent::sections][not(@type = 'overview')]"\
    "[not(descendant::terms)]"
end

#note_delimObject



32
33
34
# File 'lib/isodoc/ieee/base_convert.rb', line 32

def note_delim
  "&#x2014;"
end

#note_p_parse(node, div) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/isodoc/ieee/base_convert.rb', line 36

def note_p_parse(node, div)
  name = node&.at(ns("./name"))&.remove
  div.p do |p|
    name and p.span **{ class: "note_label" } do |s|
      name.children.each { |n| parse(n, s) }
      s << note_delim
    end
    node.first_element_child.children.each { |n| parse(n, p) }
  end
  node.element_children[1..-1].each { |n| parse(n, div) }
end

#note_parse1(node, div) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/isodoc/ieee/base_convert.rb', line 48

def note_parse1(node, div)
  name = node&.at(ns("./name"))&.remove
  name and div.p do |p|
    p.span **{ class: "note_label" } do |s|
      name.children.each { |n| parse(n, s) }
      s << note_delim
    end
  end
  node.children.each { |n| parse(n, div) }
end

#para_attrs(node) ⇒ Object



28
29
30
# File 'lib/isodoc/ieee/base_convert.rb', line 28

def para_attrs(node)
  super.merge(type: node["type"])
end

#scope(isoxml, out, num) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/isodoc/ieee/base_convert.rb', line 11

def scope(isoxml, out, num)
  f = isoxml.at(ns("//clause[@type = 'overview']")) or return num
  out.div **attr_code(id: f["id"]) do |div|
    num = num + 1
    clause_name(num, f&.at(ns("./title")), div, nil)
    f.elements.each do |e|
      parse(e, div) unless e.name == "title"
    end
  end
  num
end

#termnote_delimObject



59
60
61
# File 'lib/isodoc/ieee/base_convert.rb', line 59

def termnote_delim
  "&#x2014;"
end