metanorma-standoc 2.7.4 → 2.8.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67faf1005268886a18a869cd5cae9b22989946d6999317d446798521bd9b6728
4
- data.tar.gz: b3127ed75c593c211bda46f42cb1fe744f59b04337977a71e0213f2b1e6997a8
3
+ metadata.gz: ed917e2185484c68d9c76b23b7bf977ee03da83204d3ceae22fd4fc893b8dae0
4
+ data.tar.gz: c1c7af6fd9cb9a958093cb698beb2523d16bee5cdc4b4a06140092690753f44b
5
5
  SHA512:
6
- metadata.gz: bd52c09a6b065f0d097c277ec332c8d0b4dd9406fb6a71e42dfb514ba35b03b4d6f2316e6f808e55f99249b8b8c7f488fb137c65e044cb5b9abff2b8015d9824
7
- data.tar.gz: 61b6e99444cbd529626fcce026356070d5898f9607ef2239bbfd72d9445f15a81f8b06a5801057293d2838af8d300908365d566acd3ef66c3aedab0e9324c6d9
6
+ metadata.gz: 491207a21d304b30840b19398d547a1eb5e55037bd93c3c39397a9d31a725cde2de5e88348e984958639415f8ea38dcd6091fb5888825775934609e83c79cf53
7
+ data.tar.gz: aa771efa57e60c94ac9e8e65dc0fd00a6c9280a812ea1ecbc212cecb25547be7b492111a6fdcbfa0118ad855ca775772fbedfc1d83c92fd3d3fff68b89a8f950
data/Gemfile CHANGED
@@ -4,12 +4,6 @@ Encoding.default_internal = Encoding::UTF_8
4
4
  source "https://rubygems.org"
5
5
  git_source(:github) { |repo| "https://github.com/#{repo}" }
6
6
 
7
- group :development, :test do
8
- gem "rspec"
9
- end
10
-
11
- if File.exist? "Gemfile.devel"
12
- eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
13
- end
14
-
15
7
  gemspec
8
+
9
+ eval_gemfile("Gemfile.devel") rescue nil
@@ -140,6 +140,14 @@ a.FootnoteRef, span.FootnoteRef {
140
140
  color: red;
141
141
  text-decoration: line-through; }
142
142
 
143
+ ruby {
144
+ ruby-position: over;
145
+ -webkit-ruby-position: before; }
146
+
147
+ ruby ruby {
148
+ ruby-position: under;
149
+ -webkit-ruby-position: after; }
150
+
143
151
  /* code highlighting with line numbers */
