metanorma-standoc 1.5.3 → 1.6.4

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +66 -0
  3. data/README.adoc +1 -3
  4. data/lib/asciidoctor/standoc/base.rb +6 -1
  5. data/lib/asciidoctor/standoc/basicdoc.rng +4 -11
  6. data/lib/asciidoctor/standoc/cleanup.rb +78 -12
  7. data/lib/asciidoctor/standoc/cleanup_block.rb +41 -4
  8. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +14 -0
  9. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +25 -0
  10. data/lib/asciidoctor/standoc/cleanup_inline.rb +6 -2
  11. data/lib/asciidoctor/standoc/cleanup_ref.rb +3 -4
  12. data/lib/asciidoctor/standoc/converter.rb +58 -3
  13. data/lib/asciidoctor/standoc/front.rb +9 -3
  14. data/lib/asciidoctor/standoc/front_contributor.rb +43 -11
  15. data/lib/asciidoctor/standoc/inline.rb +18 -40
  16. data/lib/asciidoctor/standoc/isodoc.rng +27 -50
  17. data/lib/asciidoctor/standoc/lists.rb +4 -2
  18. data/lib/asciidoctor/standoc/macros.rb +28 -2
  19. data/lib/asciidoctor/standoc/ref.rb +46 -48
  20. data/lib/asciidoctor/standoc/ref_sect.rb +16 -8
  21. data/lib/asciidoctor/standoc/section.rb +5 -9
  22. data/lib/liquid/custom_blocks/with_json_nested_context.rb +18 -0
  23. data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +19 -0
  24. data/lib/metanorma/standoc.rb +0 -5
  25. data/lib/metanorma/standoc/version.rb +20 -1
  26. data/metanorma-standoc.gemspec +7 -3
  27. data/spec/asciidoctor-standoc/base_spec.rb +246 -9
  28. data/spec/asciidoctor-standoc/blocks_spec.rb +1 -1
  29. data/spec/asciidoctor-standoc/cleanup_sections_spec.rb +1514 -0
  30. data/spec/asciidoctor-standoc/cleanup_spec.rb +384 -1547
  31. data/spec/asciidoctor-standoc/inline_spec.rb +128 -4
  32. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +15 -22
  33. data/spec/asciidoctor-standoc/lists_spec.rb +10 -1
  34. data/spec/asciidoctor-standoc/macros_json2text_spec.rb +1 -1
  35. data/spec/asciidoctor-standoc/macros_lutaml_spec.rb +80 -0
  36. data/spec/asciidoctor-standoc/macros_spec.rb +258 -0
  37. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +1 -1
  38. data/spec/asciidoctor-standoc/refs_dl_spec.rb +8 -8
  39. data/spec/asciidoctor-standoc/refs_spec.rb +362 -104
  40. data/spec/asciidoctor-standoc/validate_spec.rb +26 -0
  41. data/spec/fixtures/diagram_definitions.lutaml +22 -0
  42. data/spec/fixtures/test.exp +121 -0
  43. data/spec/spec_helper.rb +34 -1
  44. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +201 -3
  45. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +47 -231
  46. data/spec/vcr_cassettes/isobib_get_123.yml +14 -60
  47. data/spec/vcr_cassettes/isobib_get_123_1.yml +24 -116
  48. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +361 -0
  49. data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -60
  50. data/spec/vcr_cassettes/isobib_get_124.yml +12 -58
  51. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  52. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +292 -162
  53. metadata +59 -17
  54. data/.github/workflows/macos.yml +0 -46
  55. data/.github/workflows/ubuntu.yml +0 -49
  56. data/.github/workflows/windows.yml +0 -53
  57. data/lib/asciidoctor/standoc/base_structured_text_preprocessor.rb +0 -123
  58. data/lib/asciidoctor/standoc/json2_text_preprocessor.rb +0 -43
  59. data/lib/asciidoctor/standoc/yaml2_text_preprocessor.rb +0 -43
  60. data/lib/metanorma/standoc/latexml_requirement.rb +0 -62
  61. data/lib/metanorma/standoc/requirement.rb +0 -13
@@ -5,8 +5,8 @@ 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"
9
+ require "metanorma-plugin-lutaml"
10
10
 
11
11
  module Asciidoctor
12
12
  module Standoc
