metanorma-standoc 2.8.2 → 2.8.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2015e269893b92d91e3b1f7fabe93f706693d7a45da1719daac5b60e04f0011
4
- data.tar.gz: 2ac72c8476a05968b34648c05eec685f8339dfbe711780ed7b1b7f646c94aa2e
3
+ metadata.gz: 76c0e218fd82abc53141b42753ee4cbc14956ee9ccc75f1e8115bf91ac6a0eb6
4
+ data.tar.gz: 532c96be450bb8f4a234ec5f6cd6c032d71fe89e20ad46e1f48195137b108c94
5
5
  SHA512:
6
- metadata.gz: 1df98678c7d010abdbdc9c4ba754ca1892ce75c5d4aa7bb882642bca4e3b4df725c9b3ae01b208a0b0cfe77dbf23eec2d7742e5a402c574479170f1140ebc71b
7
- data.tar.gz: 6340b42bc795cc70c3184a5d3b268c726dec16705f1396a6fc3d298c882eaf0b21d08f8bb0d982db30829518b24a6f09256361218d10b3ff8083ac00c1aadd68
6
+ metadata.gz: bab6d097fc885f64299d90ceed88dc475c951ff7c916f176e504aaca63336b69e62bb12c48059004fe757200a448a15fd4c798ffcd2e7f9b7c04444259431799
7
+ data.tar.gz: 6acb021a5f5348caa7c625db4d54a9a2af9e26e1720318cdd77a54c77bc0c734109c600d96a95d2a5a161bc5eb28f6db2336f06dee75bd896733fef8a600f1bf
@@ -338,29 +338,32 @@
338
338
  </define>
339
339
  <define name="organization">
340
340
  <element name="organization">
341
- <oneOrMore>
342
- <ref name="orgname"/>
343
- </oneOrMore>
344
- <zeroOrMore>
345
- <ref name="subdivision"/>
346
- </zeroOrMore>
347
- <optional>
348
- <ref name="abbreviation"/>
349
- </optional>
350
- <zeroOrMore>
351
- <ref name="uri"/>
352
- </zeroOrMore>
353
- <zeroOrMore>
354
- <ref name="org-identifier"/>
355
- </zeroOrMore>
356
- <zeroOrMore>
357
- <ref name="contact"/>
358
- </zeroOrMore>
359
- <optional>
360
- <ref name="logo"/>
361
- </optional>
341
+ <ref name="OrganizationType"/>
362
342
  </element>
363
343
  </define>
344
+ <define name="OrganizationType">
345
+ <oneOrMore>
346
+ <ref name="orgname"/>
347
+ </oneOrMore>
348
+ <zeroOrMore>
349
+ <ref name="subdivision"/>
350
+ </zeroOrMore>
351
+ <optional>
352
+ <ref name="abbreviation"/>
353
+ </optional>
354
+ <zeroOrMore>
355
+ <ref name="uri"/>
356
+ </zeroOrMore>
357
+ <zeroOrMore>
358
+ <ref name="org-identifier"/>
359
+ </zeroOrMore>
360
+ <zeroOrMore>
361
+ <ref name="contact"/>
362
+ </zeroOrMore>
363
+ <optional>
364
+ <ref name="logo"/>
365
+ </optional>
366
+ </define>
364
367
  <define name="orgname">
365
368
  <element name="name">
366
369
  <choice>
@@ -371,10 +374,10 @@
371
374
  </define>
372
375
  <define name="subdivision">
373
376
  <element name="subdivision">
374
- <choice>
375
- <ref name="LocalizedString"/>
376
- <ref name="NameWithVariants"/>
377
- </choice>
377
+ <optional>
378
+ <attribute name="type"/>
379
+ </optional>
380
+ <ref name="OrganizationType"/>
378
381
  </element>
379
382
  </define>
380
383
  <define name="logo">
@@ -22,8 +22,7 @@ module Metanorma
22
22
 
23
23
  def insert_thead(table)
24
24
  thead = table.at("./thead")
25
- return thead unless thead.nil?
26
-
25
+ thead.nil? or return thead
27
26
  if tname = table.at("./name")
28
27
  thead = tname.add_next_sibling("<thead/>").first
29
28
  return thead
@@ -35,8 +34,7 @@ module Metanorma
35
34
  xmldoc.xpath("//table[@headerrows]").each do |s|
36
35
  thead = insert_thead(s)
37
36
  (thead.xpath("./tr").size...s["headerrows"].to_i).each do
38
- row = s.at("./tbody/tr")
39
- row.parent = thead
37
+ s.at("./tbody/tr").parent = thead
40
38
  end
41
39
  thead.xpath(".//td").each { |n| n.name = "th" }
