Module: Metanorma::Standoc::Front

Included in:
Converter
Defined in:
lib/metanorma/standoc/front.rb,
lib/metanorma/standoc/front_contributor.rb,
lib/metanorma/standoc/front_organisation.rb

Instance Method Summary collapse

Instance Method Details

#committee_component(compname, node, out) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/metanorma/standoc/front_organisation.rb', line 4

def committee_component(compname, node, out)
  i = 1
  suffix = ""
  while node.attr(compname + suffix)
    out.send compname.gsub(/-/, "_"), node.attr(compname + suffix),
             **attr_code(number: node.attr("#{compname}-number#{suffix}"),
                         type: node.attr("#{compname}-type#{suffix}"))
    i += 1
    suffix = "_#{i}"
  end
end


95
96
97
98
99
100
101
# File 'lib/metanorma/standoc/front_contributor.rb', line 95

def copyright_parse(node)
  opt = { source: ["copyright-holder", "publisher", "pub"],
          role: "publisher", default: default_publisher }
  ret = org_attrs_parse(node, opt)
  ret.empty? and ret = [{ name: "-" }]
  ret
end

#datetypesObject



88
89
90
91
92
# File 'lib/metanorma/standoc/front.rb', line 88

def datetypes
  %w{ published accessed created implemented obsoleted
      confirmed updated corrected issued circulated unchanged received
      vote-started vote-ended announced }
end

#default_publisherObject



122
123
124
# File 'lib/metanorma/standoc/front_organisation.rb', line 122

def default_publisher
  nil
end

#extract_org_attrs_address(node, opts, suffix) ⇒ Object



198
199
200
201
202
203
204
205
# File 'lib/metanorma/standoc/front_organisation.rb', line 198

def extract_org_attrs_address(node, opts, suffix)
  %w(address phone fax email uri).each_with_object({}) do |a, m|
    opts[:source]&.each do |s|
      p = node.attr("#{s}-#{a}#{suffix}") and
        m[a.to_sym] = p
    end
  end
end

#extract_org_attrs_complex(node, opts, source, suffix) ⇒ Object



189
190
191
192
193
194
195
196
# File 'lib/metanorma/standoc/front_organisation.rb', line 189

def extract_org_attrs_complex(node, opts, source, suffix)
  { name: node.attr(source + suffix),
    abbrev: node.attr("#{source}_abbr#{suffix}"),
    role: opts[:role], desc: opts[:desc],
    subdiv: node.attr("#{source}_subdivision#{suffix}"),
    logo: node.attr("#{source}_logo#{suffix}") }.compact
    .merge(extract_org_attrs_address(node, opts, suffix))
end

#metadata(node, xml) ⇒ Object



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/metanorma/standoc/front.rb', line 169

def (node, xml)
  title node, xml
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  xml.ext do
    (node, xml)
  end
end

#metadata_author(node, xml) ⇒ Object



6
7
8
9
10
11
# File 'lib/metanorma/standoc/front_contributor.rb', line 6

def (node, xml)
  org_contributor(node, xml,
                  { source: ["publisher", "pub"], role: "author",
                    default: default_publisher })
  personal_author(node, xml)
end

#metadata_classifications(node, xml) ⇒ Object



161
162
163
164
165
166
167
# File 'lib/metanorma/standoc/front.rb', line 161

def (node, xml)
  csv_split(node.attr("classification"), ",")&.each do |c|
    vals = c.split(/:/, 2)
    vals.size == 1 and vals = ["default", vals[0]]
    xml.classification vals[1], type: vals[0]
  end
end

#metadata_committee(node, xml) ⇒ Object



56
57
58
59
60
61
# File 'lib/metanorma/standoc/front.rb', line 56

def (node, xml)
  node.attr("technical-committee") or return
  xml.editorialgroup do |a|
    committee_component("technical-committee", node, a)
  end
end


103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/metanorma/standoc/front_contributor.rb', line 103

def (node, xml)
  copyright_parse(node).each do |p|
    xml.copyright do |c|
      c.from (node.attr("copyright-year") || Date.today.year)
      (p[:name].is_a?(String) && p[:name].match(/\p{L}/).nil?) or
        c.owner do |owner|
          owner.organization do |a|
            org_organization(node, a, p)
          end
        end
    end
  end