@@ -187,5 +187,31 @@ module Asciidoctor
187
187
  %{<autonumber type=#{target}>#{out}</autonumber>}
188
188
  end
189
189
  end
190
+
191
+ class VariantInlineMacro < Extensions::InlineMacroProcessor
192
+ use_dsl
193
+ named :lang
194
+ parse_content_as :text
195
+
196
+ def process(parent, target, attrs)
197
+ /^(?<lang>[^-]*)(-(?<script>.*))?$/ =~ target
198
+ out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
199
+ script ?
200
+ %{<variant lang=#{lang} script=#{script}>#{out}</variant>} :
201
+ %{<variant lang=#{lang}>#{out}</variant>}
202
+ end
203
+ end
204
+
205
+ class FootnoteBlockInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
206
+ use_dsl
207
+ named :footnoteblock
208
+ parse_content_as :text
209
+ using_format :short
210
+
211
+ def process(parent, _target, attrs)
212
+ out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
213
+ %{<footnoteblock>#{out}</footnoteblock>}
214
+ end
215
+ end
190
216
  end
191
217
  end
@@ -42,8 +42,7 @@ module Asciidoctor
42
42
 
43
43
  def docid(t, code)
44
44
  type, code1 = /^\[\d+\]$|^\([^)]+\).*$/.match(code) ?
45
- ["metanorma", mn_code(code)] :
46
- @bibdb&.docid_type(code) || [nil, code]
45
+ ["metanorma", mn_code(code)] : @bibdb&.docid_type(code) || [nil, code]
47
46
  code1.sub!(/^nofetch\((.+)\)$/, "\\1")
48
47
  t.docidentifier **attr_code(type: type) do |d|
49
48
  d << code1
@@ -57,7 +56,9 @@ module Asciidoctor
57
56
  end
58
57
 
59
58
  def norm_year(yr)
60
- /^\&\#821[12];$/.match(yr) ? "--" : yr
59
+ /^\&\#821[12];$/.match(yr) and return "--"
60
+ /^\d\d\d\d-\d\d\d\d$/.match(yr) and return yr
61
+ yr&.sub(/(?<=[0-9])-.*$/, "")
61
62
  end
62
63
 
63
64
  def isorefrender1(t, m, yr, allp = "")
@@ -69,7 +70,8 @@ module Asciidoctor
69
70
 
70
71
  def isorefmatches(xml, m)
71
72
  yr = norm_year(m[:year])
72
- ref = fetch_ref xml, m[:code], yr, title: m[:text], usrlbl: m[:usrlbl]
73
+ ref = fetch_ref xml, m[:code], yr, title: m[:text], usrlbl: m[:usrlbl],
74
+ lang: (@lang || :all)
73
75
  return use_my_anchor(ref, m[:anchor]) if ref
74
76
  xml.bibitem **attr_code(ref_attributes(m)) do |t|
75
77
  isorefrender1(t, m, yr)
@@ -82,15 +84,19 @@ module Asciidoctor
82
84
 
83
85
  def isorefmatches2(xml, m)
84
86
  ref = fetch_ref xml, m[:code], nil, no_year: true, note: m[:fn],
85
- title: m[:text], usrlbl: m[:usrlbl]
87
+ title: m[:text], usrlbl: m[:usrlbl], lang: (@lang || :all)
86
88
  return use_my_anchor(ref, m[:anchor]) if ref
89
+ isorefmatches2_1(xml, m)
90
+ end
91
+
92
+ def isorefmatches2_1(xml, m)
87
93
  xml.bibitem **attr_code(ref_attributes(m)) do |t|
88
94
  isorefrender1(t, m, "--")
89
95
  t.date **{ type: "published" } do |d|
90
96
  d.on "--"
91
97
  end
92
98
  iso_publisher(t, m[:code])
93
- m[:fn].nil? or t.note(**plaintxt.merge(type: "ISO DATE")) do |p|
99
+ m[:fn].nil? or t.note(**plaintxt.merge(type: "Unpublished-Status")) do |p|
94
100
  p << "#{m[:fn]}"
95
101
  end
96
102
  end
@@ -106,19 +112,21 @@ module Asciidoctor
106
112
 
107
113
  def isorefmatches3(xml, m)
108
114
  yr = norm_year(m[:year])
109
- #hasyr = m.names.include?("year") && yr != "--"
110
115
  hasyr = !yr.nil? && yr != "--"
111
- #noyr = m.names.include?("year") && yr == "--"
112
116
  ref = fetch_ref xml, m[:code], hasyr ? yr : nil, all_parts: true,
113
- no_year: yr == "--", text: m[:text], usrlbl: m[:usrlbl]
117
+ no_year: yr == "--", text: m[:text], usrlbl: m[:usrlbl],
118
+ lang: (@lang || :all)
114
119
  return use_my_anchor(ref, m[:anchor]) if ref
120
+ isorefmatches3_1(xml, m, yr, hasyr, ref)
121
+ end
115
122
 
123
+ def isorefmatches3_1(xml, m, yr, hasyr, ref)
116
124
  xml.bibitem(**attr_code(ref_attributes(m))) do |t|
117
125
  isorefrender1(t, m, yr, " (all parts)")
118
126
  conditional_date(t, m, yr == "--")
119
127
  iso_publisher(t, m[:code])
120
128
  m.names.include?("fn") && m[:fn] and
121
- t.note(**plaintxt.merge(type: "ISO DATE")) { |p| p << "#{m[:fn]}" }
129
+ t.note(**plaintxt.merge(type: "Unpublished-Status")) { |p| p << "#{m[:fn]}" }
122
130
  t.extent **{ type: 'part' } do |e|
123
131
  e.referenceFrom "all"
124
132
  end
@@ -147,30 +155,25 @@ module Asciidoctor
147
155
  end
148
156
 
149
157
  MALFORMED_REF = "no anchor on reference, markup may be malformed: see "\
150
- "https://www.metanorma.com/author/topics/document-format/bibliography/ , "\
151
- "https://www.metanorma.com/author/iso/topics/markup/#bibliographies".freeze
158
+ "https://www.metanorma.com/author/topics/document-format/"\
159
+ "bibliography/ , https://www.metanorma.com/author/iso/topics/markup/"\
160
+ "#bibliographies".freeze
152
161
 
153
162
  def analyse_ref_nofetch(ret)
154
163
  return ret unless m = /^nofetch\((?<id>.+)\)$/.match(ret[:id])
155
- ret[:id] = m[:id]
156
- ret[:nofetch] = true
157
- ret
164
+ ret.merge(id: m[:id], nofetch: true)
158
165
  end
159
166
 
160
167
  def analyse_ref_repo_path(ret)
161
168
  return ret unless m =
162
- /^(?<type>repo|path):\((?<key>[^,]+),(?<id>.+)\)$/.match(ret[:id])
163
- ret[:id] = m[:id]
164
- ret[:type] = m[:type]
165
- ret[:key] = m[:key]
166
- ret[:nofetch] = true
167
- ret
169
+ /^(?<type>repo|path):\((?<key>[^,]+),?(?<id>.*)\)$/.match(ret[:id])
170
+ id = m[:id].empty? ? m[:key].sub(%r{^[^/]+/}, "") : m[:id]
171
+ ret.merge(id: id, type: m[:type], key: m[:key], nofetch: true)
168
172
  end
169
173
 
170
174
  def analyse_ref_numeric(ret)
171
175
  return ret unless /^\d+$/.match(ret[:id])
172
- ret[:numeric] = true
173
- ret
176
+ ret.merge(numeric: true)
174
177
  end
175
178
 
176
179
  # ref id = (usrlbl)code[:-]year
@@ -178,23 +181,22 @@ module Asciidoctor
178
181
  def analyse_ref_code(code)
179
182
  ret = {id: code}
180
183
  return ret if code.nil? || code.empty?
181
- ret = analyse_ref_nofetch(ret)
182
- ret = analyse_ref_repo_path(ret)
183
- ret = analyse_ref_numeric(ret)
184
- ret
184
+ analyse_ref_nofetch(analyse_ref_repo_path(analyse_ref_numeric(ret)))
185
185
  end
186
186
 
187
187
  # TODO: alternative where only title is available
188
188
  def refitem(xml, item, node)
189
- unless m = NON_ISO_REF.match(item)
190
- @log.add("AsciiDoc Input", node, "#{MALFORMED_REF}: #{item}")
191
- return
192
- end
189
+ m = NON_ISO_REF.match(item) and return refitem1(xml, item, m)
190
+ @log.add("AsciiDoc Input", node, "#{MALFORMED_REF}: #{item}")
191
+ nil
192
+ end
193
+
194
+ def refitem1(xml, item, m)
193
195
  code = analyse_ref_code(m[:code])
194
196
  unless code[:id] && code[:numeric] || code[:nofetch]
195
197
  ref = fetch_ref xml, code[:id],
196
198
  m.names.include?("year") ? m[:year] : nil, title: m[:text],
197
- usrlbl: m[:usrlbl]
199
+ usrlbl: m[:usrlbl], lang: (@lang || :all)
198
200
  return use_my_anchor(ref, m[:anchor]) if ref
199
201
  end
200
202
  refitem_render(xml, m, code)
@@ -214,23 +216,25 @@ module Asciidoctor
214
216
  (?<text>.*)$}xm
215
217
 
216
218
  ISO_REF_NO_YEAR = %r{^<ref\sid="(?<anchor>[^"]+)">
217
- \[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9-]+):(--|\&\#821[12]\;)\]</ref>,?\s*
219
+ \[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9-]+):
220
+ (--|\&\#821[12]\;)\]</ref>,?\s*
218
221
  (<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>)?,?\s?(?<text>.*)$}xm
