metanorma-standoc 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +11 -0
  3. data/lib/asciidoctor/standoc/cleanup_ref.rb +1 -1
  4. data/lib/asciidoctor/standoc/converter.rb +2 -2
  5. data/lib/asciidoctor/standoc/front.rb +3 -3
  6. data/lib/asciidoctor/standoc/front_contributor.rb +34 -10
  7. data/lib/asciidoctor/standoc/isodoc.rng +0 -1
  8. data/lib/asciidoctor/standoc/macros.rb +1 -2
  9. data/lib/asciidoctor/standoc/ref.rb +9 -15
  10. data/lib/asciidoctor/standoc/ref_sect.rb +12 -5
  11. data/lib/asciidoctor/standoc/section.rb +5 -9
  12. data/lib/liquid/custom_blocks/with_json_nested_context.rb +18 -0
  13. data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +19 -0
  14. data/lib/metanorma/standoc/version.rb +1 -1
  15. data/metanorma-standoc.gemspec +2 -1
  16. data/spec/asciidoctor-standoc/base_spec.rb +123 -8
  17. data/spec/asciidoctor-standoc/cleanup_spec.rb +37 -0
  18. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +6 -22
  19. data/spec/asciidoctor-standoc/macros_json2text_spec.rb +1 -1
  20. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +1 -1
  21. data/spec/asciidoctor-standoc/refs_dl_spec.rb +2 -2
  22. data/spec/asciidoctor-standoc/refs_spec.rb +248 -46
  23. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +156 -4
  24. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +155 -155
  25. data/spec/vcr_cassettes/isobib_get_123.yml +10 -56
  26. data/spec/vcr_cassettes/isobib_get_123_1.yml +92 -92
  27. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +361 -0
  28. data/spec/vcr_cassettes/isobib_get_123_2001.yml +45 -45
  29. data/spec/vcr_cassettes/isobib_get_124.yml +45 -45
  30. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  31. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +36 -36
  32. metadata +21 -7
  33. data/lib/asciidoctor/standoc/base_structured_text_preprocessor.rb +0 -123
  34. data/lib/asciidoctor/standoc/json2_text_preprocessor.rb +0 -44
  35. data/lib/asciidoctor/standoc/yaml2_text_preprocessor.rb +0 -46
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a619338025bf24d56d382fde0bfcd3d7c5f2e5ecf5520d995d8c7d4986cb67d
4
- data.tar.gz: 1f8c10a80a5ada1b94c6216568eb11851fd081c9ae63bae2d8b9e3e080673b17
3
+ metadata.gz: 11adce8b2fe42f3e2b4db51088b5818f5cff207a62cc19e33b27cf5a53160c47
4
+ data.tar.gz: 17967efeb1bc5c518a9498ec8329d7ae0fb6c77cb19bb911527aa15efd2f0881
5
5
  SHA512:
6
- metadata.gz: 5d9fea4687d265c36099b30faa69893c10ec011e7d1a8b7e32b4e0df4ef9d892e5efe90bb8bd0767f51f3ec74f91b05dc3613532eeff247f1a2039b6094f15dc
7
- data.tar.gz: 2ccb181da62a4ca659c2f3915ffdbebbc88b501c97938244d65d780b241e05bd2f61870ac32cc8a3cef739ac7a36b8c714f2cc5027d9269e78c7e6f6bcabb12c
6
+ metadata.gz: 6bef6b7fb5db91fd23d039a2e01d69685ba049b3ef34ebb2c4eaafa2e144b54c6c948b1c0a91796b700c2c18494c048d79d71b21fe58e1437f994a296d950785
7
+ data.tar.gz: 6c4d35c69f213280a58dd8b5e53da18c4947cc5de3210397f35f19726dbcceb2a3ea4f26066f86ee2fca2e0d0a37d9941e6cb092a7625d557dfba25eb4367812
@@ -72,7 +72,18 @@ module Asciidoctor
72
72
  end
73
73
  end
74
74
 
75
+ def title_footnote_move(xmldoc)
76
+ ins = xmldoc.at("//bibdata/language")
77
+ xmldoc.xpath("//bibdata/title//fn").each do |f|
78
+ f.name = "note"
79
+ f["type"] = "title-footnote"
80
+ f.delete("reference")
81
+ ins.previous = f.remove
82
+ end
83
+ end
84
+
75
85
  def footnote_cleanup(xmldoc)
86
+ title_footnote_move(xmldoc)
76
87
  table_footnote_renumber(xmldoc)
77
88
  other_footnote_renumber(xmldoc)
78
89
  xmldoc.xpath("//fn").each do |fn|
@@ -126,7 +126,7 @@ module Asciidoctor
126
126
  bibitemxml = RelatonBib::BibliographicItem.new(
127
127
  RelatonBib::HashConverter::hash_to_bib(bib)).to_xml or next
128
128
  bibitem = Nokogiri::XML(bibitemxml)
129
- bibitem["id"] = c["id"] if c["id"]
129
+ bibitem.root["id"] = c["id"] if c["id"] && !/^_/.match(c["id"])
130
130
  c.replace(bibitem.root)
131
131
  end
132
132
  end
@@ -23,8 +23,8 @@ module Asciidoctor
23
23
  Asciidoctor::Extensions.register do
24
24
  preprocessor Asciidoctor::Standoc::Datamodel::AttributesTablePreprocessor
25
25
  preprocessor Asciidoctor::Standoc::Datamodel::DiagramPreprocessor
26
- preprocessor Asciidoctor::Standoc::Yaml2TextPreprocessor
27
- preprocessor Asciidoctor::Standoc::Json2TextPreprocessor
26
+ preprocessor Metanorma::Plugin::Datastruct::Json2TextPreprocessor
27
+ preprocessor Metanorma::Plugin::Datastruct::Yaml2TextPreprocessor
28
28
  inline_macro Asciidoctor::Standoc::AltTermInlineMacro
29
29
  inline_macro Asciidoctor::Standoc::DeprecatedTermInlineMacro
30
30
  inline_macro Asciidoctor::Standoc::DomainTermInlineMacro
@@ -27,7 +27,7 @@ module Asciidoctor
27
27
 
28
28
  def metadata_status(node, xml)
29
29
  xml.status do |s|
30
- s.stage ( node.attr("status") || node.attr("docstage") || "published" )
30
+ s.stage (node.attr("status") || node.attr("docstage") || "published")
31
31
  node.attr("docsubstage") and s.substage node.attr("docsubstage")
32
32
  node.attr("iteration") and s.iteration node.attr("iteration")
33
33
  end
@@ -180,8 +180,8 @@ module Asciidoctor
180
180
  ["en"].each do |lang|
181
181
  at = { language: lang, format: "text/plain" }
182
182
  xml.title **attr_code(at) do |t|
183
- t << (Utils::asciidoc_sub(node.attr("title") || node.attr("title-en")) ||
184
- node.title)
183
+ t << (Utils::asciidoc_sub(node.attr("title") ||
184
+ node.attr("title-en")) || node.title)
185
185
  end
186
186
  end
187
187
  end
@@ -21,11 +21,27 @@ module Asciidoctor
21
21
  end
22
22
  end
23
23
 
24
- def organization(org, orgname)
24
+ def organization(org, orgname, node = nil, default_org = nil)
25
25
  abbrevs = org_abbrev
26
26
  n = abbrevs.invert[orgname] and orgname = n
27
27
  org.name orgname
28
- a = org_abbrev[orgname] and org.abbreviation a
28
+ default_org and a = node.attr("subdivision") and org.subdivision a
29
+ abbr = org_abbrev[orgname]
30
+ default_org && b = node.attr("subdivision-abbr") and abbr = b
31
+ abbr and org.abbreviation abbr
32
+ default_org and org_address(node, org)
33
+ end
34
+
35
+ def org_address(node, p)
36
+ node.attr("pub-address") and p.address do |ad|
37
+ ad.formattedAddress do |f|
38
+ f << node.attr("pub-address").gsub(/ \+\n/, "<br/>")
39
+ end
40
+ 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")
29
45
  end
