metanorma-standoc 1.9.3 → 1.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +3 -13
  3. data/.hound.yml +3 -1
  4. data/.rubocop.yml +4 -6
  5. data/lib/asciidoctor/standoc/base.rb +3 -1
  6. data/lib/asciidoctor/standoc/blocks.rb +1 -1
  7. data/lib/asciidoctor/standoc/cleanup.rb +1 -2
  8. data/lib/asciidoctor/standoc/cleanup_block.rb +0 -1
  9. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +2 -2
  10. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +0 -1
  11. data/lib/asciidoctor/standoc/cleanup_inline.rb +117 -77
  12. data/lib/asciidoctor/standoc/cleanup_maths.rb +0 -1
  13. data/lib/asciidoctor/standoc/cleanup_ref.rb +7 -0
  14. data/lib/asciidoctor/standoc/cleanup_section.rb +13 -81
  15. data/lib/asciidoctor/standoc/cleanup_section_names.rb +75 -0
  16. data/lib/asciidoctor/standoc/cleanup_terms.rb +19 -18
  17. data/lib/asciidoctor/standoc/converter.rb +1 -0
  18. data/lib/asciidoctor/standoc/front.rb +0 -1
  19. data/lib/asciidoctor/standoc/front_contributor.rb +66 -42
  20. data/lib/asciidoctor/standoc/inline.rb +45 -34
  21. data/lib/asciidoctor/standoc/isodoc.rng +65 -7
  22. data/lib/asciidoctor/standoc/macros.rb +7 -5
  23. data/lib/asciidoctor/standoc/macros_plantuml.rb +21 -23
  24. data/lib/asciidoctor/standoc/macros_terms.rb +60 -23
  25. data/lib/asciidoctor/standoc/section.rb +19 -12
  26. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +69 -30
  27. data/lib/asciidoctor/standoc/terms.rb +1 -1
  28. data/lib/asciidoctor/standoc/utils.rb +0 -1
  29. data/lib/asciidoctor/standoc/validate.rb +22 -8
  30. data/lib/isodoc/html/html_titlepage.html +81 -0
  31. data/lib/isodoc/html/htmlstyle.css +983 -0
  32. data/lib/isodoc/html/htmlstyle.scss +714 -0
  33. data/lib/isodoc/html/scripts.html +71 -0
  34. data/lib/metanorma/standoc/processor.rb +16 -7
  35. data/lib/metanorma/standoc/version.rb +1 -1
  36. data/metanorma-standoc.gemspec +2 -2
  37. data/spec/asciidoctor/base_spec.rb +693 -553
  38. data/spec/asciidoctor/blocks_spec.rb +6 -6
  39. data/spec/asciidoctor/cleanup_spec.rb +899 -688
  40. data/spec/asciidoctor/inline_spec.rb +62 -14
  41. data/spec/asciidoctor/isobib_cache_spec.rb +4 -6
  42. data/spec/asciidoctor/lists_spec.rb +147 -135
  43. data/spec/asciidoctor/macros_json2text_spec.rb +1 -1
  44. data/spec/asciidoctor/macros_spec.rb +714 -168
  45. data/spec/asciidoctor/refs_spec.rb +1527 -1532
  46. data/spec/asciidoctor/validate_spec.rb +352 -304
  47. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +51 -51
  48. data/spec/vcr_cassettes/isobib_get_123.yml +14 -14
  49. data/spec/vcr_cassettes/isobib_get_123_1.yml +27 -27
  50. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +36 -36
  51. data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
  52. data/spec/vcr_cassettes/isobib_get_124.yml +13 -13
  53. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  54. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +46 -46
  55. metadata +10 -5
@@ -1,6 +1,5 @@
1
1
  require "nokogiri"
2
2
  require "pathname"
3
- require "open-uri"
4
3
  require "html2doc"
5
4
  require "asciimath2unitsml"
6
5
  require_relative "./cleanup_block"
@@ -149,7 +149,14 @@ module Asciidoctor
149
149
  end