144
152
  table.rouge-line-table td.rouge-gutter {
145
153
  -moz-user-select: none;
@@ -1,13 +1,11 @@
1
1
  require "date"
2
2
  require "nokogiri"
3
3
  require "htmlentities"
4
- require "json"
5
4
  require "pathname"
6
5
  require "isodoc"
7
6
  require "relaton"
8
7
  require "fileutils"
9
8
  require "metanorma-utils"
10
- require "isodoc/xslfo_convert"
11
9
  require_relative "render"
12
10
  require_relative "localbib"
13
11
  require "mn-requirements"
@@ -80,25 +78,29 @@ module Metanorma
80
78
  end
81
79
 
82
80
  def init_reqt(node)
83
- @default_requirement_model = (node.attr("requirements-model") ||
84
- default_requirement_model)
81
+ @default_requirement_model = node.attr("requirements-model") ||
82
+ default_requirement_model
85
83
  @reqt_models = requirements_processor
86
84
  .new({ default: @default_requirement_model })
87
85
  end
88
86
 
89
87
  def init_toc(node)
90
- @htmltoclevels = node.attr("htmltoclevels") ||
88
+ @htmltoclevels = node.attr("toclevels-html") ||
89
+ node.attr("htmltoclevels") ||
91
90
  node.attr("toclevels") || toc_default[:html_levels]
92
- @doctoclevels = node.attr("doctoclevels") ||
93
- node.attr("toclevels") || toc_default[:word_levels]
94
- @toclevels = node.attr("toclevels") || toc_default[:word_levels]
91
+ @doctoclevels = node.attr("toclevels-doc") ||
92
+ node.attr("doctoclevels") || node.attr("toclevels") ||
93
+ toc_default[:word_levels]
94
+ @pdftoclevels = node.attr("toclevels-pdf") ||
95
+ node.attr("toclevels") || toc_default[:pdf_levels]
96
+ @toclevels = node.attr("toclevels") || toc_default[:html_levels]
95
97
  @tocfigures = node.attr("toc-figures")
96
98
  @toctables = node.attr("toc-tables")
97
99
  @tocrecommendations = node.attr("toc-recommendations")
98
100
  end
99
101
 
100
102
  def toc_default
101
- { word_levels: 2, html_levels: 2 }
103
+ { word_levels: 2, html_levels: 2, pdf_levels: 2 }
102
104
  end
103
105
 
104
106
  def init_output(node)
@@ -113,9 +115,9 @@ module Metanorma
113
115
  end
114
116
 
115
117
  def init_i18n(node)
116
- @lang = (node.attr("language") || "en")
117
- @script = (node.attr("script") ||
118
- Metanorma::Utils.default_script(node.attr("language")))
118
+ @lang = node.attr("language") || "en"
119
+ @script = node.attr("script") ||
120
+ Metanorma::Utils.default_script(node.attr("language"))
119
121
  @locale = node.attr("locale")
120
122
  @isodoc = isodoc(@lang, @script, @locale, node.attr("i18nyaml"))
121
123
  @i18n = @isodoc.i18n
@@ -95,8 +95,89 @@
95
95
  <ref name="pagebreak"/>
96
96
  <ref name="hr"/>
97
97
  <ref name="bookmark"/>
98
+ <ref name="amend"/>
98
99
  </choice>
99
100
  </define>
101
+ <define name="amend">
102
+ <element name="amend">
103
+ <ref name="AmendType"/>
104
+ </element>
105
+ </define>
106
+ <define name="AmendType">
107
+ <optional>
108
+ <attribute name="id">
109
+ <data type="ID"/>
110
+ </attribute>
111
+ </optional>
112
+ <attribute name="change">
113
+ <choice>
114
+ <value>add</value>
115
+ <value>modify</value>
116
+ <value>delete</value>
117
+ <value>replace</value>
118
+ </choice>
119
+ </attribute>
120
+ <optional>
121
+ <attribute name="path"/>
122
+ </optional>
123
+ <optional>
124
+ <attribute name="path_end"/>
125
+ </optional>
126
+ <optional>
127
+ <attribute name="title"/>
128
+ </optional>
129
+ <optional>
130
+ <element name="location">
131
+ <zeroOrMore>
132
+ <choice>
133
+ <ref name="locality"/>
134
+ <ref name="localityStack"/>
135
+ </choice>
136
+ </zeroOrMore>
137
+ </element>
138
+ </optional>
139
+ <optional>
140
+ <element name="description">
141
+ <zeroOrMore>
142
+ <ref name="BasicBlock"/>
143
+ </zeroOrMore>
144
+ </element>
145
+ </optional>
146
+ <optional>
147
+ <element name="newcontent">
148
+ <optional>
149
+ <attribute name="id">
150
+ <data type="ID"/>
151
+ </attribute>
152
+ </optional>
153
+ <zeroOrMore>
154
+ <ref name="BasicBlock"/>
155
+ </zeroOrMore>
156
+ </element>
157
+ </optional>
158
+ <zeroOrMore>
159
+ <ref name="classification"/>
160
+ </zeroOrMore>
161
+ <zeroOrMore>
162
+ <ref name="contributor"/>
163
+ </zeroOrMore>
164
+ </define>
165
+ <define name="classification">
166
+ <element name="classification">
167
+ <ref name="classification_tag"/>
168
+ <ref name="classification_value"/>
169
+ </element>
170
+ </define>
171
+ <define name="classification_tag">
172
+ <element name="tag">
173
+ <text/>
174
+ </element>
175
+ </define>
176
+ <define name="classification_value">
177
+ <element name="value">
178
+ <text/>
179
+ </element>
180
+ </define>
100
181
  <define name="paragraph">
101
182
  <element name="p">
102
183
  <ref name="ParagraphType"/>
@@ -715,27 +796,36 @@
715
796
  </define>
716
797
  <define name="ruby">
717
798
  <element name="ruby">
718
- <zeroOrMore>
719
- <choice>
720
- <ref name="PureTextElement"/>
721
- <ref name="rp"/>
722
- <ref name="rt"/>
723
- </choice>
724
- </zeroOrMore>
799
+ <choice>
800
+ <ref name="ruby_pronunciation"/>
801
+ <ref name="ruby_annotation"/>
802
+ </choice>
803
+ <choice>
804
+ <text/>
805
+ <ref name="ruby"/>
806
+ </choice>
725
807
  </element>
726
808
  </define>
727
- <define name="rp">
728
- <element name="rp">
729
- <zeroOrMore>
730
- <ref name="PureTextElement"/>
731
- </zeroOrMore>
809
+ <define name="ruby_pronunciation">
810
+ <element name="pronunciation">
811
+ <attribute name="value"/>
812
+ <optional>
813
+ <attribute name="script"/>
814
+ </optional>
815
+ <optional>
816
+ <attribute name="lang"/>
817
+ </optional>
732
818
  </element>
733
819
  </define>
734
- <define name="rt">
735
- <element name="rt">
736
- <zeroOrMore>
737
- <ref name="PureTextElement"/>
738
- </zeroOrMore>
820
+ <define name="ruby_annotation">
821
+ <element name="annotation">
822
+ <attribute name="value"/>
823
+ <optional>
824
+ <attribute name="script"/>
825
+ </optional>
826
+ <optional>
827
+ <attribute name="lang"/>
828
+ </optional>
739
829
  </element>
740
830
  </define>
741
831
  <define name="br">
@@ -930,18 +1020,12 @@
930
1020
  </optional>
931
1021
  <optional>
932
1022
  <attribute name="width">
933
- <choice>
934
- <data type="int"/>
935
- <value>auto</value>
936
- </choice>
1023
+ <ref name="ImageSize"/>
937
1024
  </attribute>
938
1025
  </optional>
939
1026
  <optional>
940
1027
  <attribute name="height">
941
- <choice>
942
- <data type="int"/>
943
- <value>auto</value>
944
- </choice>
1028
+ <ref name="ImageSize"/>
945
1029
  </attribute>
946
1030
  </optional>
947
1031
  <optional>
@@ -956,6 +1040,14 @@
956
1040
  </attribute>
957
1041
  </optional>
958
1042
  </define>
1043
+ <define name="ImageSize">
1044
+ <choice>
1045
+ <data type="string">
1046
+ <param name="pattern">\d+([.]\d+)?(%?)</param>
1047
+ </data>
1048
+ <value>auto</value>
1049
+ </choice>
1050
+ </define>
959
1051
  <define name="video">
960
1052
  <element name="video">
961
1053
  <attribute name="id">
@@ -9,11 +9,42 @@
9
9
  -->
10
10
  <include href="biblio.rng">
11
11
  <define name="BibData">
12
- <ref name="BibliographicItem"/>
12
+ <ref name="StandardBibliographicItem"/>
13
13
  <optional>
14
14
  <ref name="ext"/>
15
15
  </optional>
16
16
  </define>
17
+ <define name="docrelation">
18
+ <element name="relation">
19
+ <attribute name="type">
20
+ <ref name="DocRelationType"/>
21
+ </attribute>
22
+ <optional>
23
+ <element name="description">
24
+ <ref name="FormattedString"/>
25
+ </element>
26
+ </optional>
27
+ <element name="bibitem">
28
+ <ref name="StandardReducedBibliographicItem"/>
29
+ </element>
30
+ <choice>
31
+ <zeroOrMore>
32
+ <ref name="locality"/>
33
+ </zeroOrMore>
34
+ <zeroOrMore>
35
+ <ref name="localityStack"/>
36
+ </zeroOrMore>
37
+ </choice>
38
+ <choice>
39
+ <zeroOrMore>
40
+ <ref name="sourceLocality"/>
41
+ </zeroOrMore>
42
+ <zeroOrMore>
43
+ <ref name="sourceLocalityStack"/>
44
+ </zeroOrMore>
45
+ </choice>
46
+ </element>
47
+ </define>
17
48
  </include>
18
49
  <define name="ext">
19
50
  <element name="ext">
@@ -161,4 +192,16 @@
161
192
  </optional>
162
193
  </element>
163
194
  </define>
195
+ <define name="StandardBibliographicItem">
196
+ <ref name="BibliographicItem"/>
197
+ <zeroOrMore>
198
+ <ref name="amend"/>
199
+ </zeroOrMore>
200
+ </define>
201
+ <define name="StandardReducedBibliographicItem">
202
+ <ref name="ReducedBibliographicItem"/>
203
+ <zeroOrMore>
204
+ <ref name="amend"/>
205
+ </zeroOrMore>
206
+ </define>
164
207
  </grammar>
@@ -241,6 +241,9 @@
241
241
  </element>
242
242
  </define>
243
243
  <define name="FullNameType">
244
+ <optional>
245
+ <ref name="name_abbreviation"/>
246
+ </optional>
244
247
  <choice>
245
248
  <group>
246
249
  <zeroOrMore>
@@ -266,6 +269,11 @@
266
269
  <ref name="variantname"/>
267
270
  </zeroOrMore>
268
271
  </define>
272
+ <define name="name_abbreviation">
273
+ <element name="abbreviation">
274
+ <ref name="LocalizedString"/>
275
+ </element>
276
+ </define>
269
277
  <define name="prefix">
270
278
  <element name="prefix">
271
279
  <ref name="LocalizedString"/>
@@ -870,6 +878,9 @@
870
878
  <optional>
871
879
  <ref name="validity"/>
872
880
  </optional>
881
+ <optional>
882
+ <ref name="depiction"/>
883
+ </optional>
873
884
  </define>
874
885
  <define name="btitle">
875
886
  <element name="title">
@@ -71,6 +71,8 @@ module Metanorma
71
71
  mathml_cleanup(xmldoc)
72
72
  script_cleanup(xmldoc)
73
73
  docidentifier_cleanup(xmldoc) # feeds: bibdata_cleanup
74
+ ext_contributor_cleanup(xmldoc) # feeds: bibdata_cleanup
75
+ ext_dochistory_cleanup(xmldoc) # feeds: bibdata_cleanup
74
76
  bibdata_cleanup(xmldoc)
75
77
  svgmap_cleanup(xmldoc) # feeds: img_cleanup
76
78
  boilerplate_cleanup(xmldoc)
@@ -19,9 +19,10 @@ module Metanorma
19
19
  def create_amend1(clause, amend)
20
20
  create_amend2(clause, amend)
21
21
  d = amend.at("./description")
22
- d.xpath(".//autonumber").each { |e| d.previous = e }
22
+ autonum = d.xpath(".//autonumber").map(&:remove)
23
23
  d.xpath(".//p[normalize-space(.)='']").each(&:remove)
24
24
  move_attrs_to_amend(clause, amend)
25
+ autonum.each { |a| amend << a }
25
26
  amend
26
27
  end
27
28
 
@@ -46,17 +46,16 @@ module Metanorma
46
46
  end
47
47
 
48
48
  def indirect_eref_to_xref(eref, ident)
49
- loc = eref.at("./localityStack[locality[@type = 'anchor']]")
50
- &.remove&.text ||
51
- eref.at("./locality[@type = 'anchor']")&.remove&.text || ident
49
+ loc = eref.at("./localityStack[locality[@type = 'anchor']]") ||
50
+ eref.at("./locality[@type = 'anchor']")
51
+ loc = loc&.remove&.text || ident
52
52
  eref.name = "xref"
53
53
  eref.delete("bibitemid")
54
54
  eref.delete("citeas")
55
55
  eref["target"] = loc
56
- unless eref.document.at("//*[@id = '#{loc}']")
57
- eref.children = %(** Missing target #{loc})
58
- eref["target"] = ident
59
- end
56
+ eref.document.at("//*[@id = '#{loc}']") and return
57
+ eref.children = %(** Missing target #{loc})
58
+ eref["target"] = ident
60
59
  end
61
60
 
62
61
  def resolve_local_indirect_erefs(xmldoc, refs, prefix)
@@ -122,6 +121,118 @@ module Metanorma
122
121
  .each { |x| x << ident.text }
123
122
  end
124
123
  end
124
+
125
+ def ext_contributor_cleanup(xmldoc)
126
+ t = xmldoc.xpath("//metanorma-extension/clause/title").detect do |x|
127
+ x.text.strip.casecmp("contributor metadata").zero?
128
+ end or return
129
+ a = t.at("../sourcecode") or return
130
+ ins = xmldoc.at("//bibdata/contributor[last()]")
131
+ yaml = YAML.safe_load(a.text, permitted_classes: [Date])
132
+ ext_contributors_process(yaml, ins)
133
+ end
134
+
135
+ def yaml2relaton(yaml, amend = nil)
136
+ r = RelatonBib.parse_yaml(yaml.to_yaml, [Date], symbolize_names: true)
137
+ h = RelatonBib::HashConverter.hash_to_bib(r)
138
+ b = RelatonBib::BibliographicItem.new(**h).to_xml
139
+ amend and b.sub!("</bibitem>", "#{amend}</bibitem>")
140
+ b
141
+ end
142
+
143
+ def ext_contributors_process(yaml, ins)
144
+ yaml.is_a?(Hash) && !yaml["contributor"] and yaml = [yaml]
145
+ yaml.is_a?(Array) and yaml = { "contributor" => yaml }
146
+ r = yaml2relaton(yaml)
147
+ Nokogiri::XML(r).xpath("//contributor").reverse
148
+ .each do |c|
149
+ ins.next = c
150
+ end
151
+ end
152
+
153
+ def bib_relation_insert_pt(xmldoc)
154
+ ins = nil
155
+ %w(relation copyright status abstract script language note version
156
+ edition contributor).each do |x|
157
+ ins = xmldoc.at("//bibdata/#{x}[last()]") and break
158
+ end
159
+ ins
160
+ end
161
+
162
+ def ext_dochistory_cleanup(xmldoc)
163
+ t = xmldoc.xpath("//metanorma-extension/clause/title").detect do |x|
164
+ x.text.strip.casecmp("document history").zero?
165
+ end or return
166
+ a = t.at("../sourcecode") or return
167
+ ins = bib_relation_insert_pt(xmldoc) or return
168
+ docid = xmldoc.at("//bibdata/docidentifier")
169
+ yaml = YAML.safe_load(a.text, permitted_classes: [Date])
170
+ ext_dochistory_process(yaml, ins, docid)
171
+ end
172
+
173
+ def ext_dochistory_process(yaml, ins, docid)
174
+ yaml.is_a?(Hash) and yaml = [yaml]
175
+ yaml.reverse.each do |y|
176
+ type = y["relation.type"] || "updatedBy"
177
+ docid and
178
+ y["docid"] ||= [{ "type" => docid["type"], "id" => docid.text }]
179
+ r = yaml2relaton(y, amend_hash2mn(y["amend"]))
180
+ ins.next = "<relation type='#{type}'>#{r}</relation>"
181
+ end
182
+ end
183
+
184
+ def amend_hash2mn(yaml)
185
+ yaml.nil? and return ""
186
+ yaml.is_a?(Hash) and yaml = [yaml]
187
+ yaml.map { |x| amend_hash2mn1(x) }.join("\n")
188
+ end
189
+
190
+ def amend_attrs(yaml)
191
+ ret = ""
192
+ yaml["change"] ||= "modify"
193
+ %w(change path path_end title).each do |x|
194
+ a = yaml[x] and ret += " #{x}='#{a}'"
195
+ end
196
+ ret = "<amend#{ret}>"
197
+ end
198
+
199
+ def amend_hash2mn1(yaml)
200
+ ret = amend_attrs(yaml)
201
+ ret += amend_description(yaml)
202
+ ret += amend_location(yaml)
203
+ ret += amend_classification(yaml)
204
+ "#{ret}</amend>"
205
+ end
206
+
207
+ def amend_location(yaml)
208
+ a = yaml["location"] or return ""
209
+ a.is_a?(Array) or a = [a]
210
+ ret = a.map do |x|
211
+ elem = Nokogiri::XML("<location>#{x}</location>").root
212
+ extract_localities(elem)
213
+ elem.children.to_xml
214
+ end.join("\n")
215
+ "<location>#{ret}</location>"
216
+ end
217
+
218
+ def amend_description(yaml)
219
+ a = yaml["description"] or return ""
220
+ out = adoc2xml(a, backend.to_sym)
221
+ "<description>#{out.children.to_xml}</description>"
222
+ end
223
+
224
+ def amend_classification(yaml)
225
+ a = yaml["classification"] or return ""
226
+ a.is_a?(Array) or a = [a]
227
+ a.map { |x| amend_classification1(x) }.join("\n")
228
+ end
229
+
230
+ def amend_classification1(yaml)
231
+ yaml.is_a?(Hash) or yaml = { "tag" => "default", "value" => yaml }
232
+ <<~OUT
233
+ <classification><tag>#{yaml['tag']}</tag><value>#{yaml['value']}</value></classification>
234
+ OUT
235
+ end
125
236
  end
126
237
  end
127
238
  end
@@ -1,3 +1,5 @@
1
+ require "vectory"
2
+
1
3
  module Metanorma
2
4
  module Standoc
3
5
  module Cleanup
@@ -5,7 +7,7 @@ module Metanorma
5
7
  svg_uniqueids(xmldoc)
6
8
  svgmap_moveattrs(xmldoc)
7
9
  svgmap_populate(xmldoc)
8
- Metanorma::Utils::svgmap_rewrite(xmldoc, @localdir)
10
+ Vectory::SvgMapping.new(xmldoc, @localdir).call
9
11
  end
10
12
 
11
13
  def guid?(str)
@@ -64,7 +66,7 @@ module Metanorma
64
66
  xmldoc.xpath("//image").each do |i|
65
67
  # do not datauri encode SVG, we need to deduplicate its IDs
66
68
  unless read_in_if_svg(i, @localdir)
67
- i["src"] = Metanorma::Utils::datauri(i["src"], @localdir)
69
+ i["src"] = Vectory::Utils::datauri(i["src"], @localdir)
68
70
  end
69
71
  end
70
72
  end
@@ -75,7 +77,7 @@ module Metanorma
75
77
  def read_in_if_svg(img, localdir)
76
78
  return false unless img["src"]
77
79
 
78
- path = Metanorma::Utils::svgmap_rewrite0_path(img["src"], localdir)
80
+ path = Vectory::Utils.svgmap_rewrite0_path(img["src"], localdir)
79
81
  File.file?(path) or return false
80
82
  types = MIME::Types.type_for(path) or return false
81
83
  types.first == "image/svg+xml" or return false
@@ -78,7 +78,7 @@ module Metanorma
78
78
  end
79
79
 
80
80
  def toc_metadata(xmldoc)
81
- @htmltoclevels || @doctoclevels || @toclevels or return
81
+ @htmltoclevels || @doctoclevels || @pdftoclevels || @toclevels or return
82
82
  ins = add_misc_container(xmldoc)
83
83
  toc_metadata1(ins)
84
84
  end
@@ -86,7 +86,8 @@ module Metanorma
86
86
  def toc_metadata1(ins)
87
87
  [[@toclevels, "TOC Heading Levels"],
88
88
  [@htmltoclevels, "HTML TOC Heading Levels"],
89
- [@doctoclevels, "DOC TOC Heading Levels"]].each do |n|
89
+ [@doctoclevels, "DOC TOC Heading Levels"],
90
+ [@pdftoclevels, "PDF TOC Heading Levels"]].each do |n|
90
91
  n[0] and ins << "<presentation-metadata><name>#{n[1]}</name>" \
91
92
  "<value>#{n[0]}</value></presentation-metadata>"
92
93
  end
@@ -2,8 +2,10 @@ module Metanorma
2
2
  module Standoc
3
3
  module Cleanup
4
4
  # extending localities to cover ISO referencing
5
+ CONN_REGEX_STR = "(?<conn>and|or|from|to)!".freeze
6
+
5
7
  LOCALITY_REGEX_STR = <<~REGEXP.freeze
6
- ^(((?<conn>and|or|from|to)!)?
8
+ ^((#{CONN_REGEX_STR})?
7
9
  (?<locality>section|clause|part|paragraph|chapter|page|line|
8
10
  table|annex|figure|example|note|formula|list|time|anchor|
9
11
  locality:[^ \\t\\n\\r:,;=]+)(\\s+|=)
@@ -15,6 +17,15 @@ module Metanorma
15
17
  LOCALITY_RE = Regexp.new(LOCALITY_REGEX_STR.gsub(/\s/, ""),
16
18
  Regexp::IGNORECASE | Regexp::MULTILINE)
17
19
 
20
+ LOCALITY_REGEX_VALUE_ONLY_STR = <<~REGEXP.freeze
21
+ ^(?<conn0>(#{CONN_REGEX_STR}))
22
+ (?!whole|title|locality:)
23
+ (?<value>[^=,;:\\t\\n\\r]+)
24
+ (?<punct>[,;\\t\\n\\r]|$)
25
+ REGEXP
26
+ LOCALITY_VAL_ONLY_RE = Regexp.new(LOCALITY_REGEX_VALUE_ONLY_STR
27
+ .gsub(/\s/, ""), Regexp::IGNORECASE | Regexp::MULTILINE)
28
+
18
29
  def tq(text)
19
30
  text.sub(/^"/, "").sub(/"$/, "")
20
31
  end
@@ -33,13 +44,22 @@ module Metanorma
33
44
  b = elem.add_child("<localityStack/>").first if LOCALITY_RE.match text
34
45
  while (m = LOCALITY_RE.match text)
35
46
  add_locality(b, m)
36
- text = m[:text]
47
+ text = extract_localities_update_text(m)
37
48
  b = elem.add_child("<localityStack/>").first if m[:punct] == ";"
38
49
  end
39
50
  fill_in_eref_connectives(elem)
40
51
  elem.add_child(text) if text
41
52
  end
42
53
 
54
+ # clause=3;and!5 => clause=3;and!clause=5
55
+ def extract_localities_update_text(match)
56
+ ret = match[:text]
57
+ if LOCALITY_VAL_ONLY_RE.match?(ret) && match[:punct] == ";"
58
+ ret.sub!(%r{^(#{CONN_REGEX_STR})}o, "\\1#{match[:locality]}=")
59
+ end
60
+ ret
61
+ end
62
+
43
63
  def add_locality(stack, match)
44
64
  stack.children.empty? && match[:conn] and
45
65
  stack["connective"] = match[:conn]
@@ -22,7 +22,12 @@ module Metanorma
22
22
 
23
23
  def personal_role(node, contrib, suffix)
24
24
  type = node.attr("role#{suffix}")&.downcase || "author"
25
- contrib.role type: type
25
+ desc = node.attr("role-description#{suffix}")
26
+ contrib.role type: type do |r|
27
+ desc and r.description do |d|
28
+ d << desc
29
+ end
30
+ end
26
31
  end
27
32
 
28
33
  def personal_contact(node, suffix, person)
@@ -29,6 +29,10 @@ module Metanorma
29
29
  f << p.gsub(/ \+\n/, "<br/>")
30
30
  end
31
31
  end
32
+ org_contact(org, xml)
33
+ end
34
+
35
+ def org_contact(org, xml)
32
36
  p = org[:phone] and xml.phone p
33
37
  p = org[:fax] and xml.phone p, type: "fax"
34
38
  p = org[:email] and xml.email p
@@ -124,7 +124,7 @@ module Metanorma
124
124
  if Gem.win_platform? && /^\/[a-zA-Z]:/.match?(uri)
125
125
  uri = uri[1..-1]
126
126
  end
127
- types = if /^data:/.match?(uri) then Metanorma::Utils::datauri2mime(uri)
127
+ types = if /^data:/.match?(uri) then Vectory::Utils::datauri2mime(uri)
128
128
  else MIME::Types.type_for(uri)
129
129
  end
130
130
  type = types.first.to_s
@@ -17,10 +17,19 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.2.9 -->
20
+ <!-- VERSION v1.2.12 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
24
+ <define name="amend">
25
+ <element name="amend">
26
+ <ref name="BlockAttributes"/>
27
+ <ref name="AmendType"/>
28
+ <zeroOrMore>
29
+ <ref name="autonumber"/>
30
+ </zeroOrMore>
31
+ </element>
32
+ </define>
24
33
  <define name="admonition">
25
34
  <element name="admonition">
26
35
  <attribute name="type">
@@ -2319,69 +2328,6 @@
2319
2328
  <ref name="CitationType"/>
2320
2329
  </element>
2321
2330
  </define>
2322
- <define name="amend">
2323
- <element name="amend">
2324
- <optional>
2325
- <attribute name="id">
2326
- <data type="ID"/>
2327
- </attribute>
2328
- </optional>
2329
- <attribute name="change">
2330
- <choice>
2331
- <value>add</value>
2332
- <value>modify</value>
2333
- <value>delete</value>
2334
- <value>replace</value>
2335
- </choice>
2336
- </attribute>
2337
- <optional>
2338
- <attribute name="path"/>
2339
- </optional>
2340
- <optional>
2341
- <attribute name="path_end"/>
2342
- </optional>
2343
- <optional>
2344
- <attribute name="title"/>
2345
- </optional>
2346
- <ref name="BlockAttributes"/>
2347
- <optional>
2348
- <element name="location">
2349
- <zeroOrMore>
2350
- <ref name="locality"/>
2351
- </zeroOrMore>
2352
- </element>
2353
- </optional>
2354
- <zeroOrMore>
2355
- <ref name="autonumber"/>
2356
- </zeroOrMore>
2357
- <optional>
2358
- <element name="description">
2359
- <zeroOrMore>
2360
- <ref name="BasicBlock"/>
2361
- </zeroOrMore>
2362
- </element>
2363
- </optional>
2364
- <optional>
2365
- <element name="newcontent">
2366
- <optional>
2367
- <attribute name="id">
2368
- <data type="ID"/>
2369
- </attribute>
2370
- </optional>
2371
- <zeroOrMore>
2372
- <ref name="BasicBlock"/>
2373
- </zeroOrMore>
2374
- </element>
2375
- </optional>
2376
- <optional>
2377
- <element name="description">
2378
- <zeroOrMore>
2379
- <ref name="BasicBlock"/>
2380
- </zeroOrMore>
2381
- </element>
2382
- </optional>
2383
- </element>
2384
- </define>
2385
2331
  <define name="autonumber">
2386
2332
  <element name="autonumber">
2387
2333
  <attribute name="type">
@@ -52,25 +52,32 @@ module Metanorma
52
52
  use_dsl
53
53
  named :ruby
54
54
  parse_content_as :text
55
- option :pos_attrs, %w(rpbegin rt rpend)
56
-
57
- # for example, html5ruby:楽聖少女[がくせいしょうじょ]
58
- def process(_parent, target, attributes)
59
- rpbegin = "("
60
- rpend = ")"
61
- if (attributes.size == 1) && attributes.key?("text")
62
- rt = attributes["text"]
63
- elsif (attributes.size == 2) && attributes.key?(1) &&
64
- attributes.key?("rpbegin")
65
- rt = attributes[1] || ""
66
- else
67
- rpbegin = attributes["rpbegin"]
68
- rt = attributes["rt"]
69
- rpend = attributes["rpend"]
55
+
56
+ # ruby:{annotation}[lang=ja,script=Hira,type=pronunciation|annotation,text]
57
+
58
+ def preprocess_attrs(text)
59
+ ret = {}
60
+ while m = /^(?<key>lang|script|type)=(?<val>[^,]+),(?<rest>.+)$/
61
+ .match(text)
62
+ text = m[:rest]
63
+ ret[m[:key].to_sym] = m[:val]
70
64
  end
65
+ ret[:text] = text
66
+ ret[:type] ||= "pronunciation"
67
+ ret[:type] == "annotation" or ret[:type] = "pronunciation"
68
+ ret
69
+ end
71
70
 
72
- "<ruby>#{target}<rp>#{rpbegin}</rp><rt>#{rt}</rt>" \
73
- "<rp>#{rpend}</rp></ruby>"
71
+ def process(parent, target, attributes)
72
+ args = preprocess_attrs(attributes["text"])
73
+ out = Nokogiri::XML(
74
+ create_block(parent, :paragraph, [args[:text]], {},
75
+ subs: [:macros], content_model: :simple).convert,
76
+ ).root.children.to_xml # force recurse macros
77
+ attrs = " value='#{target}'"
78
+ x = args[:lang] and attrs += " lang='#{x}'"
79
+ x = args[:script] and attrs += " script='#{x}'"
80
+ "<ruby><#{args[:type]} #{attrs}/>#{out}</ruby>"
74
81
  end
75
82
  end
76
83
 
@@ -17,8 +17,9 @@ module Metanorma
17
17
  scripts_override: node.attr("scripts-override"),
18
18
  scripts_pdf: node.attr("scripts-pdf"),
19
19
  datauriimage: node.attr("data-uri-image") != "false",
20
- htmltoclevels: node.attr("htmltoclevels") || node.attr("toclevels"),
21
- doctoclevels: node.attr("doctoclevels") || node.attr("toclevels"),
20
+ htmltoclevels: @htmltoclevels,
21
+ doctoclevels: @doctoclevels,
22
+ pdftoclevels: @pdftoclevels,
22
23
  breakupurlsintables: node.attr("break-up-urls-in-tables"),
23
24
  suppressasciimathdup: node.attr("suppress-asciimath-dup") == "true",
24
25
  bare: node.attr("bare"),
@@ -62,8 +63,9 @@ module Metanorma
62
63
  wordintropage: node.attr("wordintropage"),
63
64
  ulstyle: node.attr("ulstyle"),
64
65
  olstyle: node.attr("olstyle"),
65
- htmltoclevels: node.attr("htmltoclevels") || node.attr("toclevels"),
66
- doctoclevels: node.attr("doctoclevels") || node.attr("toclevels"),
66
+ htmltoclevels: @htmltoclevels,
67
+ doctoclevels: @doctoclevels,
68
+ pdftoclevels: @pdftoclevels,
67
69
  breakupurlsintables: node.attr("break-up-urls-in-tables"),
68
70
  suppressasciimathdup: node.attr("suppress-asciimath-dup"),
69
71
  bare: node.attr("bare"),
@@ -207,20 +207,4 @@
207
207
  <value>permission</value>
208
208
  </choice>
209
209
  </define>
210
- <define name="classification">
211
- <element name="classification">
212
- <ref name="classification_tag"/>
213
- <ref name="classification_value"/>
214
- </element>
215
- </define>
216
- <define name="classification_tag">
217
- <element name="tag">
218
- <text/>
219
- </element>
220
- </define>
221
- <define name="classification_value">
222
- <element name="value">
223
- <text/>
224
- </element>
225
- </define>
226
210
  </grammar>
@@ -144,8 +144,8 @@ module Metanorma
144
144
 
145
145
  def image_exists(doc)
146
146
  doc.xpath("//image").each do |i|
147
- Metanorma::Utils::url?(i["src"]) and next
148
- Metanorma::Utils::datauri?(i["src"]) and next
147
+ Vectory::Utils::url?(i["src"]) and next
148
+ Vectory::Utils::datauri?(i["src"]) and next
149
149
  expand_path(i["src"]) and next
150
150
  @log.add("Images", i.parent,
151
151
  "Image not found: #{i['src']}", severity: 0)
@@ -161,9 +161,9 @@ module Metanorma
161
161
 
162
162
  def png_validate(doc)
163
163
  doc.xpath("//image[@mimetype = 'image/png']").each do |i|
164
- Metanorma::Utils::url?(i["src"]) and next
165
- decoded = if Metanorma::Utils::datauri?(i["src"])
166
- Metanorma::Utils::decode_datauri(i["src"])[:data]
164
+ Vectory::Utils::url?(i["src"]) and next
165
+ decoded = if Vectory::Utils::datauri?(i["src"])
166
+ Vectory::Utils::decode_datauri(i["src"])[:data]
167
167
  else
168
168
  path = expand_path(i["src"]) or next
169
169
  File.binread(path)
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.7.4".freeze
22
+ VERSION = "2.8.0".freeze
23
23
  end
24
24
  end
@@ -4,6 +4,7 @@ require_relative "metanorma/standoc/converter"
4
4
  require_relative "metanorma/standoc/version"
5
5
  require "asciidoctor/extensions"
6
6
  require "metanorma"
7
+ require "vectory"
7
8
 
8
9
  if defined? Metanorma::Registry
9
10
  require_relative "metanorma/standoc"
@@ -31,7 +31,7 @@ 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.7.1"
34
+ spec.add_dependency "isodoc", "~> 2.8.0"
35
35
  spec.add_dependency "metanorma", ">= 1.6.0"
36
36
  spec.add_dependency "metanorma-plugin-datastruct", "~> 0.2.0"
37
37
  spec.add_dependency "metanorma-plugin-glossarist", "~> 0.1.1"
@@ -41,9 +41,10 @@ Gem::Specification.new do |spec|
41
41
  spec.add_dependency "asciimath2unitsml", "~> 0.4.0"
42
42
  spec.add_dependency "concurrent-ruby"
43
43
  spec.add_dependency "pngcheck"
44
- spec.add_dependency "relaton-cli", "~> 1.17.0"
44
+ spec.add_dependency "relaton-cli", "~> 1.18.0"
45
45
  spec.add_dependency "relaton-iev", "~> 1.1.5"
46
46
  spec.add_dependency "unicode2latex", "~> 0.0.1"
47
+ spec.add_dependency "vectory", "~> 0.6"
47
48
 
48
49
  spec.add_development_dependency "debug"
49
50
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
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.7.4
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-10 00:00:00.000000000 Z
11
+ date: 2024-01-09 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.7.1
61
+ version: 2.8.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.7.1
68
+ version: 2.8.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: metanorma
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: 1.17.0
187
+ version: 1.18.0
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: 1.17.0
194
+ version: 1.18.0
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: relaton-iev
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -220,6 +220,20 @@ dependencies:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
222
  version: 0.0.1
223
+ - !ruby/object:Gem::Dependency
224
+ name: vectory
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '0.6'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '0.6'
223
237
  - !ruby/object:Gem::Dependency
224
238
  name: debug
225
239
  requirement: !ruby/object:Gem::Requirement