219
222
 
220
223
  ISO_REF_ALL_PARTS = %r{^<ref\sid="(?<anchor>[^"]+)">
221
- \[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9]+)(:(?<year>--|\&\#821[12]\;|[0-9][0-9-]+))?\s
224
+ \[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9]+)
225
+ (:(?<year>--|\&\#821[12]\;|[0-9][0-9-]+))?\s
222
226
  \(all\sparts\)\]</ref>,?\s*
223
227
  (<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>,?\s?)?(?<text>.*)$}xm
224
228
 
225
229
  NON_ISO_REF = %r{^<ref\sid="(?<anchor>[^"]+)">
226
- \[(?<usrlbl>\([^)]+\))?(?<code>[^\]]+?)([:-](?<year>(19|20)[0-9][0-9]))?\]</ref>,?\s*
227
- (?<text>.*)$}xm
228
-
229
- def reference1_matches(item)
230
- matched = ISO_REF.match item
231
- matched2 = ISO_REF_NO_YEAR.match item
232
- matched3 = ISO_REF_ALL_PARTS.match item
233
- [matched, matched2, matched3]
230
+ \[(?<usrlbl>\([^)]+\))?(?<code>[^\]]+?)
231
+ ([:-](?<year>(19|20)[0-9][0-9][0-9-]*))?\]</ref>,?\s*(?<text>.*)$}xm
232
+
233
+ def reference1_matches(item)
234
+ matched = ISO_REF.match item
235
+ matched2 = ISO_REF_NO_YEAR.match item
236
+ matched3 = ISO_REF_ALL_PARTS.match item
237
+ [matched, matched2, matched3]
234
238
  end
235
239
 
236
240
  def reference1(node, item, xml)
@@ -243,12 +247,6 @@ module Asciidoctor
243
247
  end
244
248
  end
245
249
 
246
- def reference(node)
247
- noko do |xml|
248
- node.items.each { |item| reference1(node, item.text, xml) }
249
- end.join
250
- end
251
-
252
250
  def mn_code(code)
253
251
  code.sub(/^\(/, "[").sub(/\).*$/, "]").sub(/^nofetch\((.+)\)$/, "\\1")
254
252
  end
@@ -9,14 +9,20 @@ 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
15
21
  @log.add("AsciiDoc Input", node, "Section not marked up as [bibliography]!")
16
22
  @biblio = true
17
23
  xml.references **attr_code(attrs.merge(normative: false)) do |xml_section|
18
- title = node.level == 1 ? "Bibliography" : node.title
19
- xml_section.title { |t| t << title }
24
+ #title = node.level == 1 ? "Bibliography" : node.title
25
+ xml_section.title { |t| t << node.title }
20
26
  xml_section << node.content
21
27
  end
22
28
  @biblio = false
@@ -38,7 +44,8 @@ module Asciidoctor
38
44
  @log.add("AsciiDoc Input", node, "Section not marked up as [bibliography]!")
39
45
  @norm_ref = true
40
46
  xml.references **attr_code(attrs.merge(normative: true)) do |xml_section|