30
46
 
31
47
  # , " => ," : CSV definition does not deal with space followed by quote
@@ -37,10 +53,13 @@ module Asciidoctor
37
53
  end
38
54
 
39
55
  def metadata_author(node, xml)
40
- csv_split(node.attr("publisher") || default_publisher || "")&.each do |p|
56
+ csv_split(node.attr("publisher") || default_publisher || "")&.
57
+ each do |p|
41
58
  xml.contributor do |c|
42
59
  c.role **{ type: "author" }
43
- c.organization { |a| organization(a, p) }
60
+ c.organization do |a|
61
+ organization(a, p, node, !node.attr("publisher"))
62
+ end
44
63
  end
45
64
  end
46
65
  personal_author(node, xml)
@@ -99,7 +118,9 @@ module Asciidoctor
99
118
  abbr = node.attr("affiliation_abbrev#{suffix}") and
100
119
  o.abbreviation abbr
101
120
  node.attr("address#{suffix}") and o.address do |ad|
102
- ad.formattedAddress node.attr("address#{suffix}")
121
+ ad.formattedAddress do |f|
122
+ f << node.attr("address#{suffix}").gsub(/ \+\n/, "<br/>")
123
+ end
103
124
  end
104
125
  end
105
126
  end
@@ -118,19 +139,22 @@ module Asciidoctor
118
139
  csv_split(publishers)&.each do |p|
119
140
  xml.contributor do |c|
120
141
  c.role **{ type: "publisher" }
121
- c.organization { |a| organization(a, p) }
142
+ c.organization do |a|
143
+ organization(a, p, node, !node.attr("publisher"))
144
+ end
122
145
  end
123
146
  end
124
147
  end
125
148
 
126
149
  def metadata_copyright(node, xml)
127
- publishers = node.attr("copyright-holder") || node.attr("publisher") ||
128
- default_publisher || "-"
129
- csv_split(publishers)&.each do |p|
150
+ pub = node.attr("copyright-holder") || node.attr("publisher")
151
+ csv_split(pub || default_publisher || "-")&.each do |p|
130
152
  xml.copyright do |c|
131
153
  c.from (node.attr("copyright-year") || Date.today.year)
132
154
  p.match(/[A-Za-z]/).nil? or c.owner do |owner|
133
- owner.organization { |o| organization(o, p) }
155
+ owner.organization do |a|
156
+ organization(a, p, node, !pub)
157
+ end
134
158
  end
135
159
  end
136
160
  end
@@ -42,7 +42,6 @@
42
42
  </define>
43
43
  <define name="xref">
44
44
  <element name="xref">
45
- <!-- attribute target { xsd:IDREF }, -->
46
45
  <attribute name="target">
47
46
  <data type="string">
48
47
  <param name="pattern">\i\c*|\c+#\c+</param>
@@ -5,8 +5,7 @@ require "yaml"
5
5
  require_relative "./macros_plantuml.rb"
6
6
  require_relative "./datamodel/attributes_table_preprocessor.rb"
7
7
  require_relative "./datamodel/diagram_preprocessor.rb"
8
- require_relative "./yaml2_text_preprocessor.rb"
9
- require_relative "./json2_text_preprocessor.rb"
8
+ require "metanorma-plugin-datastruct"
10
9
 
11
10
  module Asciidoctor
12
11
  module Standoc
@@ -68,7 +68,8 @@ module Asciidoctor
68
68
 
69
69
  def isorefmatches(xml, m)
70
70
  yr = norm_year(m[:year])
71
- ref = fetch_ref xml, m[:code], yr, title: m[:text], usrlbl: m[:usrlbl]
71
+ ref = fetch_ref xml, m[:code], yr, title: m[:text], usrlbl: m[:usrlbl],
72
+ lang: (@lang || :all)
72
73
  return use_my_anchor(ref, m[:anchor]) if ref
73
74
  xml.bibitem **attr_code(ref_attributes(m)) do |t|