end

#metadata_coverpage_images(node, xml) ⇒ Object



246
247
248
249
250
251
252
253
254
255
# File 'lib/metanorma/standoc/front.rb', line 246

def (node, xml)
  %w(coverpage-image innercoverpage-image tocside-image
     backpage-image).each do |n|
    if a = node.attr(n)
      xml.send n do |c|
        a.split(",").each { |x| c.image src: x }
      end
    end
  end
end

#metadata_date(node, xml) ⇒ Object



94
95
96
97
98
99
100
101
102
# File 'lib/metanorma/standoc/front.rb', line 94

def (node, xml)
  datetypes.each { |t| (node, xml, t) }
  node.attributes.each_key do |a|
    a == "date" || /^date_\d+$/.match(a) or next
    type, date = node.attr(a).split(/ /, 2)
    type or next
    xml.date(type:) { |d| d.on date }
  end
end

#metadata_date1(node, xml, type) ⇒ Object



81
82
83
84
85
86
# File 'lib/metanorma/standoc/front.rb', line 81

def (node, xml, type)
  date = node.attr("#{type}-date")
  date and xml.date(type:) do |d|
    d.on date
  end
end

#metadata_doctype(node, xml) ⇒ Object



205
206
207
# File 'lib/metanorma/standoc/front.rb', line 205

def (node, xml)
  xml.doctype doctype(node)
end

#metadata_ext(node, ext) ⇒ Object



193
194
195
196
197
198
199
200
201
# File 'lib/metanorma/standoc/front.rb', line 193

def (node, ext)
  (node, ext)
  (node, ext)
  (node, ext)
  (node, ext)
  (node, ext)
  structured_id(node, ext)
  (node, ext)
end

#metadata_flavor(_node, ext) ⇒ Object



213
214
215
# File 'lib/metanorma/standoc/front.rb', line 213

def (_node, ext)
  ext.flavor processor.new.asciidoctor_backend
end

#metadata_getrelation(node, xml, type, desc = nil) ⇒ Object



136
137
138
139
140
141
# File 'lib/metanorma/standoc/front.rb', line 136

def (node, xml, type, desc = nil)
  docs = node.attr(desc || type) or return
  @c.decode(docs).split(/;\s*/).each do |d|
    (d, xml, type, desc)
  end
end

#metadata_getrelation1(doc, xml, type, desc) ⇒ Object



143
144
145
146
147
148
149
150
151
152
# File 'lib/metanorma/standoc/front.rb', line 143

def (doc, xml, type, desc)
  id = doc.split(/,\s*/)
  xml.relation type: relation_normalise(type) do |r|
    desc.nil? or r.description desc.tr("-", " ")
    fetch_ref(r, doc, nil, **{}) or r.bibitem do |b|
      b.title id[1] || "--"
      b.docidentifier id[0]
    end
  end
end

#metadata_ics(node, xml) ⇒ Object



63
64
65
66
67
68
69
70
71
72
# File 'lib/metanorma/standoc/front.rb', line 63

def (node, xml)
  ics = node.attr("library-ics")
  ics&.split(/,\s*/)&.each do |i|
    xml.ics do |elem|
      elem.code i
      icsdata = Isoics.fetch i
      elem.text_ icsdata.description
    end
  end
end

#metadata_id(node, xml) ⇒ Object



9
10
11
12
# File 'lib/metanorma/standoc/front.rb', line 9

def (node, xml)
  id = node.attr("docidentifier") || (node)
  xml.docidentifier id, primary: "true"
end

#metadata_id_build(node) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/metanorma/standoc/front.rb', line 14

def (node)
  part, subpart = node&.attr("partnumber")&.split("-")
  id = node.attr("docnumber") || ""
  id += "-#{part}" if part
  id += "-#{subpart}" if subpart
  id
end

#metadata_keywords(node, xml) ⇒ Object



154
155
156
157
158
159
# File 'lib/metanorma/standoc/front.rb', line 154

def (node, xml)
  node.attr("keywords") or return
  node.attr("keywords").split(/,\s*/).each do |kw|
    xml.keyword kw
  end
