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
- #committee_component(compname, node, out) ⇒ Object
- #copyright_parse(node) ⇒ Object
- #datetypes ⇒ Object
- #default_publisher ⇒ Object
- #extract_org_attrs_address(node, opts, suffix) ⇒ Object
- #extract_org_attrs_complex(node, opts, source, suffix) ⇒ Object
- #metadata(node, xml) ⇒ Object
- #metadata_author(node, xml) ⇒ Object
- #metadata_classifications(node, xml) ⇒ Object
- #metadata_committee(node, xml) ⇒ Object
- #metadata_copyright(node, xml) ⇒ Object
- #metadata_date(node, xml) ⇒ Object
- #metadata_date1(node, xml, type) ⇒ Object
- #metadata_doctype(node, xml) ⇒ Object
- #metadata_ext(node, ext) ⇒ Object
- #metadata_getrelation(node, xml, type, desc = nil) ⇒ Object
- #metadata_getrelation1(doc, xml, type, desc) ⇒ Object
- #metadata_ics(node, xml) ⇒ Object
- #metadata_id(node, xml) ⇒ Object
- #metadata_id_build(node) ⇒ Object
- #metadata_keywords(node, xml) ⇒ Object
- #metadata_language(node, xml) ⇒ Object
- #metadata_note(node, xml) ⇒ Object
- #metadata_other_id(node, xml) ⇒ Object
- #metadata_publisher(node, xml) ⇒ Object
- #metadata_relations(node, xml) ⇒ Object
- #metadata_script(node, xml) ⇒ Object
- #metadata_series(node, xml) ⇒ Object
- #metadata_source(node, xml) ⇒ Object
- #metadata_sponsor(node, xml) ⇒ Object
- #metadata_status(node, xml) ⇒ Object
- #metadata_subdoctype(node, xml) ⇒ Object
- #metadata_version(node, xml) ⇒ Object
- #org_abbrev ⇒ Object
- #org_address(org, xml) ⇒ Object
- #org_attrs_complex_parse(node, opts, source) ⇒ Object
- #org_attrs_parse(node, opts) ⇒ Object
- #org_attrs_simple_parse(node, opts, source) ⇒ Object
- #org_attrs_simple_parse_no_source(node, opts) ⇒ Object
- #org_contact(org, xml) ⇒ Object
- #org_contributor(node, xml, opts) ⇒ Object
- #org_contributor_role(xml, org) ⇒ Object
- #org_logo(xml, logo) ⇒ Object
- #org_organization(node, xml, org) ⇒ Object
- #organization(org, orgname, node = nil, default_org = nil, attrs = {}) ⇒ Object
- #person_address(node, suffix, xml) ⇒ Object
- #person_address_components(node, suffix, xml) ⇒ Object
- #person_affiliation(node, _xml, suffix, person) ⇒ Object
- #person_credentials(node, _xml, suffix, person) ⇒ Object
- #person_name(node, _xml, suffix, person) ⇒ Object
- #person_org_logo(node, suffix, xml) ⇒ Object
- #person_organization(node, suffix, xml) ⇒ Object
- #personal_author(node, xml) ⇒ Object
- #personal_author1(node, xml, suffix) ⇒ Object
- #personal_contact(node, suffix, person) ⇒ Object
- #personal_role(node, contrib, suffix) ⇒ Object
- #relation_normalise(type) ⇒ Object
- #relaton_relation_descriptions ⇒ Object
- #relaton_relations ⇒ Object
- #subdiv_build(list, org) ⇒ Object
- #subdivision(attr, abbr, org) ⇒ Object
- #subdivision1(attr, abbr, org) ⇒ Object
- #title(node, xml) ⇒ Object
- #title_english(node, xml) ⇒ Object
- #title_otherlangs(node, xml) ⇒ Object
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 |
#copyright_parse(node) ⇒ Object
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 |
#datetypes ⇒ Object
82 83 84 85 86 |
# File 'lib/metanorma/standoc/front.rb', line 82 def datetypes %w{ published accessed created implemented obsoleted confirmed updated corrected issued circulated unchanged received vote-started vote-ended announced } end |
#default_publisher ⇒ Object
114 115 116 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 114 def default_publisher nil end |
#extract_org_attrs_address(node, opts, suffix) ⇒ Object
189 190 191 192 193 194 195 196 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 189 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
181 182 183 184 185 186 187 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 181 def extract_org_attrs_complex(node, opts, source, suffix) { name: node.attr(source + 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
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/metanorma/standoc/front.rb', line 165 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 }) (node, xml) end |
#metadata_classifications(node, xml) ⇒ Object
157 158 159 160 161 162 163 |
# File 'lib/metanorma/standoc/front.rb', line 157 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
50 51 52 53 54 55 |
# File 'lib/metanorma/standoc/front.rb', line 50 def (node, xml) node.attr("technical-committee") or return xml.editorialgroup do |a| committee_component("technical-committee", node, a) end end |
#metadata_copyright(node, xml) ⇒ Object
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_date(node, xml) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/metanorma/standoc/front.rb', line 88 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:) do |d| d.on date end end end |
#metadata_date1(node, xml, type) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/metanorma/standoc/front.rb', line 75 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
196 197 198 |
# File 'lib/metanorma/standoc/front.rb', line 196 def (node, xml) xml.doctype doctype(node) end |
#metadata_ext(node, ext) ⇒ Object
189 190 191 192 193 194 |
# File 'lib/metanorma/standoc/front.rb', line 189 def (node, ext) (node, ext) (node, ext) (node, ext) (node, ext) end |
#metadata_getrelation(node, xml, type, desc = nil) ⇒ Object
132 133 134 135 136 137 |
# File 'lib/metanorma/standoc/front.rb', line 132 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
139 140 141 142 143 144 145 146 147 148 |
# File 'lib/metanorma/standoc/front.rb', line 139 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
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/metanorma/standoc/front.rb', line 57 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
11 12 13 14 |
# File 'lib/metanorma/standoc/front.rb', line 11 def (node, xml) id = node.attr("docidentifier") || (node) xml.docidentifier id, primary: "true" end |
#metadata_id_build(node) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/metanorma/standoc/front.rb', line 16 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
150 151 152 153 154 155 |
# File 'lib/metanorma/standoc/front.rb', line 150 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
100 101 102 103 |
# File 'lib/metanorma/standoc/front.rb', line 100 def (node, xml) xml.language (node.attr("language") || "en") l = node.attr("locale") and xml.locale l end |
#metadata_note(node, xml) ⇒ Object
204 |
# File 'lib/metanorma/standoc/front.rb', line 204 def (node, xml); end |
#metadata_other_id(node, xml) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/metanorma/standoc/front.rb', line 24 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
118 119 120 121 122 123 124 125 |
# File 'lib/metanorma/standoc/front.rb', line 118 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
105 106 107 108 |
# File 'lib/metanorma/standoc/front.rb', line 105 def (node, xml) xml.script (node.attr("script") || Metanorma::Utils.default_script(node.attr("language"))) end |
#metadata_series(node, xml) ⇒ Object
206 |
# File 'lib/metanorma/standoc/front.rb', line 206 def (node, xml); end |
#metadata_source(node, xml) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/metanorma/standoc/front.rb', line 68 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
42 43 44 45 46 47 48 |
# File 'lib/metanorma/standoc/front.rb', line 42 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
200 201 202 |
# File 'lib/metanorma/standoc/front.rb', line 200 def (node, xml) s = node.attr("docsubtype") and xml.subdoctype s end |
#metadata_version(node, xml) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/metanorma/standoc/front.rb', line 34 def (node, xml) 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 node.attr("draft") if node.attr("draft") end end |
#org_abbrev ⇒ Object
118 119 120 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 118 def org_abbrev {} end |
#org_address(org, xml) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 58 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
169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 169 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
147 148 149 150 151 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 147 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
153 154 155 156 157 158 159 160 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 153 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
162 163 164 165 166 167 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 162 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
67 68 69 70 71 72 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 67 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
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 122 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
133 134 135 136 137 138 139 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 133 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
108 109 110 111 112 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 108 def org_logo(xml, logo) logo and xml.logo do |l| l.image src: logo end end |
#org_organization(node, xml, org) ⇒ Object
141 142 143 144 145 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 141 def org_organization(node, xml, org) organization(xml, org[:name], node, !node.attr("publisher"), org) org_address(org, xml) org_logo(xml, org[:logo]) end |
#organization(org, orgname, node = nil, default_org = nil, attrs = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 16 def organization(org, orgname, node = nil, default_org = nil, attrs = {}) abbrevs = org_abbrev n = abbrevs.invert[orgname] and orgname = n 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 = org_abbrev[orgname] abbr and org.abbreviation abbr end |
#person_address(node, suffix, xml) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 84 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
96 97 98 99 100 101 102 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 96 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
104 105 106 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 104 def person_org_logo(node, suffix, xml) p = node.attr("affiliation_logo#{suffix}") and org_logo(xml, p) end |
#person_organization(node, suffix, xml) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 74 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) person_org_logo(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 (node, xml) (node.attr("fullname") || node.attr("surname")) and (node, xml, "") i = 2 while node.attr("fullname_#{i}") || node.attr("surname_#{i}") (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 (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
127 128 129 130 |
# File 'lib/metanorma/standoc/front.rb', line 127 def relation_normalise(type) type.sub(/-by$/, "By").sub(/-of$/, "Of").sub(/-from$/, "From") .sub(/-in$/, "In") end |
#relaton_relation_descriptions ⇒ Object
114 115 116 |
# File 'lib/metanorma/standoc/front.rb', line 114 def relaton_relation_descriptions {} end |
#relaton_relations ⇒ Object
110 111 112 |
# File 'lib/metanorma/standoc/front.rb', line 110 def relaton_relations %w(part-of translated-from) end |
#subdiv_build(list, org) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 49 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..-1], s) a = list[0][:abbr] and s.abbreviation { |n| n << a } end end |
#subdivision(attr, abbr, org) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 27 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
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/metanorma/standoc/front_organisation.rb', line 36 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
208 209 210 211 |
# File 'lib/metanorma/standoc/front.rb', line 208 def title(node, xml) title_english(node, xml) title_otherlangs(node, xml) end |
#title_english(node, xml) ⇒ Object
213 214 215 216 217 218 219 220 221 222 |
# File 'lib/metanorma/standoc/front.rb', line 213 def title_english(node, xml) ["en"].each do |lang| at = { language: lang, format: "text/plain" } xml.title **attr_code(at) do |t| t << (Metanorma::Utils::asciidoc_sub(node.attr("title") || node.attr("title-en")) || node.title) end end end |
#title_otherlangs(node, xml) ⇒ Object
224 225 226 227 228 229 230 |
# File 'lib/metanorma/standoc/front.rb', line 224 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 |