isodoc 2.10.0 → 2.10.1

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: 9d98a917ee770ef1034262fa29628010e3254f3ddb5d8dfe63be54c57c3d58c0
4
- data.tar.gz: 64b2107fddc44c0096653fc0319c7b0df81285327ab83600471b1b99971f3dbd
3
+ metadata.gz: 6867b3f44bce43fcfbd4c65115b8b71b6eb38cb7b1e39c20215addc7af8ad086
4
+ data.tar.gz: f335e4aecc20758c7c9810083d7da486ec73e0db4c377b9528841b46166085de
5
5
  SHA512:
6
- metadata.gz: 1b1ac5b466169fd9f2698b79617ef4d2c6dd9dbf35b0cca715102ddddfcb2a0013be3bd02153263da42a7f3cde0150ccffa4f3e16e7b750dd0f73be23420e4b1
7
- data.tar.gz: 26338d106c6e1cb5133c305c97ec5a8bb1c75292120ce2928efb93572ea6ff79b203eef4a6d73419d097cad76d6a0e22e71beac64a0f483dc09919e8d7d25e86
6
+ metadata.gz: 0bda93db557ef73dc1c5999bbd88d9ba06ac9977f48b93f4adca7aaac7e762d5b4fed0d62d8934151ce3ecf1becea0060d3fab65c92e2150a8a00a0c49895ee6
7
+ data.tar.gz: 1b0d780a2e450e8a22e8f6d4dcbcaa991e73bdcf1343ca3675c2e81b5f52688be7882f58762c18820fd2e99c4c37ea6043af8efc7f454ec44b553e00c3d356e3
@@ -152,6 +152,7 @@ module IsoDoc
152
152
  end
153
153
 
154
154
  def table_of_contents(clause, out)
155
+ @bare and return
155
156
  page_break(out)
156
157
  out.div **attr_code(preface_attrs(clause)) do |div|