150
150
  end
151
151
 
152
+ def bibitem_nested_id(xmldoc)
153
+ xmldoc.xpath("//bibitem//bibitem").each do |b|
154
+ b.delete("id")
155
+ end
156
+ end
157
+
152
158
  def bibitem_cleanup(xmldoc)
159
+ bibitem_nested_id(xmldoc)
153
160
  ref_dl_cleanup(xmldoc)
154
161
  fetch_local_bibitem(xmldoc)
155
162
  end
@@ -1,22 +1,22 @@
1
1
  require "date"
2
2
  require "htmlentities"
3
3
  require "json"
4
- require "open-uri"
5
4
  require "mathml2asciimath"
5
+ require_relative "cleanup_section_names"
6
6
 
7
7
  module Asciidoctor
8
8
  module Standoc
9
9
  module Cleanup
10
- def make_preface(xml, s)
10
+ def make_preface(xml, sect)
11
11
  if xml.at("//foreword | //introduction | //acknowledgements | "\
12
12
  "//*[@preface]")
13
- preface = s.add_previous_sibling("<preface/>").first
13
+ preface = sect.add_previous_sibling("<preface/>").first
14
14
  f = xml.at("//foreword") and preface.add_child f.remove
15
15
  f = xml.at("//introduction") and preface.add_child f.remove
16
16
  move_clauses_into_preface(xml, preface)
17
17
  f = xml.at("//acknowledgements") and preface.add_child f.remove
18
18
  end
19
- make_abstract(xml, s)
19
+ make_abstract(xml, sect)
20
20
  end
21
21
 
22
22
  def move_clauses_into_preface(xml, preface)
@@ -26,10 +26,10 @@ module Asciidoctor
26
26
  end
27
27
  end
28
28
 
29
- def make_abstract(xml, s)
29
+ def make_abstract(xml, sect)
30
30
  if xml.at("//abstract[not(ancestor::bibitem)]")
31
- preface = s.at("//preface") ||
32
- s.add_previous_sibling("<preface/>").first
31
+ preface = sect.at("//preface") ||
32
+ sect.add_previous_sibling("<preface/>").first
33
33
  abstract = xml.at("//abstract[not(ancestor::bibitem)]").remove
34
34
  preface.prepend_child abstract.remove
35
35
  bibabstract = bibabstract_location(xml)
@@ -53,17 +53,19 @@ module Asciidoctor
53
53
  xml.at("//bibdata/title[not(following-sibling::title)]")
54
54
  end
55
55
 
56
- def make_bibliography(xml, s)
56
+ def make_bibliography(xml, sect)
57
57
  if xml.at("//sections/references")
58
- biblio = s.add_next_sibling("<bibliography/>").first
58
+ biblio = sect.add_next_sibling("<bibliography/>").first
59
59
  xml.xpath("//sections/references").each do |r|
60
60
  biblio.add_child r.remove
61
61
  end
62
62
  end
63
63
  end
64
64
 
65
- def make_indexsect(xml, s)
66
- xml.xpath("//sections/indexsect").reverse_each { |r| s.next = r.remove }
65
+ def make_indexsect(xml, sect)
66
+ xml.xpath("//sections/indexsect").reverse_each do |r|
67
+ sect.next = r.remove
68
+ end
67
69
  end
68
70
 
69
71
  def sections_order_cleanup(xml)
@@ -177,76 +179,6 @@ module Asciidoctor
177
179
  ins.previous = x.remove
178
180
  end
179
181
  end
