metanorma-ieee 1.4.9 → 1.5.1

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.
@@ -38,15 +38,13 @@ module IsoDoc
38
38
  ret = [[coll[0]]]
39
39
  coll[1..-1].each do |r|
40
40
  if ret[-1][0]["type"] != r["type"]
41
- ret << [r]
42
- next
41
+ ret << [r] and next
43
42
  end
43
+
44
44
  ret[-1] << r
45
45
  end
46
46
  ret.map do |x|
47
- x.map do |y|
48
- to_xml(y)
49
- end.join("; ")
47
+ x.map { |y| to_xml(y) }.join("; ")
50
48
  end.map { |x| "<p>#{x}</p>" }.join("\n")
51
49
  end
52
50
 
@@ -86,11 +84,13 @@ module IsoDoc
86
84
 
87
85
  def admitted_to_related(docxml)
88
86
  docxml.xpath(ns("//term")).each do |t|
89
- t.xpath(ns("./fmt-admitted/semx | ./fmt-preferred/semx")).each_with_index do |a, i|
87
+ t.xpath(ns("./fmt-admitted/semx | ./fmt-preferred/semx"))
88
+ .each_with_index do |a, i|
90
89
  orig = semx_orig(a)
91
90
  (i.zero? ||
92
91
  orig.at(ns("./abbreviation-type | ./graphical-symbol"))) and next
93
- out = t.at(ns("./fmt-related")) || t.at(ns("./definition")).before("<fmt-related/>").previous
92
+ out = t.at(ns("./fmt-related")) || t.at(ns("./definition"))
93
+ .before("<fmt-related/>").previous
94
94
  admitted_to_related1(a, t.at(ns("./fmt-preferred/semx")), out)
95
95
  a.parent.name == "fmt-preferred" and a.remove
96
96
  end
@@ -133,7 +133,8 @@ module IsoDoc
133
133
  if desgn["element"] == "preferred"
134
134
  f = orig.parent.xpath(ns("./domain | ./subject"))
135
135
  .map { |u| to_xml(semx_fmt_dup(u)) }.join(", ")
136
- name << "<span class='fmt-designation-field'>, &#x3c;#{f}&#x3e;</span>" unless f.empty?
136
+ f.empty? or
137
+ name << "<span class='fmt-designation-field'>, &#x3c;#{f}&#x3e;</span>"
137
138
  end
138
139
  super
139
140
  end
@@ -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
@@ -198,14 +198,14 @@ Applicable to modify and delete</a:documentation>
198
198
  </zeroOrMore>
199
199
  </element>
200
200
  </optional>
201
- <optional>
201
+ <zeroOrMore>
202
202
  <element name="description">
203
- <a:documentation>Description of the change described in this block</a:documentation>
204
- <zeroOrMore>
203
+ <a:documentation>Description(s) of the change described in this block</a:documentation>
204
+ <oneOrMore>
205
205
  <ref name="BasicBlock"/>
206
- </zeroOrMore>
206
+ </oneOrMore>
207
207
  </element>
208
- </optional>
208
+ </zeroOrMore>
209
209
  <optional>
210
210
  <element name="newcontent">
211
211
  <a:documentation>New content to be added to the document; applicable to add and modify</a:documentation>
@@ -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
@@ -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.1.0 -->
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>
@@ -695,11 +735,22 @@ titlecase, or lowercase</a:documentation>
695
735
  <ref name="BlockAttributes"/>
696
736
  </define>
697
737
  <define name="TableAttributes" combine="interleave">
738
+ <optional>
739
+ <attribute name="plain">
740
+ <a:documentation>Render as a plain attribute, with no shading or borders</a:documentation>
741
+ <data type="boolean"/>
742
+ </attribute>
743
+ </optional>
698
744
  <optional>
699
745
  <attribute name="width">
700
746
  <a:documentation>Width of the table block in rendering</a:documentation>
701
747
  </attribute>
702
748
  </optional>
749
+ <optional>
750
+ <attribute name="style">
751
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
752
+ </attribute>
753
+ </optional>
703
754
  <ref name="BlockAttributes"/>
704
755
  </define>
705
756
  <define name="FigureAttributes" combine="interleave">
@@ -1417,7 +1468,7 @@ numbers</a:documentation>
1417
1468
  </optional>
1418
1469
  <ref name="DocumentBody"/>
1419
1470
  <optional>
1420
- <ref name="review-container">
1471
+ <ref name="annotation-container">
1421
1472
  <a:documentation>Annotations to the document</a:documentation>
1422
1473
  </ref>
1423
1474
  </optional>
@@ -1461,8 +1512,8 @@ numbers</a:documentation>
1461
1512
  </oneOrMore>
1462
1513
  </element>
1463
1514
  </define>
1464
- <define name="review-container">
1465
- <element name="review-container">
1515
+ <define name="annotation-container">
1516
+ <element name="annotation-container">
1466
1517
  <oneOrMore>
1467
1518
  <ref name="review"/>
1468
1519
  </oneOrMore>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ieee
3
- VERSION = "1.4.9".freeze
3
+ VERSION = "1.5.1".freeze
4
4
  end
5
5
  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.9
4
+ version: 1.5.1
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-23 00:00:00.000000000 Z
11
+ date: 2025-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc