Module: Metanorma::Standoc::Metadata

Included in:
Cleanup
Defined in:
lib/metanorma/cleanup/metadata.rb

Instance Method Summary collapse

Instance Method Details

#annotation_cleanup(xmldoc) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/metanorma/cleanup/metadata.rb', line 40

def annotation_cleanup(xmldoc)
  ret = xmldoc.xpath("//annotation[@type = 'ignore-log']")
    .each_with_object([]) do |ann, m|
    error_ids = Array(@conv.csv_split(ann.text || "", ","))
    m << { from: ann["from"], to: ann["to"],
           error_ids: error_ids }
    ann
  end
  config = @log.suppress_log
  config[:locations] += ret
  @log.suppress_log = config
end

#metadata_cleanup(xmldoc) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/metanorma/cleanup/metadata.rb', line 4

def (xmldoc)
  bibdata_published(xmldoc) # feeds: bibdata_cleanup,
  # docidentifier_cleanup (in generic: template)
   = @conv.instance_variable_get(:@metadata_attrs)
  (.nil? || .empty?) and return
  ins = add_misc_container(xmldoc)
  ins << 
end

#metadata_cleanup_final(xmldoc) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/metanorma/cleanup/metadata.rb', line 28

def (xmldoc)
  root = nil
  %w(semantic presentation).each do |k|
    xmldoc.xpath("//#{k}-metadata").each_with_index do |x, i|
      if i.zero? then root = x
      else
        root << x.remove.elements
      end
    end
  end
end

#pres_metadata_cleanup(xmldoc) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/metanorma/cleanup/metadata.rb', line 13

def (xmldoc)
  unless @isodoc
    @isodoc = @conv.isodoc(@lang, @script, @locale)
    @conv.instance_variable_set(:@isodoc, @isodoc)
  end
  isodoc_bibdata_parse(xmldoc)
  xmldoc.xpath("//presentation-metadata/* | //semantic-metadata/*")
    .each do |x|
    /\{\{|\{%/.match?(x) or next
    x.children = @isodoc.populate_template(
      to_xml(x.children), nil
    )
  end
end