41
- xml_section.title { |t| t << "Normative References" }
47
+ #xml_section.title { |t| t << "Normative References" }
48
+ xml_section.title { |t| t << node.title }
42
49
  xml_section << node.content
43
50
  end
44
51
  @norm_ref = false
@@ -58,10 +65,10 @@ module Asciidoctor
58
65
  def fetch_ref(xml, code, year, **opts)
59
66
  return nil if opts[:no_year]
60
67
  code = code.sub(/^\([^)]+\)/, "")
68
+ #require "byebug"; byebug if opts[:lang] == "fr"
61
69
  hit = @bibdb&.fetch(code, year, opts)
62
70
  return nil if hit.nil?
63
- xml.parent.add_child(smart_render_xml(hit, code, opts[:title],
64
- opts[:usrlbl]))
71
+ xml.parent.add_child(smart_render_xml(hit, code, opts))
65
72
  xml
66
73
  rescue RelatonBib::RequestError
67
74
  @log.add("Bibliography", nil, "Could not retrieve #{code}: "\
@@ -84,10 +91,11 @@ module Asciidoctor
84
91
  "<docidentifier type='metanorma'>#{mn_code(usrlbl)}</docidentifier>"
85
92
  end
86
93
 
87
- def smart_render_xml(x, code, title, usrlbl)
88
- xstr = x.to_xml if x.respond_to? :to_xml
94
+ def smart_render_xml(x, code, opts)
95
+ x.respond_to? :to_xml or return nil
96
+ xstr = x.to_xml(lang: opts[:lang])
89
97
  xml = Nokogiri::XML(xstr)
90
- emend_biblio(xml, code, title, usrlbl)
98
+ emend_biblio(xml, code, opts[:title], opts[:usrlbl])
91
99
  xml.xpath("//date").each { |d| Utils::endash_date(d) }
92
100
  xml.traverse do |n|
93
101
  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
@@ -1,11 +1,6 @@
1
1
  require_relative "./standoc/processor"
2
- require_relative "./standoc/requirement"
3
- require_relative "./standoc/latexml_requirement"
4
2
 
5
3
  module Metanorma
6
4
  module Standoc
7
- Requirements = {
8
- latexml: LatexmlRequirement.new
9
- }
10
5
  end
11
6
  end
@@ -1,5 +1,24 @@
1
1
  module Metanorma
2
+ class << self
3
+ # https://stackoverflow.com/a/53399471
4
+ def parent_of(mod)
5
+ parent_name = mod.name =~ /::[^:]+\Z/ ? $`.freeze : nil
6
+ Object.const_get(parent_name) if parent_name
7
+ end
8
+
9
+ def all_modules(mod)
10
+ [mod] + mod.constants.map { |c| mod.const_get(c) }
11
+ .select {|c| c.is_a?(Module) && parent_of(c) == mod }
12
+ .flat_map {|m| all_modules(m) }
13
+ end
14
+
15
+ def versioned(mod, flavour)
16
+ all_modules(mod).select {|c| defined? c::VERSION}.
17
+ select {|c| c.name =~ /::#{flavour}$/ }
18
+ end
19
+ end
20
+
2
21
  module Standoc
3
- VERSION = "1.5.3".freeze
22
+ VERSION = "1.6.4".freeze
4
23
  end
5
24
  end
@@ -28,16 +28,20 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency "asciidoctor", "~> 2.0.0"
30
30
  spec.add_dependency "ruby-jing"
31
- spec.add_dependency "isodoc", "~> 1.2.0"
31
+ spec.add_dependency "isodoc", "~> 1.3.0"
32
32
  spec.add_dependency "iev", "~> 0.2.1"
33
- spec.add_dependency "relaton", "~> 1.3.0"
34
- spec.add_dependency "relaton-iev", "~> 1.0.0"
33
+ spec.add_dependency "metanorma-plugin-datastruct"
34
+ spec.add_dependency "metanorma-plugin-lutaml", "~> 0.2.1"
35
+ # relaton-cli not just relaton, to avoid circular reference in metanorma
36
+ spec.add_dependency "relaton-cli", "~> 1.7.0"
37
+ spec.add_dependency "relaton-iev", "~> 1.1.0"
35
38
  spec.add_dependency "sterile", "~> 1.0.14"
36
39
  spec.add_dependency "concurrent-ruby"
37
40
  spec.add_dependency "unicode2latex", "~> 0.0.1"
38
41
  spec.add_dependency "mimemagic"
39
42
  spec.add_dependency "mathml2asciimath"
40
43
  spec.add_dependency "latexmath"
44
+ spec.add_dependency "fontist", "~> 1.5.0"
41
45
 
42
46
  spec.add_development_dependency "byebug"
43
47
  spec.add_development_dependency "sassc", "2.4.0"
@@ -32,8 +32,101 @@ RSpec.describe Asciidoctor::Standoc do
32
32
  expect(File.exist?("htmlstyle.css")).to be false
33
33
  end
34
34
 
35
+ it "processes publisher abbreviations" do
36
+ mock_org_abbrevs
37
+ expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
38
+ = Document title
39
+ Author
40
+ :docfile: test.adoc
41
+ :nodoc:
42
+ :novalid:
43
+ :publisher: International Electrotechnical Commission,IETF,ISO
44
+ INPUT
45
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Standoc::VERSION}'>
46
+ <bibdata type='standard'>
47
+ <title language='en' format='text/plain'>Document title</title>
48
+ <contributor>
49
+ <role type='author'/>
50
+ <organization>
51
+ <name>International Electrotechnical Commission</name>
52
+ <abbreviation>IEC</abbreviation>
53
+ </organization>
54
+ </contributor>
55
+ <contributor>
56
+ <role type='author'/>
57
+ <organization>
58
+ <name>IETF</name>
59
+ </organization>
60
+ </contributor>
61
+ <contributor>
62
+ <role type='author'/>
63
+ <organization>
64
+ <name>International Standards Organization</name>
65
+ <abbreviation>ISO</abbreviation>
66
+ </organization>
67
+ </contributor>
68
+ <contributor>
69
+ <role type='publisher'/>
70
+ <organization>
71
+ <name>International Electrotechnical Commission</name>
72
+ <abbreviation>IEC</abbreviation>
73
+ </organization>
74
+ </contributor>
75
+ <contributor>
76
+ <role type='publisher'/>
77
+ <organization>
78
+ <name>IETF</name>
79
+ </organization>
80
+ </contributor>
81
+ <contributor>
82
+ <role type='publisher'/>
83
+ <organization>
84
+ <name>International Standards Organization</name>
85
+ <abbreviation>ISO</abbreviation>
86
+ </organization>
87
+ </contributor>
88
+ <language>en</language>
89
+ <script>Latn</script>
90
+ <status>
91
+ <stage>published</stage>
92
+ </status>
93
+ <copyright>
94
+ <from>2020</from>
95
+ <owner>
96
+ <organization>
97
+ <name>International Electrotechnical Commission</name>
98
+ <abbreviation>IEC</abbreviation>
99
+ </organization>
100
+ </owner>
101
+ </copyright>
102
+ <copyright>
103
+ <from>2020</from>
104
+ <owner>
105
+ <organization>
106
+ <name>IETF</name>
107
+ </organization>
108
+ </owner>
109
+ </copyright>
110
+ <copyright>
111
+ <from>2020</from>
112
+ <owner>
113
+ <organization>
114
+ <name>International Standards Organization</name>
115
+ <abbreviation>ISO</abbreviation>
116
+ </organization>
117
+ </owner>
118
+ </copyright>
119
+ <ext>
120
+ <doctype>article</doctype>
121
+ </ext>
122
+ </bibdata>
123
+ <sections> </sections>
124
+ </standard-document>
125
+ OUTPUT
126
+ end
127
+
35
128
  it "processes default metadata" do
36
- expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~'OUTPUT')
129
+ expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
37
130
  = Document title
38
131
  Author
39
132
  :docfile: test.adoc
@@ -98,7 +191,8 @@ RSpec.describe Asciidoctor::Standoc do
98
191
  :role_2: editor
99
192
  :affiliation_2: Rockhead and Quarry Cave Construction Company
100
193
  :affiliation_abbrev_2: RQCCC
101
- :address_2: 6A Rubble Way, Bedrock
194
+ :address_2: 6A Rubble Way, + \\
195
+ Bedrock
102
196
  :email_2: barney@rockhead.example.com
103
197
  :phone_2: 789
104
198
  :fax_2: 012
@@ -107,12 +201,22 @@ RSpec.describe Asciidoctor::Standoc do
107
201
  :part-of: ABC
108
202
  :translated-from: DEF,GHI;JKL MNO,PQR
109
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
210
+ :isbn: ISBN-13
211
+ :isbn10: ISBN-10
110
212
  INPUT
111
213
  <?xml version="1.0" encoding="UTF-8"?>
112
- <standard-document xmlns="https://www.metanorma.org/ns/standoc">
214
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
113
215
  <bibdata type="standard">
114
216
  <title language="en" format="text/plain">Main Title — Title</title>
115
217
  <docidentifier>1000-1</docidentifier>
218
+ <docidentifier type='ISBN'>ISBN-13</docidentifier>
219
+ <docidentifier type='ISBN10'>ISBN-10</docidentifier>
116
220
  <docnumber>1000</docnumber>
117
221
  <date type="published">
118
222
  <on>1000-01-01</on>
@@ -159,19 +263,19 @@ RSpec.describe Asciidoctor::Standoc do
159
263
  <contributor>
160
264
  <role type="author"/>
161
265
  <organization>
162
- <name>Ribose, Inc.</name>
266
+ <name>Hanna Barbera</name>
163
267
  </organization>
164
268
  </contributor>
165
269
  <contributor>
166
270
  <role type="author"/>
167
271
  <organization>
168
- <name>Hanna Barbera</name>
272
+ <name>Cartoon Network</name>
169
273
  </organization>
170
274
  </contributor>
171
275
  <contributor>
172
276
  <role type="author"/>
173
277
  <organization>
174
- <name>Cartoon Network</name>
278
+ <name>Ribose, Inc.</name>
175
279
  </organization>
176
280
  </contributor>
177
281
  <contributor>
@@ -185,7 +289,9 @@ RSpec.describe Asciidoctor::Standoc do
185
289
  <name>Slate Rock and Gravel Company</name>
186
290
  <abbreviation>SRG</abbreviation>
187
291
  <address>
188
- <formattedAddress>6 Rubble Way, Bedrock</formattedAddress>
292
+ <formattedAddress>
293
+ 6 Rubble Way, Bedrock
294
+ </formattedAddress>
189
295
  </address>
190
296
  </organization>
191
297
  </affiliation>
@@ -207,7 +313,7 @@ RSpec.describe Asciidoctor::Standoc do
207
313
  <name>Rockhead and Quarry Cave Construction Company</name>
208
314
  <abbreviation>RQCCC</abbreviation>
209
315
  <address>
210
- <formattedAddress>6A Rubble Way, Bedrock</formattedAddress>
316
+ <formattedAddress>6A Rubble Way, <br/>Bedrock</formattedAddress>
211
317
  </address>
212
318
  </organization>
213
319
  </affiliation>
@@ -328,6 +434,8 @@ RSpec.describe Asciidoctor::Standoc do
328
434
  :relaton-uri: F
329
435
  :title-eo: Dokumenttitolo
330
436
  :doctype: This is a DocType
437
+ :subdivision: Subdivision
438
+ :subdivision-abbr: SD
331
439
 
332
440
  [abstract]
333
441
  == Abstract
@@ -339,7 +447,7 @@ RSpec.describe Asciidoctor::Standoc do
339
447
  == Clause 1
340
448
  INPUT
341
449
  <?xml version="1.0" encoding="UTF-8"?>
342
- <standard-document xmlns="https://www.metanorma.org/ns/standoc">
450
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
343
451
  <bibdata type="standard">
344
452
  <title language="en" format="text/plain">Document title</title>
345
453
  <title language="eo" format="text/plain">Dokumenttitolo</title>
@@ -442,6 +550,105 @@ RSpec.describe Asciidoctor::Standoc do
442
550
  OUTPUT
443
551
  end
444
552
 
553
+ it "processes subdivisions" do
554
+ mock_default_publisher
555
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
556
+ = Document title
557
+ Author
558
+ :docfile: test.adoc
559
+ :nodoc:
560
+ :novalid:
561
+ :revdate: 2000-01
562
+ :published-date: 1000-01
563
+ :docnumber: 1000
564
+ :partnumber: 1-1
565
+ :tc-docnumber: 2000
566
+ :language: el
567
+ :script: Grek
568
+ :subdivision: Subdivision
569
+ :subdivision-abbr: SD
570
+ :doctype: This is a DocType
571
+ :pub-address: 1 Infinity Loop + \\
572
+ California
573
+ :pub-phone: 3333333
574
+ :pub-fax: 4444444
575
+ :pub-email: x@example.com
576
+ :pub-uri: http://www.example.com
577
+
578
+ INPUT
579
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
580
+ <bibdata type='standard'>
581
+ <title language='en' format='text/plain'>Document title</title>
582
+ <docidentifier>1000-1-1</docidentifier>
583
+ <docnumber>1000</docnumber>
584
+ <date type='published'>
585
+ <on>1000-01</on>
586
+ </date>
587
+ <contributor>
588
+ <role type='author'/>
589
+ <organization>
590
+ <name>International Standards Organization</name>
591
+ <subdivision>Subdivision</subdivision>
592
+ <abbreviation>SD</abbreviation>
593
+ <address>
594
+ <formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
595
+ </address>
596
+ <phone>3333333</phone>
597
+ <phone type='fax'>4444444</phone>
598
+ <email>x@example.com</email>
599
+ <uri>http://www.example.com</uri>
600
+ </organization>
601
+ </contributor>
602
+ <contributor>
603
+ <role type='publisher'/>
604
+ <organization>
605
+ <name>International Standards Organization</name>
606
+ <subdivision>Subdivision</subdivision>
607
+ <abbreviation>SD</abbreviation>
608
+ <address>
609
+ <formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
610
+ </address>
611
+ <phone>3333333</phone>
612
+ <phone type='fax'>4444444</phone>
613
+ <email>x@example.com</email>
614
+ <uri>http://www.example.com</uri>
615
+ </organization>
616
+ </contributor>
617
+ <version>
618
+ <revision-date>2000-01</revision-date>
619
+ </version>
620
+ <language>el</language>
621
+ <script>Grek</script>
622
+ <status>
623
+ <stage>published</stage>
624
+ </status>
625
+ <copyright>
626
+ <from>2020</from>
627
+ <owner>
628
+ <organization>
629
+ <name>International Standards Organization</name>
630
+ <subdivision>Subdivision</subdivision>
631
+ <abbreviation>SD</abbreviation>
632
+ <address>
633
+ <formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
634
+ </address>
635
+ <phone>3333333</phone>
636
+ <phone type='fax'>4444444</phone>
637
+ <email>x@example.com</email>
638
+ <uri>http://www.example.com</uri>
639
+ </organization>
640
+ </owner>
641
+ </copyright>
642
+ <ext>
643
+ <doctype>this-is-a-doctype</doctype>
644
+ </ext>
645
+ </bibdata>
646
+ <sections> </sections>
647
+ </standard-document>
648
+
649
+ OUTPUT
650
+ end
651
+
445
652
  it "reads scripts into blank HTML document" do
446
653
  FileUtils.rm_f "test.html"
447
654
  Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
@@ -526,6 +733,36 @@ QU1FOiB0ZXN0Cgo=
526
733
  ])
527
734
  end
528
735
 
736
+ it "test submitting-organizations with delimiter in end" do
737
+ FileUtils.rm_f "test.doc"
738
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
739
+ = Document title
740
+ Author
741
+ :docfile: test.adoc
742
+ :doctype: standard
743
+ :encoding: utf-8
744
+ :lang: en
745
+ :submitting-organizations: Organization One; Organization Two;
746
+ :publisher: "Hanna Barbera", "Cartoon Network", "Ribose, Inc.",
747
+ INPUT
748
+ expect(File.exist?("test.doc")).to be true
749
+ end
750
+
751
+ private
752
+
753
+ def mock_org_abbrevs
754
+ allow_any_instance_of(::Asciidoctor::Standoc::Front).to receive(:org_abbrev).and_return(
755
+ { "International Standards Organization" => "ISO",
756
+ "International Electrotechnical Commission" => "IEC" }
757
+ )
758
+ end
759
+
760
+ def mock_default_publisher
761
+ allow_any_instance_of(::Asciidoctor::Standoc::Front).to receive(:default_publisher).and_return(
762
+ "International Standards Organization"
763
+ )
764
+ end
765
+
529
766
 
530
767
  end
531
768