end

#metadata_language(node, xml) ⇒ Object



104
105
106
107
# File 'lib/metanorma/standoc/front.rb', line 104

def (node, xml)
  xml.language (node.attr("language") || "en")
  l = node.attr("locale") and xml.locale l
end

#metadata_note(node, xml) ⇒ Object



217
# File 'lib/metanorma/standoc/front.rb', line 217

def (node, xml); end

#metadata_other_id(node, xml) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/metanorma/standoc/front.rb', line 22

def (node, xml)
  a = node.attr("isbn") and xml.docidentifier a, type: "ISBN"
  a = node.attr("isbn10") and xml.docidentifier a, type: "ISBN10"
  csv_split(node.attr("docidentifier-additional"), ",")&.each do |n|
    t, v = n.split(":", 2)
    xml.docidentifier v, type: t
  end
  xml.docnumber node.attr("docnumber")
end

#metadata_publisher(node, xml) ⇒ Object



82
83
84
85
86
# File 'lib/metanorma/standoc/front_contributor.rb', line 82

def (node, xml)
  o = { source: ["publisher", "pub"], role: "publisher",
        default: default_publisher }
  org_contributor(node, xml, o)
end

#metadata_relations(node, xml) ⇒ Object



122
123
124
125
126
127
128
129
# File 'lib/metanorma/standoc/front.rb', line 122

def (node, xml)
  relaton_relations.each do |t|
    (node, xml, t)
  end
  relaton_relation_descriptions.each do |k, v|
    (node, xml, v, k)
  end
end

#metadata_script(node, xml) ⇒ Object



109
110
111
112
# File 'lib/metanorma/standoc/front.rb', line 109

def (node, xml)
  xml.script (node.attr("script") ||
              Metanorma::Utils.default_script(node.attr("language")))
end

#metadata_series(node, xml) ⇒ Object



219
# File 'lib/metanorma/standoc/front.rb', line 219

def (node, xml); end

#metadata_source(node, xml) ⇒ Object



74
75
76
77
78
79
# File 'lib/metanorma/standoc/front.rb', line 74

def (node, xml)
  node.attr("uri") && xml.uri(node.attr("uri"))
  %w(xml html pdf doc relaton).each do |t|
    node.attr("#{t}-uri") && xml.uri(node.attr("#{t}-uri"), type: t)
  end
end

#metadata_sponsor(node, xml) ⇒ Object



88
89
90
91
92
93
# File 'lib/metanorma/standoc/front_contributor.rb', line 88

def (node, xml)
  o = { source: ["sponsor"], role: "enabler" }
  org_contributor(node, xml, o)
  o = { source: ["authorizer"], role: "authorizer" }
  org_contributor(node, xml, o)
end

#metadata_status(node, xml) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/metanorma/standoc/front.rb', line 48

def (node, xml)
  xml.status do |s|
    s.stage (node.attr("status") || node.attr("docstage") || "published")
    node.attr("docsubstage") and s.substage node.attr("docsubstage")
    node.attr("iteration") and s.iteration node.attr("iteration")
  end
end

#metadata_subdoctype(node, xml) ⇒ Object



209
210
211
# File 'lib/metanorma/standoc/front.rb', line 209

def (node, xml)
  s = node.attr("docsubtype") and xml.subdoctype s
end

#metadata_version(node, xml) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/metanorma/standoc/front.rb', line 32

def (node, xml)
  draft = (node)
  xml.edition node.attr("edition") if node.attr("edition")
  xml.version do |v|
    v.revision_date node.attr("revdate") if node.attr("revdate")
    v.draft draft if draft
  end
end

#metadata_version_value(node) ⇒ Object



41
42
43
44
45
46
# File 'lib/metanorma/standoc/front.rb', line 41

def (node)
  draft = node.attr("version") and return draft
  draft = node.attr("draft") or return nil
  draft.empty? and return nil
  draft
end

#org_abbrevObject



126
127
128
# File 'lib/metanorma/standoc/front_organisation.rb', line 126

def org_abbrev
  {}
end

#org_address(org, xml) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/metanorma/standoc/front_organisation.rb', line 66