157
158
  clause_name(clause, clause.at(ns("./title")), div,
@@ -194,32 +195,28 @@ module IsoDoc
194
195
  end
195
196
 
196
197
  def copyright_parse(node, out)
197
- return if @bare
198
-
198
+ @bare and return
199
199
  out.div class: "boilerplate-copyright" do |div|
200
200
  node.children.each { |n| parse(n, div) }
201
201
  end
202
202
  end
203
203
 
204
204
  def license_parse(node, out)
205
- return if @bare
206
-
205
+ @bare and return
207
206
  out.div class: "boilerplate-license" do |div|
208
207
  node.children.each { |n| parse(n, div) }
209
208
  end
210
209
  end
211
210
 
212
211
  def legal_parse(node, out)
213
- return if @bare
214
-
212
+ @bare and return
215
213
  out.div class: "boilerplate-legal" do |div|
216
214
  node.children.each { |n| parse(n, div) }
217
215
  end
218
216
  end
219
217
 
220
218
  def feedback_parse(node, out)
221
- return if @bare
222
-
219
+ @bare and return
223
220
  out.div class: "boilerplate-feedback" do |div|
224
221
  node.children.each { |n| parse(n, div) }
225
222
  end
@@ -40,8 +40,10 @@ module IsoDoc
40
40
  end
41
41
 
42
42
  def html_preface(docxml)
43
- html_cover(docxml) if @htmlcoverpage && !@bare
44
- html_intro(docxml) if @htmlintropage && !@bare
43
+ @htmlcoverpage && !@htmlcoverpage.empty? && !@bare and
44
+ html_cover(docxml)
45
+ @htmlintropage && !@htmlintropage.empty? && !@bare and
46
+ html_intro(docxml)
45
47
  docxml.at("//body") << mathjax(@openmathdelim, @closemathdelim)
46
48
  html_main(docxml)
47
49
  authority_cleanup(docxml)
@@ -102,9 +102,14 @@ module IsoDoc
102
102
  end
103
103
 
104
104
  def bibliography_bibitem_number_insert_pt(bibitem)
105
- unless ins = bibitem.at(ns(".//docidentifier")).previous_element
106
- bibitem.at(ns(".//docidentifier")).previous = " "
107
- ins = bibitem.at(ns(".//docidentifier")).previous
105
+ unless d = bibitem.at(ns(".//docidentifier"))
106
+ d = bibitem.children.first
107
+ d.previous = " "
108
+ return d.previous
109
+ end
110
+ unless ins = d.previous_element
111
+ d.previous = " "
112
+ ins = d.previous
108
113
  end
109
114
  ins
110
115
  end
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.10.0".freeze
2
+ VERSION = "2.10.1".freeze
3
3
  end
@@ -64,10 +64,16 @@ module IsoDoc
64
64
  word_tab_clean(docxml)
65
65
  authority_cleanup(docxml)
66
66
  word_footnote_format(docxml)
67
+ word_remove_empty_toc(docxml)
67
68
  word_remove_empty_sections(docxml)
68
69
  docxml
69
70
  end
70
71
 
72
+ def word_remove_empty_toc(docxml)
73
+ docxml.at("//div[@class = 'TOC']//p[@class = 'MsoToc1']") and return
74
+ remove_toc_div(docxml)
75
+ end
76
+
71
77
  def word_sourcecode_annotations(html)
72
78
  ann = ".//div[@class = 'annotation']"
73
79
  html.xpath("//p[@class = '#{sourcecode_style}'][#{ann}]")
@@ -2,8 +2,10 @@ module IsoDoc
2
2
  module WordFunction
3
3
  module Postprocess
4
4
  def word_preface(docxml)
5
- word_cover(docxml) if @wordcoverpage
6
- word_intro(docxml, @wordToClevels) if @wordintropage
5
+ @wordcoverpage && !@wordcoverpage.empty? and
6
+ word_cover(docxml)
7
+ @wordintropage && !@wordintropage.empty? and
8
+ word_intro(docxml, @wordToClevels)
7
9
  end
8
10
 
9
11
  def word_remove_empty_sections(docxml)
@@ -4,11 +4,7 @@ module IsoDoc
4
4
  def insert_toc(intro, docxml, level)
5
5
  toc = assemble_toc(docxml, level)
6
6
  if intro&.include?("WORDTOC")
7
- if s = docxml.at("//div[@class = 'TOC']")
8
- s&.previous_element&.elements&.first&.name == "br" and
9
- s&.previous_element&.remove # page break
10
- s.remove
11
- end
7
+ remove_toc_div(docxml)
12
8
  intro.sub("WORDTOC", toc)
13
9
  else
14
10
  source = docxml.at("//div[@class = 'TOC']") and
@@ -17,6 +13,14 @@ module IsoDoc
17
13
  end
18
14
  end
19
15
 
16
+ def remove_toc_div(docxml)
17
+ s = docxml.at("//div[@class = 'TOC']") or return
18
+ prev = s.previous_element
19
+ prev&.elements&.first&.name == "br" and
20
+ prev&.remove # page break
21
+ s.remove
22
+ end
23
+
20
24
  def assemble_toc(docxml, level)
21
25
  toc = ""
22
26
  toc += make_WordToC(docxml, level)
@@ -0,0 +1,41 @@
1
+ module IsoDoc
2
+ module XrefGen
3
+ module Sections
4
+ def clause_order(docxml)
5
+ { preface: clause_order_preface(docxml),
6
+ main: clause_order_main(docxml),
7
+ annex: clause_order_annex(docxml),
8
+ back: clause_order_back(docxml) }
9
+ end
10
+
11
+ def clause_order_preface(_docxml)
12
+ [{ path: "//preface/*", multi: true }]
13
+ end
14
+
15
+ def clause_order_main(docxml)
16
+ [
17
+ { path: "//sections/clause[@type = 'scope']" },
18
+ { path: @klass.norm_ref_xpath },
19
+ { path: "//sections/terms | " \
20
+ "//sections/clause[descendant::terms]" },
21
+ { path: "//sections/definitions | " \
22
+ "//sections/clause[descendant::definitions]" \
23
+ "[not(descendant::terms)]" },
24
+ { path: @klass.middle_clause(docxml), multi: true },
25
+ ]
26
+ end
27
+
28
+ def clause_order_annex(_docxml)
29
+ [{ path: "//annex", multi: true }]
30
+ end
31
+
32
+ def clause_order_back(_docxml)
33
+ [
34
+ { path: @klass.bibliography_xpath },
35
+ { path: "//indexsect", multi: true },
36
+ { path: "//colophon/*", multi: true },
37
+ ]
38
+ end
39
+ end
40
+ end
41
+ end
@@ -139,7 +139,7 @@ module IsoDoc
139
139
  end
140
140
 
141
141
  def increment(node)
142
- @unnumbered = (node["unnumbered"] || node["hidden"]) and return self
142
+ @unnumbered = node["unnumbered"] == "true" || node["hidden"] == "true" and return self
143
143
  reset_overrides
144
144
  if node["subsequence"] != @subseq &&
145
145
  !(blank?(node["subsequence"]) && blank?(@subseq))
@@ -1,42 +1,8 @@
1
+ require_relative "clause_order"
2
+
1
3
  module IsoDoc
2
4
  module XrefGen
3
5
  module Sections
4
- def clause_order(docxml)
5
- { preface: clause_order_preface(docxml),
6
- main: clause_order_main(docxml),
7
- annex: clause_order_annex(docxml),
8
- back: clause_order_back(docxml) }
9
- end
10
-
11
- def clause_order_preface(_docxml)
12
- [{ path: "//preface/*", multi: true }]
13
- end
14
-
15
- def clause_order_main(docxml)
16
- [
17
- { path: "//sections/clause[@type = 'scope']" },
18
- { path: @klass.norm_ref_xpath },
19
- { path: "//sections/terms | " \
20
- "//sections/clause[descendant::terms]" },
21
- { path: "//sections/definitions | " \
22
- "//sections/clause[descendant::definitions]" \
23
- "[not(descendant::terms)]" },
24
- { path: @klass.middle_clause(docxml), multi: true },
25
- ]
26
- end
27
-
28
- def clause_order_annex(_docxml)
29
- [{ path: "//annex", multi: true }]
30
- end
31
-
32
- def clause_order_back(_docxml)
33
- [
34
- { path: @klass.bibliography_xpath },
35
- { path: "//indexsect", multi: true },
36
- { path: "//colophon/*", multi: true },
37
- ]
38
- end
39
-
40
6
  def back_anchor_names(xml)
41
7
  if @parse_settings.empty? || @parse_settings[:clauses]
42
8
  annex_anchor_names(xml)
@@ -173,7 +139,7 @@ module IsoDoc
173
139
  end
174
140
 
175
141
  def section_names(clause, num, lvl)
176
- clause.nil? and return num
142
+ unnumbered_section_name?(clause) and return num
177
143
  num.increment(clause)
178
144
  section_name_anchors(clause, num.print, lvl)
179
145
  clause.xpath(ns(SUBCLAUSES))
@@ -184,6 +150,7 @@ module IsoDoc
184
150
  end
185
151
 
186
152
  def section_names1(clause, num, level)
153
+ unnumbered_section_name?(clause) and return num
187
154
  section_name_anchors(clause, num, level)
188
155
  i = Counter.new(0, prefix: "#{num}.")
189
156
  clause.xpath(ns(SUBCLAUSES)).each do |c|
@@ -191,6 +158,15 @@ module IsoDoc
191
158
  end
192
159
  end
193
160
 
161
+ def unnumbered_section_name?(clause)
162
+ clause.nil? and return true
163
+ if clause["unnumbered"] == "true"
164
+ unnumbered_names(clause)
165
+ return true
166
+ end
167
+ false
168
+ end
169
+
194
170
  def section_name_anchors(clause, num, level)
195
171
  @anchors[clause["id"]] =
196
172
  { label: num, xref: l10n("#{@labels['clause']} #{num}"),
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.10.1
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-04-08 00:00:00.000000000 Z
11
+ date: 2024-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html2doc
@@ -392,6 +392,7 @@ files:
392
392
  - lib/isodoc/word_function/postprocess_toc.rb
393
393
  - lib/isodoc/word_function/table.rb
394
394
  - lib/isodoc/xref.rb
395
+ - lib/isodoc/xref/clause_order.rb
395
396
  - lib/isodoc/xref/xref_anchor.rb
396
397
  - lib/isodoc/xref/xref_counter.rb
397
398
  - lib/isodoc/xref/xref_gen.rb