180
-
181
- def get_or_make_title(node)
182
- unless node.at("./title")
183
- if node.children.empty?
184
- node << "<title/>"
185
- else
186
- node.children.first.previous = "<title/>"
187
- end
188
- end
189
- node.at("./title")
190
- end
191
-
192
- def replace_title(doc, xpath, text, first = false)
193
- return unless text
194
-
195
- doc.xpath(xpath).each_with_index do |node, i|
196
- next if first && !i.zero?
197
-
198
- title = get_or_make_title(node)
199
- fn = title.xpath("./fn")
200
- fn.each(&:remove)
201
- title.content = text
202
- fn.each { |n| title << n }
203
- end
204
- end
205
-
206
- def sections_names_cleanup(xml)
207
- replace_title(xml, "//clause[@type = 'scope']", @i18n&.scope)
208
- replace_title(xml, "//preface//abstract", @i18n&.abstract)
209
- replace_title(xml, "//foreword", @i18n&.foreword)
210
- replace_title(xml, "//introduction", @i18n&.introduction)
211
- replace_title(xml, "//acknowledgements", @i18n&.acknowledgements)
212
- section_names_refs_cleanup(xml)
213
- section_names_terms_cleanup(xml)
214
- end
215
-
216
- def section_names_refs_cleanup(xml)
217
- replace_title(xml, "//references[@normative = 'true']",
218
- @i18n&.normref, true)
219
- replace_title(xml, "//references[@normative = 'false']",
220
- @i18n&.bibliography, true)
221
- end
222
-
223
- NO_SYMABBR = "[.//definitions[not(@type)]]".freeze
224
- SYMABBR = "[.//definitions[@type = 'symbols']]"\
225
- "[.//definitions[@type = 'abbreviated_terms']]".freeze
226
- SYMnoABBR = "[.//definitions[@type = 'symbols']]"\
227
- "[not(.//definitions[@type = 'abbreviated_terms'])]".freeze
228
- ABBRnoSYM = "[.//definitions[@type = 'abbreviated_terms']]"\
229
- "[not(.//definitions[@type = 'symbols'])]".freeze
230
-
231
- def section_names_terms_cleanup(x)
232
- replace_title(x, "//definitions[@type = 'symbols']", @i18n&.symbols)
233
- replace_title(x, "//definitions[@type = 'abbreviated_terms']",
234
- @i18n&.abbrev)
235
- replace_title(x, "//definitions[not(@type)]", @i18n&.symbolsabbrev)
236
- replace_title(x, "//terms#{SYMnoABBR} | //clause[.//terms]#{SYMnoABBR}",
237
- @i18n&.termsdefsymbols, true)
238
- replace_title(x, "//terms#{ABBRnoSYM} | //clause[.//terms]#{ABBRnoSYM}",
239
- @i18n&.termsdefabbrev, true)
240
- replace_title(x, "//terms#{SYMABBR} | //clause[.//terms]#{SYMABBR}",
241
- @i18n&.termsdefsymbolsabbrev, true)
242
- replace_title(x, "//terms#{NO_SYMABBR} | //clause[.//terms]#{NO_SYMABBR}",
243
- @i18n&.termsdefsymbolsabbrev, true)
244
- replace_title(
245
- x,
246
- "//terms[not(.//definitions)] | //clause[.//terms][not(.//definitions)]",
247
- @i18n&.termsdef, true
248
- )
249
- end
250
182
  end
251
183
  end
252
184
  end