def org_address(org, xml)
  p = org[:address] and xml.address do |ad|
    ad.formattedAddress do |f|
      f << p.gsub(/ \+\n/, "<br/>")
    end
  end
  org_contact(org, xml)
end

#org_attrs_complex_parse(node, opts, source) ⇒ Object



177
178
179
180
181
182
183
184
185
186
187
# File 'lib/metanorma/standoc/front_organisation.rb', line 177

def org_attrs_complex_parse(node, opts, source)
  i = 1
  suffix = ""
  ret = []
  while node.attr(source + suffix)
    ret << extract_org_attrs_complex(node, opts, source, suffix)
    i += 1
    suffix = "_#{i}"
  end
  ret
end

#org_attrs_parse(node, opts) ⇒ Object



155
156
157
158
159
# File 'lib/metanorma/standoc/front_organisation.rb', line 155

def org_attrs_parse(node, opts)
  source = opts[:source]&.detect { |s| node.attr(s) }
  org_attrs_simple_parse(node, opts, source) ||
    org_attrs_complex_parse(node, opts, source)
end

#org_attrs_simple_parse(node, opts, source) ⇒ Object



161
162
163
164
165
166
167
168
# File 'lib/metanorma/standoc/front_organisation.rb', line 161

def org_attrs_simple_parse(node, opts, source)
  !source and return org_attrs_simple_parse_no_source(node, opts)
  orgs = csv_split(node.attr(source))
  orgs.size > 1 and return orgs.map do |o|
    { name: o, role: opts[:role], desc: opts[:desc] }
  end
  nil
end

#org_attrs_simple_parse_no_source(node, opts) ⇒ Object



170
171
172
173
174
175
# File 'lib/metanorma/standoc/front_organisation.rb', line 170

def org_attrs_simple_parse_no_source(node, opts)
  !opts[:default] && !opts[:name] and return []
  [{ name: opts[:name] || opts[:default],
     role: opts[:role], desc: opts[:desc] }
    .compact.merge(extract_org_attrs_address(node, opts, ""))]
end

#org_contact(org, xml) ⇒ Object



75
76
77
78
79
80
# File 'lib/metanorma/standoc/front_organisation.rb', line 75

def org_contact(org, xml)
  p = org[:phone] and xml.phone p
  p = org[:fax] and xml.phone p, type: "fax"
  p = org[:email] and xml.email p
  p = org[:uri] and xml.uri p
end

#org_contributor(node, xml, opts) ⇒ Object



130
131
132
133
134
135
136
137
138
139
# File 'lib/metanorma/standoc/front_organisation.rb', line 130

def org_contributor(node, xml, opts)
  org_attrs_parse(node, opts).each do |o|
    xml.contributor do |c|
      org_contributor_role(c, o)
      c.organization do |a|
        org_organization(node, a, o)
      end
    end
  end
end

#org_contributor_role(xml, org) ⇒ Object



141
142
143
144
145
146
147
# File 'lib/metanorma/standoc/front_organisation.rb', line 141

def org_contributor_role(xml, org)
  xml.role type: org[:role] do |r|
    org[:desc] and r.description do |d|
      d << org[:desc]
    end
  end
end

#org_logo(xml, logo) ⇒ Object



116
117
118
119
120
# File 'lib/metanorma/standoc/front_organisation.rb', line 116

def (xml, )
   and xml. do |l|
    l.image src: , mimetype: image_mimetype()
  end
end

#org_name_and_abbrev(org, orgname) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/metanorma/standoc/front_organisation.rb', line 25

def org_name_and_abbrev(org, orgname)
  if org[:abbrev]
    [orgname, org[:abbrev]]
  else
    abbrevs = org_abbrev
    n = abbrevs.invert[orgname] and orgname = n
    [orgname, org_abbrev[orgname]]
  end
end

#org_organization(node, xml, org) ⇒ Object



149
150
151
152
153
# File 'lib/metanorma/standoc/front_organisation.rb', line 149

def org_organization(node, xml, org)
  organization(xml, org[:name], node, !node.attr("publisher"), org)
  org_address(org, xml)
  (xml, org[:logo])
end

