Class: Metanorma::Requirements::Modspec::Iso

Inherits:
Metanorma::Requirements::Modspec show all
Defined in:
lib/metanorma/requirements/modspec.rb

Instance Method Summary collapse

Instance Method Details

#nested_tables_names(table) ⇒ Object


26
27
28
29
30
31
32
33
# File 'lib/metanorma/requirements/modspec.rb', line 26

def nested_tables_names(table)
  table.xpath(ns("./tbody/tr/td/*/fmt-provision/table"))
    .each_with_object([]) do |t, m|
      id = t["original-id"] || t["id"]
      id and b = "<bookmark id='#{id}'/>"
      m << b + to_xml(t.at(ns(".//fmt-name")).children).strip
    end
end

#postprocess_anchor_struct(block, anchor) ⇒ Object


35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/metanorma/requirements/modspec.rb', line 35

def postprocess_anchor_struct(block, anchor)
  super
  t = block.at(ns("./fmt-provision/table")) and
    anchor[:container] = t["id"]
  anchor[:modspec] = anchor[:xref_bare]
  if l = block.at(ns("./title"))
    anchor[:modspec] =
      l10n("#{anchor[:modspec]}<span class='fmt-caption-delim'>: </span><semx element='title' source='#{block['id']}'>#{l.children.to_xml.strip}</semx>")
  end
  /<xref/.match?(anchor[:modspec]) or
    anchor[:modspec] = "<xref target='#{block['id']}'>#{anchor[:modspec]}</xref>"
  anchor
end

#requirement_table_cleanup_nested_replacement(node, out, table) ⇒ Object


17
18
19
20
21
22
23
24
# File 'lib/metanorma/requirements/modspec.rb', line 17

def requirement_table_cleanup_nested_replacement(node, out, table)
  label = "provision"
  node["type"] == "conformanceclass" and label = "conformancetest"
  n = nested_tables_names(table)
  hdr = @i18n.inflect(@labels["modspec"][label],
                      number: n.size == 1 ? "sg" : "pl")
  "<tr><th>#{hdr}</th><td>#{n.join('<br/>')}</td></tr>"
end

#requirement_table_nested_cleanup(node, out, table) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/metanorma/requirements/modspec.rb', line 5

def requirement_table_nested_cleanup(node, out, table)
  (out.xpath(ns(".//table")) - out.xpath(ns("./fmt-provision/table"))).each do |x|
    x["unnumbered"] = "true"
  end
  table["type"] == "recommendclass" or return super # table
  ins = table.at(ns("./tbody/tr[td/*/fmt-provision/table]")) or return table
  ins.replace(requirement_table_cleanup_nested_replacement(node, out, table))
  table.xpath(ns("./tbody/tr[td/*/fmt-provision/table]")).each(&:remove)
  out.xpath(ns("./*/fmt-provision")).each(&:remove)
  table
end