@@ -0,0 +1,75 @@
1
+ module Asciidoctor
2
+ module Standoc
3
+ module Cleanup
4
+ def get_or_make_title(node)
5
+ unless node.at("./title")
6
+ if node.children.empty?
7
+ node << "<title/>"
8
+ else
9
+ node.children.first.previous = "<title/>"
10
+ end
11
+ end
12
+ node.at("./title")
13
+ end
14
+
15
+ def replace_title(doc, xpath, text, first = false)
16
+ return unless text
17
+
18
+ doc.xpath(xpath).each_with_index do |node, i|
19
+ next if first && !i.zero?
20
+
21
+ title = get_or_make_title(node)
22
+ fn = title.xpath("./fn")
23
+ fn.each(&:remove)
24
+ title.content = text
25
+ fn.each { |n| title << n }
26
+ end
27
+ end
28
+
29
+ def sections_names_cleanup(xml)
30
+ replace_title(xml, "//clause[@type = 'scope']", @i18n&.scope)
31
+ replace_title(xml, "//preface//abstract", @i18n&.abstract)
32
+ replace_title(xml, "//foreword", @i18n&.foreword)
33
+ replace_title(xml, "//introduction", @i18n&.introduction)
34
+ replace_title(xml, "//acknowledgements", @i18n&.acknowledgements)
35
+ section_names_refs_cleanup(xml)
36
+ section_names_terms_cleanup(xml)
37
+ end
38
+
39
+ def section_names_refs_cleanup(xml)
40
+ replace_title(xml, "//references[@normative = 'true']",
41
+ @i18n&.normref, true)
42
+ replace_title(xml, "//references[@normative = 'false']",
43
+ @i18n&.bibliography, true)
44
+ end
45
+
46
+ NO_SYMABBR = "[.//definitions[not(@type)]]".freeze
47
+ SYMABBR = "[.//definitions[@type = 'symbols']]"\
48
+ "[.//definitions[@type = 'abbreviated_terms']]".freeze
49
+ SYMnoABBR = "[.//definitions[@type = 'symbols']]"\
50
+ "[not(.//definitions[@type = 'abbreviated_terms'])]".freeze
51
+ ABBRnoSYM = "[.//definitions[@type = 'abbreviated_terms']]"\
52
+ "[not(.//definitions[@type = 'symbols'])]".freeze
53
+
54
+ def section_names_terms_cleanup(x)
55
+ replace_title(x, "//definitions[@type = 'symbols']", @i18n&.symbols)
56
+ replace_title(x, "//definitions[@type = 'abbreviated_terms']",
57
+ @i18n&.abbrev)
58
+ replace_title(x, "//definitions[not(@type)]", @i18n&.symbolsabbrev)
59
+ replace_title(x, "//terms#{SYMnoABBR} | //clause[.//terms]#{SYMnoABBR}",
60
+ @i18n&.termsdefsymbols, true)
61
+ replace_title(x, "//terms#{ABBRnoSYM} | //clause[.//terms]#{ABBRnoSYM}",
62
+ @i18n&.termsdefabbrev, true)
63
+ replace_title(x, "//terms#{SYMABBR} | //clause[.//terms]#{SYMABBR}",
64
+ @i18n&.termsdefsymbolsabbrev, true)
65
+ replace_title(x, "//terms#{NO_SYMABBR} | //clause[.//terms]#{NO_SYMABBR}",
66
+ @i18n&.termsdefsymbolsabbrev, true)
67
+ replace_title(
68
+ x,
69
+ "//terms[not(.//definitions)] | //clause[.//terms][not(.//definitions)]",
70
+ @i18n&.termsdef, true
71
+ )
72
+ end
73
+ end
74
+ end
75
+ end
@@ -60,15 +60,15 @@ module Asciidoctor
60
60
 
61
61
  def term_children_cleanup(xmldoc)
62
62
  xmldoc.xpath("//term").each do |t|
63
- t.xpath("./termnote").each { |n| t << n.remove }
64
- t.xpath("./termexample").each { |n| t << n.remove }
65
- t.xpath("./termsource").each { |n| t << n.remove }
63
+ %w(termnote termexample termsource).each do |w|
64
+ t.xpath("./#{w}").each { |n| t << n.remove }
65
+ end
66
66
  end
67
- end
67
+ end
68
68
 
69
69
  def termdef_from_termbase(xmldoc)
70
70
  xmldoc.xpath("//term").each do |x|
71
- if c = x.at("./origin/termref") and !x.at("./definition")
71
+ if (c = x.at("./origin/termref")) && !x.at("./definition")
72
72
  x.at("./origin").previous = fetch_termbase(c["base"], c.text)
73
73
  end
74
74
  end
@@ -93,33 +93,34 @@ module Asciidoctor
93
93
  termdomain1_cleanup(xmldoc)
94
94
  termnote_example_cleanup(xmldoc)
95
95
  termdef_subclause_cleanup(xmldoc)
96
- term_children_cleanup(xmldoc)
96
+ term_children_cleanup(xmldoc)
97
97
  termdocsource_cleanup(xmldoc)
98
- end
98
+ end
99
99
 
100
100
  # Indices sort after letter but before any following
101
101
  # letter (x, x_m, x_1, xa); we use colon to force that sort order.
102
102
  # Numbers sort *after* letters; we use thorn to force that sort order.
103
- def symbol_key(x)
104
- key = x.dup
103
+ def symbol_key(sym)
104
+ key = sym.dup
105
105
  key.traverse do |n|
106
106
  next unless n.name == "math"
107
+
107
108
  n.replace(grkletters(MathML2AsciiMath.m2a(n.to_xml)))
108
109
  end
109
110
  ret = Nokogiri::XML(key.to_xml)
110
- HTMLEntities.new.decode(ret.text.downcase).
111
- gsub(/[\[\]\{\}<>\(\)]/, "").gsub(/\s/m, "").
112
- gsub(/[[:punct:]]|[_^]/, ":\\0").gsub(/`/, "").
113
- gsub(/[0-9]+/, "þ\\0")
111
+ HTMLEntities.new.decode(ret.text.downcase)
112
+ .gsub(/[\[\]{}<>()]/, "").gsub(/\s/m, "")
113
+ .gsub(/[[:punct:]]|[_^]/, ":\\0").gsub(/`/, "")
114
+ .gsub(/[0-9]+/, "þ\\0")
114
115
  end
115
-
116
+
116
117
  def grkletters(x)
117
118
  x.gsub(/\b(alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\b/i, "&\\1;")
118
119
  end
119
120
 
120
- def extract_symbols_list(dl)
121
+ def extract_symbols_list(dlist)
121
122
  dl_out = []
122
- dl.xpath("./dt | ./dd").each do |dtd|
123
+ dlist.xpath("./dt | ./dd").each do |dtd|
123
124
  if dtd.name == "dt"
124
125
  dl_out << { dt: dtd.remove, key: symbol_key(dtd) }
125
126
  else
@@ -128,7 +129,7 @@ module Asciidoctor
128
129
  end
129
130
  dl_out
130
131
  end
131
-
132
+
132
133
  def symbols_cleanup(docxml)
133
134
  docxml.xpath("//definitions/dl").each do |dl|
134
135
  dl_out = extract_symbols_list(dl)
@@ -136,7 +137,7 @@ module Asciidoctor
136
137
  dl.children = dl_out.map { |d| d[:dt].to_s + d[:dd].to_s }.join("\n")
137
138
  end
138
139
  docxml
139
- end
140
+ end
140
141
  end
141
142
  end
142
143
  end
@@ -37,6 +37,7 @@ module Asciidoctor
37
37
  inline_macro Asciidoctor::Standoc::VariantInlineMacro
38
38
  inline_macro Asciidoctor::Standoc::FootnoteBlockInlineMacro
39
39
  inline_macro Asciidoctor::Standoc::TermRefInlineMacro
40
+ inline_macro Asciidoctor::Standoc::SymbolRefInlineMacro
40
41
  inline_macro Asciidoctor::Standoc::IndexXrefInlineMacro
41
42
  inline_macro Asciidoctor::Standoc::IndexRangeInlineMacro
42
43
  inline_macro Asciidoctor::Standoc::AddMacro
@@ -2,7 +2,6 @@ require "date"
2
2
  require "nokogiri"
3
3
  require "htmlentities"
4
4
  require "pathname"
5
- require "open-uri"
6
5
  require_relative "./front_contributor"
7
6
 
8
7
  module Asciidoctor
@@ -2,7 +2,6 @@ require "date"
2
2
  require "nokogiri"
3
3
  require "htmlentities"
4
4
  require "pathname"
5
- require "open-uri"
6
5
  require "csv"
7
6
 
8
7
  module Asciidoctor
@@ -10,13 +9,13 @@ module Asciidoctor
10
9
  module Front
11
10
  def committee_component(compname, node, out)
12
11
  out.send compname.gsub(/-/, "_"), node.attr(compname),
13
- **attr_code(number: node.attr("#{compname}-number"),
14
- type: node.attr("#{compname}-type"))
12
+ **attr_code(number: node.attr("#{compname}-number"),
13
+ type: node.attr("#{compname}-type"))
15
14
  i = 2
16
- while node.attr(compname+"_#{i}") do
17
- out.send compname.gsub(/-/, "_"), node.attr(compname+"_#{i}"),
18
- **attr_code(number: node.attr("#{compname}-number_#{i}"),
19
- type: node.attr("#{compname}-type_#{i}"))
15
+ while node.attr(compname + "_#{i}")
16
+ out.send compname.gsub(/-/, "_"), node.attr(compname + "_#{i}"),
17
+ **attr_code(number: node.attr("#{compname}-number_#{i}"),
18
+ type: node.attr("#{compname}-type_#{i}"))
20
19
  i += 1
21
20
  end
22
21
  end
@@ -32,34 +31,36 @@ module Asciidoctor
32
31
  is_pub && node and org_address(node, org)
33
32
  end
34
33
 
35
- def org_address(node, p)
36
- node.attr("pub-address") and p.address do |ad|
34
+ def org_address(node, person)
35
+ node.attr("pub-address") and person.address do |ad|
37
36
  ad.formattedAddress do |f|
38
37
  f << node.attr("pub-address").gsub(/ \+\n/, "<br/>")
39
38
  end
40
39
  end
41
- node.attr("pub-phone") and p.phone node.attr("pub-phone")
42
- node.attr("pub-fax") and p.phone node.attr("pub-fax"), **{type: "fax"}
43
- node.attr("pub-email") and p.email node.attr("pub-email")
44
- node.attr("pub-uri") and p.uri node.attr("pub-uri")
40
+ node.attr("pub-phone") and person.phone node.attr("pub-phone")
41
+ node.attr("pub-fax") and
42
+ person.phone node.attr("pub-fax"), **{ type: "fax" }
43
+ node.attr("pub-email") and person.email node.attr("pub-email")
44
+ node.attr("pub-uri") and person.uri node.attr("pub-uri")
45
45
  end
46
46
 
47
47
  # , " => ," : CSV definition does not deal with space followed by quote
48
48
  # at start of field
49
- def csv_split(s, delim = ";")
50
- return if s.nil?
51
- CSV.parse_line(s&.gsub(/#{delim} "(?!")/, "#{delim}\""),
49
+ def csv_split(text, delim = ";")
50
+ return if text.nil?
51
+
52
+ CSV.parse_line(text&.gsub(/#{delim} "(?!")/, "#{delim}\""),
52
53
  liberal_parsing: true,
53
- col_sep: delim)&.compact&.map { |x| x.strip }
54
+ col_sep: delim)&.compact&.map(&:strip)
54
55
  end
55
56
 
56
57
  def metadata_author(node, xml)
57
- csv_split(node.attr("publisher") || default_publisher || "")&.
58
- each do |p|
58
+ csv_split(node.attr("publisher") || default_publisher || "")
59
+ &.each do |p|
59
60
  xml.contributor do |c|
60
61
  c.role **{ type: "author" }
61
62
  c.organization do |a|
62
- organization(a, p, false, node, !node.attr("publisher"))
63
+ organization(a, p, false, node, !node.attr("publisher"))
63
64
  end
64
65
  end
65
66
  end
@@ -76,17 +77,18 @@ module Asciidoctor
76
77
  end
77
78
  end
78
79
 
79
- def personal_role(node, c, suffix)
80
- c.role **{ type: node.attr("role#{suffix}")&.downcase || "author" }
80
+ def personal_role(node, contrib, suffix)
81
+ type = node.attr("role#{suffix}")&.downcase || "author"
82
+ contrib.role **{ type: type }
81
83
  end
82
84
 
83
- def personal_contact(node, suffix, p)
84
- node.attr("phone#{suffix}") and p.phone node.attr("phone#{suffix}")
85
+ def personal_contact(node, suffix, person)
86
+ node.attr("phone#{suffix}") and person.phone node.attr("phone#{suffix}")
85
87
  node.attr("fax#{suffix}") and
86
- p.phone node.attr("fax#{suffix}"), **{type: "fax"}
87
- node.attr("email#{suffix}") and p.email node.attr("email#{suffix}")
88
+ person.phone node.attr("fax#{suffix}"), **{ type: "fax" }
89
+ node.attr("email#{suffix}") and person.email node.attr("email#{suffix}")
88
90
  node.attr("contributor-uri#{suffix}") and
89
- p.uri node.attr("contributor-uri#{suffix}")
91
+ person.uri node.attr("contributor-uri#{suffix}")
90
92
  end
91
93
 
92
94
  def personal_author1(node, xml, suffix)
@@ -100,8 +102,8 @@ module Asciidoctor
100
102
  end
101
103
  end
102
104
 
103
- def person_name(node, xml, suffix, p)
104
- p.name do |n|
105
+ def person_name(node, _xml, suffix, person)
106
+ person.name do |n|
105
107
  if node.attr("fullname#{suffix}")
106
108
  n.completename node.attr("fullname#{suffix}")
107
109
  else
@@ -112,21 +114,43 @@ module Asciidoctor
112
114
  end
113
115
  end
114
116
 
115
- def person_affiliation(node, xml, suffix, p)
116
- node.attr("affiliation#{suffix}") and p.affiliation do |a|
117
+ def person_affiliation(node, _xml, suffix, person)
118
+ node.attr("affiliation#{suffix}") and person.affiliation do |a|
117
119
  a.organization do |o|
118
- o.name node.attr("affiliation#{suffix}")
119
- a = node.attr("affiliation_subdiv#{suffix}")
120
- abbr = node.attr("affiliation_abbrev#{suffix}") and o.abbreviation abbr
121
- csv_split(node.attr("affiliation_subdiv#{suffix}"))&.each do |s|
122
- o.subdivision s
123
- end
124
- node.attr("address#{suffix}") and o.address do |ad|
125
- ad.formattedAddress do |f|
126
- f << node.attr("address#{suffix}").gsub(/ \+\n/, "<br/>")
127
- end
120
+ person_organization(node, suffix, o)
121
+ end
122
+ end
123
+ end
124
+
125
+ def person_organization(node, suffix, xml)
126
+ xml.name node.attr("affiliation#{suffix}")
127
+ abbr = node.attr("affiliation_abbrev#{suffix}") and
128
+ xml.abbreviation abbr
129
+ csv_split(node.attr("affiliation_subdiv#{suffix}"))&.each do |s|
130
+ xml.subdivision s
131
+ end
132
+ person_address(node, suffix, xml)
133
+ end
134
+
135
+ def person_address(node, suffix, xml)
136
+ if node.attr("address#{suffix}")
137
+ xml.address do |ad|
138
+ ad.formattedAddress do |f|
139
+ f << node.attr("address#{suffix}").gsub(/ \+\n/, "<br/>")
128
140
  end
129
141
  end
142
+ elsif node.attr("country#{suffix}") || node.attr("city#{suffix}")
143
+ person_address_components(node, suffix, xml)
144
+ end
145
+ end
146
+
147
+ def person_address_components(node, suffix, xml)
148
+ xml.address do |ad|
149
+ s = node.attr("street#{suffix}") and ad.street s
150
+ s = node.attr("city#{suffix}") and ad.city s
151
+ s = node.attr("state#{suffix}") and ad.state s
152
+ s = node.attr("country#{suffix}") and ad.country s
153
+ s = node.attr("postcode#{suffix}") and ad.postcode s
130
154
  end
131
155
  end
132
156
 
@@ -135,7 +159,7 @@ module Asciidoctor
135
159
  end
136
160
 
137
161
  def org_abbrev
138
- { }
162
+ {}
139
163
  end
140
164
 
141
165
  def metadata_publisher(node, xml)