#organization(org, orgname, node = nil, default_org = nil, attrs = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/metanorma/standoc/front_organisation.rb', line 16

def organization(org, orgname, node = nil, default_org = nil, attrs = {})
  orgname, abbr = org_name_and_abbrev(attrs, orgname)
  org.name orgname
  default_org && (a = node&.attr("subdivision")) && !attrs[:subdiv] and
    subdivision(a, node&.attr("subdivision-abbr"), org)
  a = attrs[:subdiv] and subdivision(a, nil, org)
  abbr and org.abbreviation abbr
end

#person_address(node, suffix, xml) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
# File 'lib/metanorma/standoc/front_organisation.rb', line 92

def person_address(node, suffix, xml)
  if node.attr("address#{suffix}")
    xml.address do |ad|
      ad.formattedAddress do |f|
        f << node.attr("address#{suffix}").gsub(/ \+\n/, "<br/>")
      end
    end
  elsif node.attr("country#{suffix}") || node.attr("city#{suffix}")
    person_address_components(node, suffix, xml)
  end
end

#person_address_components(node, suffix, xml) ⇒ Object



104
105
106
107
108
109
110
# File 'lib/metanorma/standoc/front_organisation.rb', line 104

def person_address_components(node, suffix, xml)
  xml.address do |ad|
    %w(street city state country postcode).each do |k|
      s = node.attr("#{k}#{suffix}") and ad.send k, s
    end
  end
end

#person_affiliation(node, _xml, suffix, person) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/metanorma/standoc/front_contributor.rb', line 71

def person_affiliation(node, _xml, suffix, person)
  aff = node.attr("affiliation#{suffix}")
  pos = node.attr("contributor-position#{suffix}")
  (aff || pos) and person.affiliation do |a|
    pos and a.name { |n| n << pos }
    aff and a.organization do |o|
      person_organization(node, suffix, o)
    end
  end
end

#person_credentials(node, _xml, suffix, person) ⇒ Object



66
67
68
69
# File 'lib/metanorma/standoc/front_contributor.rb', line 66

def person_credentials(node, _xml, suffix, person)
  c = node.attr("contributor-credentials#{suffix}") and
    person.credentials c
end

#person_name(node, _xml, suffix, person) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/metanorma/standoc/front_contributor.rb', line 54

def person_name(node, _xml, suffix, person)
  person.name do |n|
    if node.attr("fullname#{suffix}")
      n.completename node.attr("fullname#{suffix}")
    else
      n.forename node.attr("givenname#{suffix}")
      n.initial node.attr("initials#{suffix}")
      n.surname node.attr("surname#{suffix}")
    end
  end
end

#person_org_logo(node, suffix, xml) ⇒ Object



112
113
114
# File 'lib/metanorma/standoc/front_organisation.rb', line 112

def (node, suffix, xml)
  p = node.attr("affiliation_logo#{suffix}") and (xml, p)
end

#person_organization(node, suffix, xml) ⇒ Object



82
83
84
85
86
87
88
89
90
# File 'lib/metanorma/standoc/front_organisation.rb', line 82

def person_organization(node, suffix, xml)
  xml.name node.attr("affiliation#{suffix}")
  abbr = node.attr("affiliation_abbrev#{suffix}") and
    xml.abbreviation abbr
  a = node.attr("affiliation_subdiv#{suffix}") and
    subdivision(a, nil, xml)
  person_address(node, suffix, xml)
  (node, suffix, xml)
end

#personal_author(node, xml) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/metanorma/standoc/front_contributor.rb', line 13

def personal_author(node, xml)
  (node.attr("fullname") || node.attr("surname")) and
    personal_author1(node, xml, "")
  i = 2
  while node.attr("fullname_#{i}") || node.attr("surname_#{i}")
    personal_author1(node, xml, "_#{i}")
    i += 1
  end
end

#personal_author1(node, xml, suffix) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/metanorma/standoc/front_contributor.rb', line 42

def personal_author1(node, xml, suffix)
  xml.contributor do |c|
    personal_role(node, c, suffix)
    c.person do |p|
      person_name(node, xml, suffix, p)
      person_credentials(node, xml, suffix, p)
      person_affiliation(node, xml, suffix, p)
      personal_contact(node, suffix, p)
    end
  end