42
40
  s.delete("headerrows")
@@ -21,6 +21,14 @@ module Metanorma
21
21
  # schema encapsulation of the document for validation
22
22
  class Converter
23
23
  Asciidoctor::Extensions.register do
24
+ preprocessor Metanorma::Plugin::Lutaml::LutamlPreprocessor
25
+ preprocessor Metanorma::Plugin::Lutaml::LutamlUmlAttributesTablePreprocessor
26
+ preprocessor Metanorma::Plugin::Lutaml::LutamlUmlDatamodelDescriptionPreprocessor
27
+ preprocessor Metanorma::Plugin::Lutaml::LutamlUmlClassPreprocessor
28
+ inline_macro Metanorma::Plugin::Lutaml::LutamlFigureInlineMacro
29
+ inline_macro Metanorma::Plugin::Lutaml::LutamlTableInlineMacro
30
+ block_macro Metanorma::Plugin::Lutaml::LutamlDiagramBlockMacro
31
+ block Metanorma::Plugin::Lutaml::LutamlDiagramBlock
24
32
  preprocessor Metanorma::Standoc::EmbedIncludeProcessor
25
33
  preprocessor Metanorma::Standoc::LinkProtectPreprocessor
26
34
  preprocessor Metanorma::Standoc::Datamodel::AttributesTablePreprocessor
@@ -14,8 +14,8 @@ module Metanorma
14
14
  # read include derectives that goes after that in block and transform
15
15
  # into yaml2text blocks
16
16
  def process(document, reader)
17
- input_lines = reader.readlines.to_enum
18
- Asciidoctor::Reader.new(processed_lines(document, input_lines))
17
+ input_lines = reader.lines.to_enum
18
+ Asciidoctor::PreprocessorReader.new(document, processed_lines(document, input_lines))
19
19
  end
20
20
 
21
21
  private
@@ -15,8 +15,8 @@ module Metanorma
15
15
  # read include derectives that goes after that in block and transform
16
16
  # into plantuml block
17
17
  def process(document, reader)
18
- input_lines = reader.readlines.to_enum
19
- Asciidoctor::Reader.new(processed_lines(document, input_lines))
18
+ input_lines = reader.lines.to_enum
19
+ Asciidoctor::PreprocessorReader.new(document, processed_lines(document, input_lines))
20
20
  end
21
21
 
22
22
  private
@@ -88,6 +88,8 @@ module Metanorma
88
88
  def metadata_sponsor(node, xml)
89
89
  o = { source: ["sponsor"], role: "enabler" }
90
90
  org_contributor(node, xml, o)
91
+ o = { source: ["authorizer"], role: "authorizer" }
92
+ org_contributor(node, xml, o)
91
93
  end
92
94
 
93
95
  def copyright_parse(node)
@@ -13,16 +13,48 @@ module Metanorma
13
13
  end
14
14
  end
15
15
 
16
- def organization(org, orgname, node = nil, default_org = nil)
16
+ def organization(org, orgname, node = nil, default_org = nil, attrs = {})
17
17
  abbrevs = org_abbrev
18
18
  n = abbrevs.invert[orgname] and orgname = n
19
19
  org.name orgname
20
- default_org and a = node&.attr("subdivision") and org.subdivision a
20
+ default_org && (a = node&.attr("subdivision")) && !attrs[:subdiv] and
21
+ subdivision(a, node&.attr("subdivision-abbr"), org)
22
+ a = attrs[:subdiv] and subdivision(a, nil, org)
21
23
  abbr = org_abbrev[orgname]
22
- default_org && b = node&.attr("subdivision-abbr") and abbr = b
23
24
  abbr and org.abbreviation abbr
24
25
  end
25
26
 
27
+ def subdivision(attr, abbr, org)
28
+ abbrs = csv_split(abbr) || []
29
+ subdivs = csv_split(attr, ";")
30
+ subdivs.size == abbrs.size or abbrs = []
31
+ subdivs.each_with_index do |s, i|
32
+ subdivision1(s, abbrs[i], org)
33
+ end
34
+ end
35
+
36
+ def subdivision1(attr, abbr, org)
37
+ m = csv_split(attr, ",").map do |s1|
38
+ t, v = s1.split(":", 2).map(&:strip)
39
+ if v.nil?
40
+ v = t
41
+ t = nil
42
+ end
43
+ { type: t, value: v }
44
+ end
45
+ abbr and m[0][:abbr] = abbr
46
+ subdiv_build(m, org)
47
+ end
48
+
49
+ def subdiv_build(list, org)
50
+ list.empty? and return
51
+ org.subdivision **attr_code(type: list[0][:type]) do |s|
52
+ s.name { |n| n << list[0][:value] }
53
+ subdiv_build(list[1..-1], s)
54
+ a = list[0][:abbr] and s.abbreviation { |n| n << a }
55
+ end
56
+ end
57
+
26
58
  def org_address(org, xml)
