metanorma-ieee 1.4.8 → 1.5.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.
@@ -143,11 +143,6 @@ module IsoDoc
143
143
  warn "Failure to convert MathML to LaTeX\n#{node.parent.to_xml}\n#{e}"
144
144
  end
145
145
 
146
- def formula_where(dlist)
147
- dlist or return
148
- dlist["class"] = "formula_dl"
149
- end
150
-
151
146
  def ol(docxml)
152
147
  ol_numbering(docxml)
153
148
  @xrefs.list_anchor_names(docxml.xpath(ns(@xrefs.sections_xpath)))
@@ -88,8 +88,13 @@ module IsoDoc
88
88
  end
89
89
 
90
90
  def sourcecode_cleanup(docxml)
91
- docxml.xpath("//p[@class = 'Sourcecode']").each do |s|
92
- s.replace(to_xml(s).gsub(%r{<br/>}, "</p><p class='Sourcecode'>"))
91
+ docxml.xpath("//p[@class = 'Sourcecode']").each do |para|
92
+ br_elements = para.xpath(".//br")
93
+ br_elements.empty? and next
94
+ split_para_at_breaks(para).reverse.each do |new_para|
95
+ para.add_next_sibling(new_para)
96
+ end
97
+ para.remove
93
98
  end
94
99
  end
95
100
 
@@ -135,6 +140,91 @@ module IsoDoc
135
140
  end
136
141
  end
137
142
  end
143
+
144
+ private
145
+
146
+ def split_para_at_breaks(para)
147
+ result_paras = []
148
+ current_para = create_new_para(para)
149
+ # Process each child node of the para
150
+ para.children.each do |node|
151
+ current_para =
152
+ process_node_for_sourcecode_breaks(node, current_para, result_paras)
153
+ end
154
+ # Add the final para if it has content
155
+ result_paras << current_para if para_has_content?(current_para)
156
+ result_paras
157
+ end
158
+
159
+ def create_new_para(original_para)
160
+ new_para = Nokogiri::XML::Node.new("p", original_para.document)
161
+ # Copy all attributes from original para
162
+ original_para.attributes.each do |name, attr|
163
+ new_para[name] = attr.value
164
+ end
165
+ new_para
166
+ end
167
+
168
+ def process_node_for_sourcecode_breaks(node, current, result_paras)
169
+ if node.name == "br"
170
+ # Found a break - finish current para and start a new one
171
+ result_paras << current if para_has_content?(current)
172
+ current = create_new_para(node.document.at("//p[@class='Sourcecode']"))
173
+ elsif node.xpath(".//br").any?
174
+ current = process_element_with_breaks(node, current, result_paras)
175
+ else
176
+ current.add_child(node.dup)
177
+ end
178
+ current
179
+ end
180
+
181
+ def process_element_with_breaks(node, curr_para, result_paras)
182
+ # Create element structure for current para
183
+ curr_elem = node.dup
184
+ curr_elem.children.remove
185
+
186
+ node.children.each do |child|
187
+ if child.name == "br"
188
+ # Close current element and finish para
189
+ element_has_content?(curr_elem) and
190
+ curr_para.add_child(curr_elem.dup)
191
+ para_has_content?(curr_para) and result_paras << curr_para
192
+ # Start new para and reopen element structure
193
+ curr_para = create_new_para(node.document.at("//p[@class='Sourcecode']"))
194
+ curr_elem = node.dup
195
+ curr_elem.children.remove
196
+ elsif child.xpath(".//br").any?
197
+ # Add child to current element
198
+ temp_para = create_new_para(node.document.at("//p[@class='Sourcecode']"))
199
+ temp_para = process_element_with_breaks(child, temp_para, result_paras)
200
+ # If new paras were created, we need to handle the split
201
+ if result_paras.any? && result_paras.last != curr_para
202
+ # A split occurred, add current element to current para and update
203
+ curr_para.add_child(curr_elem.dup) if element_has_content?(curr_elem)
204
+ curr_para = temp_para
205
+ curr_elem = node.dup
206
+ curr_elem.children.remove
207
+ else
208
+ # No split, add the processed child
209
+ curr_elem.add_child(child.dup)
210
+ end
211
+ # Recursively handle nested breaks
212
+ else
213
+ curr_elem.add_child(child.dup)
214
+ end
215
+ end
216
+ # Add final element if it has content
217
+ curr_para.add_child(curr_elem.dup) if element_has_content?(curr_elem)
218
+ curr_para
219
+ end
220
+
221
+ def para_has_content?(para)
222
+ para.children.any? && !para.content.strip.empty?
223
+ end
224
+
225
+ def element_has_content?(element)
226
+ element.children.any?
227
+ end
138
228
  end