74
75
  isorefrender1(t, m, yr)
@@ -81,7 +82,7 @@ module Asciidoctor
81
82
 
82
83
  def isorefmatches2(xml, m)
83
84
  ref = fetch_ref xml, m[:code], nil, no_year: true, note: m[:fn],
84
- title: m[:text], usrlbl: m[:usrlbl]
85
+ title: m[:text], usrlbl: m[:usrlbl], lang: (@lang || :all)
85
86
  return use_my_anchor(ref, m[:anchor]) if ref
86
87
  isorefmatches2_1(xml, m)
87
88
  end
@@ -111,7 +112,8 @@ module Asciidoctor
111
112
  yr = norm_year(m[:year])
112
113
  hasyr = !yr.nil? && yr != "--"
113
114
  ref = fetch_ref xml, m[:code], hasyr ? yr : nil, all_parts: true,
114
- no_year: yr == "--", text: m[:text], usrlbl: m[:usrlbl]
115
+ no_year: yr == "--", text: m[:text], usrlbl: m[:usrlbl],
116
+ lang: (@lang || :all)
115
117
  return use_my_anchor(ref, m[:anchor]) if ref
116
118
  isorefmatches3_1(xml, m, yr, hasyr, ref)
117
119
  end
@@ -181,11 +183,9 @@ module Asciidoctor
181
183
 
182
184
  # TODO: alternative where only title is available
183
185
  def refitem(xml, item, node)
184
- unless m = NON_ISO_REF.match(item)
185
- @log.add("AsciiDoc Input", node, "#{MALFORMED_REF}: #{item}")
186
- return
187
- end
188
- refitem1(xml, item, m)
186
+ m = NON_ISO_REF.match(item) and return refitem1(xml, item, m)
187
+ @log.add("AsciiDoc Input", node, "#{MALFORMED_REF}: #{item}")
188
+ nil
189
189
  end
190
190
 
191
191
  def refitem1(xml, item, m)
@@ -193,7 +193,7 @@ module Asciidoctor
193
193
  unless code[:id] && code[:numeric] || code[:nofetch]
194
194
  ref = fetch_ref xml, code[:id],
195
195
  m.names.include?("year") ? m[:year] : nil, title: m[:text],
196
- usrlbl: m[:usrlbl]
196
+ usrlbl: m[:usrlbl], lang: (@lang || :all)
197
197
  return use_my_anchor(ref, m[:anchor]) if ref
198
198
  end
199
199
  refitem_render(xml, m, code)
@@ -244,12 +244,6 @@ module Asciidoctor
244
244
  end
245
245
  end
246
246
 
247
- def reference(node)
248
- noko do |xml|
249
- node.items.each { |item| reference1(node, item.text, xml) }
250
- end.join
251
- end
252
-
253
247
  def mn_code(code)
254
248
  code.sub(/^\(/, "[").sub(/\).*$/, "]").sub(/^nofetch\((.+)\)$/, "\\1")
255
249
  end
@@ -9,6 +9,12 @@ module Asciidoctor
9
9
  @norm_ref
10
10
  end
11
11
 
12
+ def reference(node)
13
+ noko do |xml|
14
+ node.items.each { |item| reference1(node, item.text, xml) }
15
+ end.join
16
+ end
17
+
12
18
  def bibliography_parse(attrs, xml, node)
13
19
  node.option? "bibitem" and return bibitem_parse(attrs, xml, node)
14
20
  node.attr("style") == "bibliography" or
@@ -58,10 +64,10 @@ module Asciidoctor
58
64
  def fetch_ref(xml, code, year, **opts)
59
65
  return nil if opts[:no_year]
60
66
  code = code.sub(/^\([^)]+\)/, "")
67
+ #require "byebug"; byebug if opts[:lang] == "fr"
61
68
  hit = @bibdb&.fetch(code, year, opts)
62
69
  return nil if hit.nil?
63
- xml.parent.add_child(smart_render_xml(hit, code, opts[:title],
64
- opts[:usrlbl]))
70
+ xml.parent.add_child(smart_render_xml(hit, code, opts))
65
71
  xml
66
72
  rescue RelatonBib::RequestError
67
73
  @log.add("Bibliography", nil, "Could not retrieve #{code}: "\
@@ -84,10 +90,11 @@ module Asciidoctor
84
90
  "<docidentifier type='metanorma'>#{mn_code(usrlbl)}</docidentifier>"
85
91
  end
86
92
 
87
- def smart_render_xml(x, code, title, usrlbl)
88
- xstr = x.to_xml if x.respond_to? :to_xml
93
+ def smart_render_xml(x, code, opts)
94
+ x.respond_to? :to_xml or return nil
95
+ xstr = x.to_xml(lang: opts[:lang])
89
96
  xml = Nokogiri::XML(xstr)
90
- emend_biblio(xml, code, title, usrlbl)
97
+ emend_biblio(xml, code, opts[:title], opts[:usrlbl])
91
98
  xml.xpath("//date").each { |d| Utils::endash_date(d) }
92
99
  xml.traverse do |n|
93
100
  n.text? and n.replace(Utils::smartformat(n.text))
@@ -60,8 +60,7 @@ module Asciidoctor
60
60
  ret.merge(change: node.attributes["change"],
61
61
  path: node.attributes["path"],
62
62
  path_end: node.attributes["path_end"],
63
- title: node.attributes["title"],
64
- )
63
+ title: node.attributes["title"])
65
64
  end
66
65
 
67
66
  def section(node)
@@ -105,13 +104,10 @@ module Asciidoctor
105
104
  end
106
105
 
107
106
  def set_obligation(attrs, node)
108
- attrs[:obligation] = if node.attributes.has_key?("obligation")
109
- node.attr("obligation")
110
- elsif node.parent.attributes.has_key?("obligation")
111
- node.parent.attr("obligation")
112
- else
113
- "normative"
114
- end
107
+ attrs[:obligation] = node.attributes.has_key?("obligation") ?
108
+ node.attr("obligation") :
109
+ node.parent.attributes.has_key?("obligation") ?
110
+ node.parent.attr("obligation") : "normative"
115
111
  end
116
112
 
117
113
  def preamble(node)
@@ -0,0 +1,18 @@
1
+ module Liquid
2
+ module CustomBlocks
3
+ class WithJsonNestedContext < Block
4
+ def initialize(tag_name, markup, tokens)
5
+ super
6
+ @context_file_variable, @context_name = markup.split(",").map(&:strip)
7
+ end
8
+
9
+ def render(context)
10
+ context_file = context[@context_file_variable].to_s.strip
11
+ context[@context_name] = JSON.parse(
12
+ File.read(context_file, encoding: "utf-8")
13
+ )
14
+ super
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ module Liquid
2
+ module CustomBlocks
3
+ class WithYamlNestedContext < Block
4
+ def initialize(tag_name, markup, tokens)
5
+ super
6
+ @context_file_variable, @context_name = markup.split(",").map(&:strip)
7
+ end
8
+
9
+ def render(context)
10
+ context_file = context[@context_file_variable].to_s.strip
11
+ context[@context_name] = YAML.safe_load(
12
+ File.read(context_file, encoding: "utf-8"),
13
+ [Date, Time]
14
+ )
15
+ super
16
+ end
17
+ end
18
+ end
19
+ end
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "1.6.0".freeze
22
+ VERSION = "1.6.1".freeze
23
23
  end
24
24
  end
@@ -30,8 +30,9 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "ruby-jing"
31
31
  spec.add_dependency "isodoc", "~> 1.2.0"
32
32
  spec.add_dependency "iev", "~> 0.2.1"
33
+ spec.add_dependency "metanorma-plugin-datastruct"
33
34
  # relaton-cli not just relaton, to avoid circular reference in metanorma
34
- spec.add_dependency "relaton-cli", "~> 1.4.0"
35
+ spec.add_dependency "relaton-cli", "~> 1.5.0"
35
36
  spec.add_dependency "relaton-iev", "~> 1.0.0"
36
37
  spec.add_dependency "sterile", "~> 1.0.14"
37
38
  spec.add_dependency "concurrent-ruby"
@@ -34,7 +34,7 @@ RSpec.describe Asciidoctor::Standoc do
34
34
 
35
35
  it "processes publisher abbreviations" do
36
36
  mock_org_abbrevs
37
- expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~'OUTPUT')
37
+ expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
38
38
  = Document title
39
39
  Author
40
40
  :docfile: test.adoc
@@ -42,7 +42,7 @@ RSpec.describe Asciidoctor::Standoc do
42
42
  :novalid:
43
43
  :publisher: International Electrotechnical Commission,IETF,ISO
44
44
  INPUT
45
- <standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='1.5.3'>
45
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Standoc::VERSION}'>
46
46
  <bibdata type='standard'>
47
47
  <title language='en' format='text/plain'>Document title</title>
48
48
  <contributor>
@@ -191,7 +191,8 @@ OUTPUT
191
191
  :role_2: editor
192
192
  :affiliation_2: Rockhead and Quarry Cave Construction Company
193
193
  :affiliation_abbrev_2: RQCCC
194
- :address_2: 6A Rubble Way, Bedrock
194
+ :address_2: 6A Rubble Way, + \\
195
+ Bedrock
195
196
  :email_2: barney@rockhead.example.com
196
197
  :phone_2: 789
197
198
  :fax_2: 012
@@ -200,6 +201,12 @@ OUTPUT
200
201
  :part-of: ABC
201
202
  :translated-from: DEF,GHI;JKL MNO,PQR
202
203
  :keywords: a, b, c
204
+ :pub-address: 1 Infinity Loop + \\
205
+ California
206
+ :pub-phone: 3333333
207
+ :pub-fax: 4444444
208
+ :pub-email: x@example.com
209
+ :pub-uri: http://www.example.com
203
210
  INPUT
204
211
  <?xml version="1.0" encoding="UTF-8"?>
205
212
  <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
@@ -252,19 +259,19 @@ OUTPUT
252
259
  <contributor>
253
260
  <role type="author"/>
254
261
  <organization>
255
- <name>Ribose, Inc.</name>
262
+ <name>Hanna Barbera</name>
256
263
  </organization>
257
264
  </contributor>
258
265
  <contributor>
259
266
  <role type="author"/>
260
267
  <organization>
261
- <name>Hanna Barbera</name>
268
+ <name>Cartoon Network</name>
262
269
  </organization>
263
270
  </contributor>
264
271
  <contributor>
265
272
  <role type="author"/>
266
273
  <organization>
267
- <name>Cartoon Network</name>
274
+ <name>Ribose, Inc.</name>
268
275
  </organization>
269
276
  </contributor>
270
277
  <contributor>
@@ -278,7 +285,9 @@ OUTPUT
278
285
  <name>Slate Rock and Gravel Company</name>
279
286
  <abbreviation>SRG</abbreviation>
280
287
  <address>
281
- <formattedAddress>6 Rubble Way, Bedrock</formattedAddress>
288
+ <formattedAddress>
289
+ 6 Rubble Way, Bedrock
290
+ </formattedAddress>
282
291
  </address>
283
292
  </organization>
284
293
  </affiliation>
@@ -300,7 +309,7 @@ OUTPUT
300
309
  <name>Rockhead and Quarry Cave Construction Company</name>
301
310
  <abbreviation>RQCCC</abbreviation>
302
311
  <address>
303
- <formattedAddress>6A Rubble Way, Bedrock</formattedAddress>
312
+ <formattedAddress>6A Rubble Way, <br/>Bedrock</formattedAddress>
304
313
  </address>
305
314
  </organization>
306
315
  </affiliation>
@@ -421,6 +430,8 @@ OUTPUT
421
430
  :relaton-uri: F
422
431
  :title-eo: Dokumenttitolo
423
432
  :doctype: This is a DocType
433
+ :subdivision: Subdivision
434
+ :subdivision-abbr: SD
424
435
 
425
436
  [abstract]
426
437
  == Abstract
@@ -535,6 +546,105 @@ OUTPUT
535
546
  OUTPUT
536
547
  end
537
548
 
549
+ it "processes subdivisions" do
550
+ mock_default_publisher
551
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
552
+ = Document title
553
+ Author
554
+ :docfile: test.adoc
555
+ :nodoc:
556
+ :novalid:
557
+ :revdate: 2000-01
558
+ :published-date: 1000-01
559
+ :docnumber: 1000
560
+ :partnumber: 1-1
561
+ :tc-docnumber: 2000
562
+ :language: el
563
+ :script: Grek
564
+ :subdivision: Subdivision
565
+ :subdivision-abbr: SD
566
+ :doctype: This is a DocType
567
+ :pub-address: 1 Infinity Loop + \\
568
+ California
569
+ :pub-phone: 3333333
570
+ :pub-fax: 4444444
571
+ :pub-email: x@example.com
572
+ :pub-uri: http://www.example.com
573
+
574
+ INPUT
575
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
576
+ <bibdata type='standard'>
577
+ <title language='en' format='text/plain'>Document title</title>
578
+ <docidentifier>1000-1-1</docidentifier>
579
+ <docnumber>1000</docnumber>
580
+ <date type='published'>
581
+ <on>1000-01</on>
582
+ </date>
583
+ <contributor>
584
+ <role type='author'/>
585
+ <organization>
586
+ <name>International Standards Organization</name>
587
+ <subdivision>Subdivision</subdivision>
588
+ <abbreviation>SD</abbreviation>
589
+ <address>
590
+ <formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
591
+ </address>
592
+ <phone>3333333</phone>
593
+ <phone type='fax'>4444444</phone>
594
+ <email>x@example.com</email>
595
+ <uri>http://www.example.com</uri>
596
+ </organization>
597
+ </contributor>
598
+ <contributor>
599
+ <role type='publisher'/>
600
+ <organization>
601
+ <name>International Standards Organization</name>
602
+ <subdivision>Subdivision</subdivision>
603
+ <abbreviation>SD</abbreviation>
604
+ <address>
605
+ <formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
606
+ </address>
607
+ <phone>3333333</phone>
608
+ <phone type='fax'>4444444</phone>
609
+ <email>x@example.com</email>
610
+ <uri>http://www.example.com</uri>
611
+ </organization>
612
+ </contributor>
613
+ <version>
614
+ <revision-date>2000-01</revision-date>
615
+ </version>
616
+ <language>el</language>
617
+ <script>Grek</script>
618
+ <status>
619
+ <stage>published</stage>
620
+ </status>
621
+ <copyright>
622
+ <from>2020</from>
623
+ <owner>
624
+ <organization>
625
+ <name>International Standards Organization</name>
626
+ <subdivision>Subdivision</subdivision>
627
+ <abbreviation>SD</abbreviation>
628
+ <address>
629
+ <formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
630
+ </address>
631
+ <phone>3333333</phone>
632
+ <phone type='fax'>4444444</phone>
633
+ <email>x@example.com</email>
634
+ <uri>http://www.example.com</uri>
635
+ </organization>
636
+ </owner>
637
+ </copyright>
638
+ <ext>
639
+ <doctype>this-is-a-doctype</doctype>
640
+ </ext>
641
+ </bibdata>
642
+ <sections> </sections>
643
+ </standard-document>
644
+
645
+ OUTPUT
646
+ end
647
+
538
648
  it "reads scripts into blank HTML document" do
539
649
  FileUtils.rm_f "test.html"
540
650
  Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
@@ -643,6 +753,11 @@ QU1FOiB0ZXN0Cgo=
643
753
  )
644
754
  end
645
755
 
756
+ def mock_default_publisher
757
+ allow_any_instance_of(::Asciidoctor::Standoc::Front).to receive(:default_publisher).and_return(
758
+ "International Standards Organization"
759
+ )
760
+ end
646
761
 
647
762
 
648
763
  end