27
59
  p = org[:address] and xml.address do |ad|
28
60
  ad.formattedAddress do |f|
@@ -43,9 +75,8 @@ module Metanorma
43
75
  xml.name node.attr("affiliation#{suffix}")
44
76
  abbr = node.attr("affiliation_abbrev#{suffix}") and
45
77
  xml.abbreviation abbr
46
- csv_split(node.attr("affiliation_subdiv#{suffix}"))&.each do |s|
47
- xml.subdivision s
48
- end
78
+ a = node.attr("affiliation_subdiv#{suffix}") and
79
+ subdivision(a, nil, xml)
49
80
  person_address(node, suffix, xml)
50
81
  person_org_logo(node, suffix, xml)
51
82
  end
@@ -108,7 +139,7 @@ module Metanorma
108
139
  end
109
140
 
110
141
  def org_organization(node, xml, org)
111
- organization(xml, org[:name], node, !node.attr("publisher"))
142
+ organization(xml, org[:name], node, !node.attr("publisher"), org)
112
143
  org_address(org, xml)
113
144
  org_logo(xml, org[:logo])
114
145
  end
@@ -150,6 +181,7 @@ module Metanorma
150
181
  def extract_org_attrs_complex(node, opts, source, suffix)
151
182
  { name: node.attr(source + suffix),
152
183
  role: opts[:role], desc: opts[:desc],
184
+ subdiv: node.attr("#{source}_subdivision#{suffix}"),
153
185
  logo: node.attr("#{source}_logo#{suffix}") }.compact
154
186
  .merge(extract_org_attrs_address(node, opts, suffix))
155
187
  end
@@ -50,14 +50,14 @@ module Metanorma
50
50
  end
51
51
 
52
52
  class NamedEscapePreprocessor < Asciidoctor::Extensions::Preprocessor
53
- def process(_document, reader)
53
+ def process(document, reader)
54
54
  c = HTMLEntities.new
55
- lines = reader.readlines.map do |l|
56
- l.split(/(&[A-Za-z][^;]*;)/).map do |s|
55
+ lines = reader.lines.map do |l|
56
+ l.split(/(&[A-Za-z][^&;]*;)/).map do |s|
57
57
  /^&[A-Za-z]/.match?(s) ? c.encode(c.decode(s), :hexadecimal) : s
58
58
  end.join
59
59
  end
60
- ::Asciidoctor::Reader.new lines
60
+ ::Asciidoctor::PreprocessorReader.new document, lines
61
61
  end
62
62
  end
63
63
 
@@ -85,14 +85,14 @@ module Metanorma
85
85
  delimln: delimln }
86
86
  end
87
87
 
88
- def process(_document, reader)
88
+ def process(document, reader)
89
89
  p = init
90
- lines = reader.readlines.map do |t|
90
+ lines = reader.lines.map do |t|
91
91
  p = pass_status(p, t.rstrip)
92
92
  !p[:pass] && t.include?(":") and t = inlinelinkmacro(inlinelink(t))
93
93
  t
94
94
  end
95
- ::Asciidoctor::Reader.new lines
95
+ ::Asciidoctor::PreprocessorReader.new document, lines
96
96
  end
97
97
 
98
98
  def pass_status(status, text)
@@ -1,13 +1,22 @@
1
1
  require "pathname"
2
2
 
3
+ module Asciidoctor
4
+ class PreprocessorNoIfdefsReader < PreprocessorReader
5
+ def preprocess_conditional_directive(keyword, target, delimiter, text)
6
+ false # decline to resolve idefs
7
+ end
8
+ end
9
+ end
10
+
3
11
  module Metanorma
4
12
  module Standoc
5
13
  class EmbedIncludeProcessor < Asciidoctor::Extensions::Preprocessor
6
14
  def process(doc, reader)
7
15
  reader.eof? and return reader
8
- lines = reader.readlines
16
+ r = ::Asciidoctor::PreprocessorNoIfdefsReader.new doc, reader.lines
17
+ lines = r.readlines
9
18
  headings = lines.grep(/^== /).map(&:strip)
10
- ret = lines.each_with_object(embed_acc(doc, reader)) do |line, m|
19
+ ret = lines.each_with_object(embed_acc(doc, r)) do |line, m|
11
20
  process_line(line, m, headings)
12
21
  end
13
22
  return_to_document(doc, ret)