139
229
  end
140
230
  end
@@ -118,10 +118,11 @@ module IsoDoc
118
118
  def formula_parse(node, out)
119
119
  out.div **formula_attrs(node) do |div|
120
120
  formula_parse1(node, div)
121
- formula_where(node.at(ns("./dl")), div)
122
121
  node.children.each do |n|
123
- %w(fmt-stem dl fmt-name).include? n.name and next
124
- parse(n, div)
122
+ %w(fmt-stem fmt-name).include? n.name and next
123
+ if n.name == "dl" then formula_where(n, div)
124
+ else parse(n, div)
125
+ end
125
126
  end
126
127
  end
127
128
  end
@@ -231,6 +232,6 @@ module IsoDoc
231
232
 
232
233
  include BaseConvert
233
234
  include Init
234
- end
235
- end
235
+ end
236
+ end
236
237
  end
@@ -114,7 +114,7 @@ module Metanorma
114
114
 
115
115
  def metadata_status(node, xml)
116
116
  status = node.attr("status") || node.attr("docstage") ||
117
- (node.attr("draft") ? "draft" : "approved")
117
+ (node.attr("version") || node.attr("draft") ? "draft" : "approved")
118
118
  xml.status do |s|
119
119
  s.stage status
120
120
  end
@@ -155,7 +155,7 @@ module Metanorma
155
155
  i.agency "IEEE"
156
156
  i.class_ doctype(node)
157
157
  a = node.attr("edition") and i.edition a
158
- a = node.attr("draft") and i.version a
158
+ a = metadata_version_value(node) and i.version a
159
159
  a = node.attr("amendment-number") and i.amendment a
160
160
  a = node.attr("corrigendum-number") and i.corrigendum a
161
161
  a = node.attr("copyright-year") and i.year a
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <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">
3
- <!-- VERSION v2.0.7 -->
3
+ <!-- VERSION v2.0.8 -->
4
4
 
5
5
  <!--
6
6
  ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
@@ -72,6 +72,46 @@ but to `@anchor`, the user-supplied cross-reference</a:documentation>
72
72
  </oneOrMore>
73
73
  </element>
74
74
  </define>
75
+ <define name="review">
76
+ <a:documentation>Generalise BasicDoc element from just review comments, to general annotations;
77
+ the type attribute defaults to `review` for reviews</a:documentation>
78
+ <element name="annotation">
79
+ <ref name="RequiredId"/>
80
+ <ref name="ReviewAttributes"/>
81
+ <oneOrMore>
82
+ <ref name="paragraph">
83
+ <a:documentation>Reviewer comments content</a:documentation>
84
+ </ref>
85
+ </oneOrMore>
86
+ </element>
87
+ </define>
88
+ <define name="ruby_pronunciation">
89
+ <a:documentation>Ruby annotation giving pronunciation of text: change tag from BasicDoc for disambiguation</a:documentation>
90
+ <element name="ruby-pronunciation">
91
+ <attribute name="value">
92
+ <a:documentation>Ruby annotation value</a:documentation>
93
+ </attribute>
94
+ <ref name="LocalizedStringAttributes"/>
95
+ </element>
96
+ </define>
97
+ <define name="ruby_annotation">
98
+ <a:documentation>Ruby annotation giving information other than pronunciation of text: change tag from BasicDoc for disambiguation</a:documentation>
99
+ <element name="ruby-annotation">
100
+ <attribute name="value">
101
+ <a:documentation>Ruby annotation value</a:documentation>
102
+ </attribute>
103
+ <ref name="LocalizedStringAttributes"/>
104
+ </element>
105
+ </define>
106
+ <define name="annotation">
107
+ <a:documentation>Source code annotation, corresponding to a callout</a:documentation>
108
+ <element name="callout-annotation">
109
+ <ref name="RequiredId"/>
110
+ <oneOrMore>
111
+ <ref name="paragraph"/>
112
+ </oneOrMore>
113
+ </element>
114
+ </define>
75
115
  <define name="section-title">