end

#personal_contact(node, suffix, person) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/metanorma/standoc/front_contributor.rb', line 33

def personal_contact(node, suffix, person)
  node.attr("phone#{suffix}") and person.phone node.attr("phone#{suffix}")
  node.attr("fax#{suffix}") and
    person.phone node.attr("fax#{suffix}"), type: "fax"
  node.attr("email#{suffix}") and person.email node.attr("email#{suffix}")
  node.attr("contributor-uri#{suffix}") and
    person.uri node.attr("contributor-uri#{suffix}")
end

#personal_role(node, contrib, suffix) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/metanorma/standoc/front_contributor.rb', line 23

def personal_role(node, contrib, suffix)
  type = node.attr("role#{suffix}")&.downcase || "author"
  desc = node.attr("role-description#{suffix}")
  contrib.role type: type do |r|
    desc and r.description do |d|
      d << desc
    end
  end
end

#relation_normalise(type) ⇒ Object



131
132
133
134
# File 'lib/metanorma/standoc/front.rb', line 131

def relation_normalise(type)
  type.sub(/-by$/, "By").sub(/-of$/, "Of").sub(/-from$/, "From")
    .sub(/-in$/, "In").sub(/^has-([a-z])/) { "has#{$1.upcase}" }
end

#relaton_relation_descriptionsObject



118
119
120
# File 'lib/metanorma/standoc/front.rb', line 118

def relaton_relation_descriptions
  {}
end

#relaton_relationsObject



114
115
116
# File 'lib/metanorma/standoc/front.rb', line 114

def relaton_relations
  %w(part-of translated-from)
end

#structured_id(node, xml) ⇒ Object



203
# File 'lib/metanorma/standoc/front.rb', line 203

def structured_id(node, xml); end

#subdiv_build(list, org) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/metanorma/standoc/front_organisation.rb', line 57

def subdiv_build(list, org)
  list.empty? and return
  org.subdivision **attr_code(type: list[0][:type]) do |s|
    s.name { |n| n << list[0][:value] }
    subdiv_build(list[1..], s)
    a = list[0][:abbr] and s.abbreviation { |n| n << a }
  end
end

#subdivision(attr, abbr, org) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/metanorma/standoc/front_organisation.rb', line 35

def subdivision(attr, abbr, org)
  abbrs = csv_split(abbr) || []
  subdivs = csv_split(attr, ";")
  subdivs.size == abbrs.size or abbrs = []
  subdivs.each_with_index do |s, i|
    subdivision1(s, abbrs[i], org)
  end
end

#subdivision1(attr, abbr, org) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/metanorma/standoc/front_organisation.rb', line 44

def subdivision1(attr, abbr, org)
  m = csv_split(attr, ",").map do |s1|
    t, v = s1.split(":", 2).map(&:strip)
    if v.nil?
      v = t
      t = nil
    end
    { type: t, value: v }
  end
  abbr and m[0][:abbr] = abbr
  subdiv_build(m, org)
end

#title(node, xml) ⇒ Object



221
222
223
224
# File 'lib/metanorma/standoc/front.rb', line 221

def title(node, xml)
  title_english(node, xml)
  title_otherlangs(node, xml)
end

#title_english(node, xml) ⇒ Object



226
227
228
229
230
231
232
233
234
235
236
# File 'lib/metanorma/standoc/front.rb', line 226

def title_english(node, xml)
  ["en"].each do |lang|
    at = { language: lang, format: "text/plain" }
    xml.title **attr_code(at) do |t|
      title = Metanorma::Utils::asciidoc_sub(
        node.attr("title") || node.attr("title-en") || node.attr("doctitle"),
      )
      t << title
    end
  end
end

#title_otherlangs(node, xml) ⇒ Object



238
239
240
241
242
243
244
# File 'lib/metanorma/standoc/front.rb', line 238

def title_otherlangs(node, xml)
  node.attributes.each do |k, v|
    /^title-(?<titlelang>.+)$/ =~ k or next
    titlelang == "en" and next
    xml.title v, { language: titlelang, format: "text/plain" }
  end
end