@@ -37,7 +46,8 @@ module Metanorma
37
46
  ret.reverse.each do |l|
38
47
  if l[:file]
39
48
  new = Pathname.new(l[:path]).relative_path_from(b).to_s
40
- reader.push_include l[:lines], new, l[:path]
49
+ #reader.push_include l[:lines], new, l[:path]
50
+ reader.unshift_lines l[:lines]
41
51
  else reader.unshift_lines l[:lines]
42
52
  end
43
53
  end
@@ -120,8 +130,8 @@ module Metanorma
120
130
  lines = filter_sections(read(inc_path), headings)
121
131
  n = Asciidoctor::Document
122
132
  .new [], { safe: :safe, base_dir: File.dirname(inc_path) }
123
- r = ::Asciidoctor::PreprocessorReader.new n, lines
124
- ret = embed_acc(n, r).merge(strip_header(r.read_lines))
133
+ r = ::Asciidoctor::PreprocessorNoIfdefsReader.new n, lines
134
+ ret = embed_acc(n, r).merge(strip_header(r.readlines))
125
135
  .merge(file: fname, path: inc_path, orig: acc[:orig])
126
136
  ret[:hdr] or
127
137
  raise "Embedding an incomplete document with no header: #{ret[:path]}"
@@ -26,7 +26,8 @@ module Metanorma
26
26
  end
27
27
 
28
28
  def csv_split(text, delim = ";")
29
- Metanorma::Utils::csv_split(text, delim)
29
+ Metanorma::Utils::csv_split(@c.decode(text), delim)
30
+ .map { |x| @c.encode(x, :basic, :hexadecimal) }
30
31
  end
31
32
 
32
33
  def wrap_in_para(node, out)
@@ -69,11 +70,11 @@ module Metanorma
69
70
  end
70
71
 
71
72
  def xml_encode(text)
72
- @c.encode(text, :basic, :hexadecimal).
73
- gsub("&amp;gt;", ">").gsub("&amp;lt;", "<").gsub("&amp;amp;", "&").
74
- gsub("&gt;", ">").gsub("&lt;", "<").gsub("&amp;", "&").
75
- gsub("&quot;", '"').gsub("&#xa;", "\n").gsub("&amp;#", "&#").
76
- gsub("&apos;", "'")
73
+ @c.encode(text, :basic, :hexadecimal)
74
+ .gsub("&amp;gt;", ">").gsub("&amp;lt;", "<").gsub("&amp;amp;", "&")
75
+ .gsub("&gt;", ">").gsub("&lt;", "<").gsub("&amp;", "&")
76
+ .gsub("&quot;", '"').gsub("&#xa;", "\n").gsub("&amp;#", "&#")
77
+ .gsub("&apos;", "'")
77
78
  end
78
79
 
79
80
  # wrapped in <sections>
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.8.2".freeze
22
+ VERSION = "2.8.3".freeze
23
23
  end
24
24
  end
@@ -31,11 +31,11 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "addressable", "~> 2.8.0"
32
32
  spec.add_dependency "asciidoctor", "~> 2.0.0"
33
33
  spec.add_dependency "iev", "~> 0.3.0"
34
- spec.add_dependency "isodoc", "~> 2.8.3"
34
+ spec.add_dependency "isodoc", "~> 2.9.0"
35
35
  spec.add_dependency "metanorma", ">= 1.6.0"
36
- spec.add_dependency "metanorma-plugin-datastruct", "~> 0.2.0"
37
- spec.add_dependency "metanorma-plugin-glossarist", "~> 0.1.1"
38
- spec.add_dependency "metanorma-plugin-lutaml"
36
+ spec.add_dependency "metanorma-plugin-datastruct", "~> 0.3.0"
37
+ spec.add_dependency "metanorma-plugin-glossarist", "~> 0.2.0"
38
+ spec.add_dependency "metanorma-plugin-lutaml", "~> 0.5.0"
39
39
  spec.add_dependency "ruby-jing"
40
40
  # relaton-cli not just relaton, to avoid circular reference in metanorma
41
41
  spec.add_dependency "asciimath2unitsml", "~> 0.4.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.2
4
+ version: 2.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-19 00:00:00.000000000 Z
11
+ date: 2024-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.8.3
61
+ version: 2.9.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.8.3
68
+ version: 2.9.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: metanorma
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -86,42 +86,42 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.2.0
89
+ version: 0.3.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.2.0
96
+ version: 0.3.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: metanorma-plugin-glossarist
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.1.1
103
+ version: 0.2.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.1.1
110
+ version: 0.2.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: metanorma-plugin-lutaml
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 0.5.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 0.5.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: ruby-jing
127
127
  requirement: !ruby/object:Gem::Requirement