76
116
  <a:documentation>Title(s) of a clause</a:documentation>
77
117
  <element name="title">
@@ -540,7 +580,7 @@ normative or informative references, some split references into sections organiz
540
580
  <ref name="OptionalId"/>
541
581
  <optional>
542
582
  <attribute name="style">
543
- <a:documentation>CSS style: only background-color supported</a:documentation>
583
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
544
584
  </attribute>
545
585
  </optional>
546
586
  </define>
@@ -620,7 +660,7 @@ This is done if the footnote reference is already presented in some other form,
620
660
  <ref name="RequiredId"/>
621
661
  <optional>
622
662
  <attribute name="style">
623
- <a:documentation>CSS style: only background-color supported</a:documentation>
663
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
624
664
  </attribute>
625
665
  </optional>
626
666
  </define>
@@ -700,6 +740,11 @@ titlecase, or lowercase</a:documentation>
700
740
  <a:documentation>Width of the table block in rendering</a:documentation>
701
741
  </attribute>
702
742
  </optional>
743
+ <optional>
744
+ <attribute name="style">
745
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
746
+ </attribute>
747
+ </optional>
703
748
  <ref name="BlockAttributes"/>
704
749
  </define>
705
750
  <define name="FigureAttributes" combine="interleave">
@@ -1417,7 +1462,7 @@ numbers</a:documentation>
1417
1462
  </optional>
1418
1463
  <ref name="DocumentBody"/>
1419
1464
  <optional>
1420
- <ref name="review-container">
1465
+ <ref name="annotation-container">
1421
1466
  <a:documentation>Annotations to the document</a:documentation>
1422
1467
  </ref>
1423
1468
  </optional>
@@ -1461,8 +1506,8 @@ numbers</a:documentation>
1461
1506
  </oneOrMore>
1462
1507
  </element>
1463
1508
  </define>
1464
- <define name="review-container">
1465
- <element name="review-container">
1509
+ <define name="annotation-container">
1510
+ <element name="annotation-container">
1466
1511
  <oneOrMore>
1467
1512
  <ref name="review"/>
1468
1513
  </oneOrMore>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ieee
3
- VERSION = "1.4.8".freeze
3
+ VERSION = "1.5.0".freeze
4
4
  end
5
5
  end
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
  spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
27
27
 
28
- spec.add_dependency "metanorma-standoc", "~> 3.0.0"
28
+ spec.add_dependency "metanorma-standoc", "~> 3.1.0"
29
29
  spec.add_dependency "mnconvert", "~> 1.20"
30
30
  spec.add_dependency "pubid"
31
31
 
@@ -40,7 +40,6 @@ spec.add_development_dependency "rubocop-performance"
40
40
  spec.add_development_dependency "sassc-embedded", "~> 1"
41
41
  spec.add_development_dependency "simplecov", "~> 0.15"
42
42
  spec.add_development_dependency "timecop", "~> 0.9"
43
- spec.add_development_dependency "vcr", "~> 6.1.0"
44
43
  spec.add_development_dependency "webmock"
45
44
  spec.add_development_dependency "xml-c14n"
46
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ieee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.8
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-06-09 00:00:00.000000000 Z
11
+ date: 2025-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0
19
+ version: 3.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.0.0
26
+ version: 3.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mnconvert
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -206,20 +206,6 @@ dependencies:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0.9'
209
- - !ruby/object:Gem::Dependency
210
- name: vcr
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - "~>"
214
- - !ruby/object:Gem::Version
215
- version: 6.1.0
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - "~>"
221
- - !ruby/object:Gem::Version
222
- version: 6.1.0
223
209
  - !ruby/object:Gem::Dependency
224
210
  name: webmock
225
211
  requirement: !ruby/object:Gem::Requirement