isodoc 1.6.3 → 1.6.4

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: b9d5c91b697c02cdac2a8221f2995d29f812804b48039967bd94c8aef7ce10c0
4
- data.tar.gz: cf66a1f8d4eb41297360341e0da8d16a9ddf0af2679f072d758a259186a291bd
3
+ metadata.gz: c36b5db70dc3eb379ad1f903a8707b7c9403474e55f0fe99b9218536d0651c9a
4
+ data.tar.gz: 33e3a3e805b97042ac336754d43c47162e0d3e8851649514c20e4d5ede0301c0
5
5
  SHA512:
6
- metadata.gz: 4cfa5637d6c22e73dd2a6c5bc32841183691a5db4121102787fad3caddd61815541e7128b624f03d20bf00d1e94fed81e43aaa19d1b84260e7bde5cfc69d924e
7
- data.tar.gz: 7015f57396172858edb4b8499e6c4706894ef540f6b96c95d5c9bf445580003a8e68d4930204e5731ec57dafa460c2cfbcf4da5572e82713070fd214bef5974e
6
+ metadata.gz: 7ec36b6afb9cdb96291f75a78740d5cd555d898fa9bce309904a7ac54408c8ad90f2f4dcb5fe5e97aeb08526f6659d317a42537466801f9abbc4735b8fa23a39
7
+ data.tar.gz: ffb1143efd27cf641cc9b336b9ff538bb6c6c5153cdc351f0e9edb8f4c7f029793267b47caa5682e9ce886ac9e30ea7c0601d1b91eca88a62f92ccb675294fc5
@@ -16,19 +16,9 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '2.7', '2.6', '2.5', '2.4' ]
19
+ ruby: [ '3.0', '2.7', '2.6', '2.5', '2.4' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
- include:
23
- - ruby: '3.0'
24
- os: 'ubuntu-latest'
25
- experimental: true
26
- - ruby: '3.0'
27
- os: 'windows-latest'
28
- experimental: true
29
- - ruby: '3.0'
30
- os: 'macos-latest'
31
- experimental: true
32
22
  steps:
33
23
  - uses: actions/checkout@master
34
24
 
@@ -49,5 +39,5 @@ jobs:
49
39
  with:
50
40
  token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
51
41
  repository: ${{ github.repository }}
52
- event-type: notify
42
+ event-type: tests-passed
53
43
  client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
data/.hound.yml CHANGED
@@ -1,3 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
1
3
  ruby:
2
- Enabled: true
4
+ enabled: true
3
5
  config_file: .rubocop.yml
data/.rubocop.yml CHANGED
@@ -1,12 +1,10 @@
1
- # This project follows the Ribose OSS style guide.
2
- # https://github.com/riboseinc/oss-guides
3
- # All project-specific additions and overrides should be specified in this file.
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
4
3
  inherit_from:
5
4
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
6
5
 
7
6
  # local repo-specific modifications
7
+ # ...
8
8
 
9
9
  AllCops:
10
- DisplayCopNames: false
11
- StyleGuideCopsOnly: false
12
10
  TargetRubyVersion: 2.4
data/isodoc.gemspec CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency "htmlentities", "~> 4.3.4"
34
34
  spec.add_dependency "liquid", "~> 4"
35
35
  spec.add_dependency "metanorma", ">= 1.2.0"
36
- spec.add_dependency "nokogiri", "~> 1.10.4"
36
+ spec.add_dependency "nokogiri", "~> 1.11.0"
37
37
  spec.add_dependency "relaton-cli"
38
38
  spec.add_dependency "roman-numerals"
39
39
  spec.add_dependency "thread_safe"
data/lib/isodoc.rb CHANGED
@@ -8,7 +8,6 @@ require "mime/types"
8
8
  require "image_size"
9
9
  require "set"
10
10
  require "pp"
11
- require "uuidtools"
12
11
  require "html2doc"
13
12
  require "liquid"
14
13
  require "htmlentities"
@@ -26,5 +25,4 @@ require "isodoc/xref"
26
25
  require "isodoc/i18n"
27
26
 
28
27
  module IsoDoc
29
-
30
28
  end
@@ -32,10 +32,12 @@ module IsoDoc
32
32
  # monospace: font to use for monospace text
33
33
  # suppressheadingnumbers: suppress heading numbers for clauses
34
34
  # scripts: Scripts file for HTML
35
+ # scripts_override: Override scripts file for HTML
35
36
  # scripts_pdf: Scripts file for PDF (not used in XSLT PDF)
36
37
  # datauriimage: Encode images in HTML output as data URIs
37
38
  # break_up_urls_in_tables: whether to insert spaces in URLs in tables
38
39
  # every 40-odd chars
40
+ # bare: do not insert any prefatory material (coverpage, boilerplate)
39
41
  def initialize(options)
40
42
  @libdir ||= File.dirname(__FILE__) # rubocop:disable Lint/DisjunctiveAssignmentInConstructor
41
43
  options.merge!(default_fonts(options)) do |_, old, new|
@@ -64,12 +66,14 @@ module IsoDoc
64
66
  @scripts = options[:scripts] ||
65
67
  File.join(File.dirname(__FILE__), "base_style", "scripts.html")
66
68
  @scripts_pdf = options[:scripts_pdf]
69
+ @scripts_override = options[:scripts_override]
67
70
  @i18nyaml = options[:i18nyaml]
68
71
  @ulstyle = options[:ulstyle]
69
72
  @olstyle = options[:olstyle]
70
73
  @datauriimage = options[:datauriimage]
71
74
  @suppressheadingnumbers = options[:suppressheadingnumbers]
72
75
  @break_up_urls_in_tables = options[:break_up_urls_in_tables] == "true"
76
+ @bare = options[:bare]
73
77
  @termdomain = ""
74
78
  @termexample = false
75
79
  @note = false
@@ -1,16 +1,17 @@
1
1
  module IsoDoc::Function
2
2
  module Cleanup
3
3
  def textcleanup(docxml)
4
- docxml = termref_cleanup(passthrough_cleanup(docxml))
4
+ termref_cleanup(passthrough_cleanup(docxml))
5
5
  end
6
6
 
7
7
  def termref_cleanup(docxml)
8
- docxml.
9
- gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/, l10n(", #{@i18n.modified} [/TERMREF]")).
10
- gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, "; ").
11
- gsub(/\[TERMREF\]\s*/, l10n("[#{@i18n.source}: ")).
12
- gsub(%r{\s*\[\/TERMREF\]\s*}, l10n("]")).
13
- gsub(/\s*\[MODIFICATION\]/, l10n(", #{@i18n.modified} &mdash; "))
8
+ docxml
9
+ .gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/,
10
+ l10n(", #{@i18n.modified} [/TERMREF]"))
11
+ .gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, "; ")
12
+ .gsub(/\[TERMREF\]\s*/, l10n("[#{@i18n.source}: "))
13
+ .gsub(%r{\s*\[/TERMREF\]\s*}, l10n("]"))
14
+ .gsub(/\s*\[MODIFICATION\]/, l10n(", #{@i18n.modified} &mdash; "))
14
15
  end
15
16
 
16
17
  def passthrough_cleanup(docxml)
@@ -21,7 +22,7 @@ module IsoDoc::Function
21
22
  end
22
23
 
23
24
  def cleanup(docxml)
24
- @i18n ||= i18n_init(@lang, @script)
25
+ @i18n ||= i18n_init(@lang, @script)
25
26
  comment_cleanup(docxml)
26
27
  footnote_cleanup(docxml)
27
28
  inline_header_cleanup(docxml)
@@ -34,30 +35,36 @@ module IsoDoc::Function
34
35
 
35
36
  def table_long_strings_cleanup(docxml)
36
37
  return unless @break_up_urls_in_tables == true
38
+
37
39
  docxml.xpath("//td | //th").each do |d|
38
40
  d.traverse do |n|
39
41
  next unless n.text?
42
+
40
43
  n.replace(HTMLEntities.new.encode(
41
- break_up_long_strings(n.text)))
44
+ break_up_long_strings(n.text),
45
+ ))
42
46
  end
43
47
  end
44
48
  end
45
49
 
46
- def break_up_long_strings(t)
47
- return t if t.match(/^\s*$/)
48
- t.split(/(?=\s)/).map do |w|
49
- (/^\s*$/.match(t) or w.size < 30) ? w :
50
+ def break_up_long_strings(text)
51
+ return text if /^\s*$/.match?(text)
52
+
53
+ text.split(/(?=\s)/).map do |w|
54
+ if /^\s*$/.match(text) || (w.size < 30) then w
55
+ else
50
56
  w.scan(/.{,30}/).map do |w1|
51
- (w1.size < 30) ? w1 : break_up_long_strings1(w1)
52
- end.join
57
+ w1.size < 30 ? w1 : break_up_long_strings1(w1)
58
+ end.join
59
+ end
53
60
  end.join
54
61
  end
55
62
 
56
- def break_up_long_strings1(w1)
57
- s = w1.split(%r{(?<=[,.?+;/=])})
58
- if s.size == 1 then w1 + " "
63
+ def break_up_long_strings1(text)
64
+ s = text.split(%r{(?<=[,.?+;/=])})
65
+ if s.size == 1 then "#{text} "
59
66
  else
60
- s[-1] = " " + s[-1]
67
+ s[-1] = " #{s[-1]}"
61
68
  s.join
62
69
  end
63
70
  end
@@ -78,11 +85,11 @@ module IsoDoc::Function
78
85
  docxml
79
86
  end
80
87
 
81
- def figure_get_or_make_dl(t)
82
- dl = t.at(".//dl")
88
+ def figure_get_or_make_dl(elem)
89
+ dl = elem.at(".//dl")
83
90
  if dl.nil?
84
- t.add_child("<p><b>#{@i18n.key}</b></p><dl></dl>")
85
- dl = t.at(".//dl")
91
+ elem.add_child("<p><b>#{@i18n.key}</b></p><dl></dl>")
92
+ dl = elem.at(".//dl")
86
93
  end
87
94
  dl
88
95
  end
@@ -91,10 +98,10 @@ module IsoDoc::Function
91
98
  "//div[@class = 'figure'][descendant::aside]"\
92
99
  "[not(descendant::div[@class = 'figure'])]".freeze
93
100
 
94
- def figure_aside_process(f, aside, key)
101
+ def figure_aside_process(elem, aside, key)
95
102
  # get rid of footnote link, it is in diagram
96
- f&.at("./a[@class='TableFootnoteRef']")&.remove
97
- fnref = f.at(".//span[@class='TableFootnoteRef']/..")
103
+ elem&.at("./a[@class='TableFootnoteRef']")&.remove
104
+ fnref = elem.at(".//span[@class='TableFootnoteRef']/..")
98
105
  dt = key.add_child("<dt></dt>").first
99
106
  dd = key.add_child("<dd></dd>").first
100
107
  fnref.parent = dt
@@ -109,6 +116,7 @@ module IsoDoc::Function
109
116
  def figure_cleanup(docxml)
110
117
  docxml.xpath(FIGURE_WITH_FOOTNOTES).each do |f|
111
118
  next unless f.at(".//aside[not(ancestor::p[@class = 'FigureTitle'])]")
119
+
112
120
  key = figure_get_or_make_dl(f)
113
121
  f.xpath(".//aside").each do |aside|
114
122
  figure_aside_process(f, aside, key)
@@ -137,12 +145,13 @@ module IsoDoc::Function
137
145
  docxml
138
146
  end
139
147
 
140
- def merge_fnref_into_fn_text(a)
141
- fn = a.at('.//span[@class="TableFootnoteRef"]/..')
148
+ def merge_fnref_into_fn_text(elem)
149
+ fn = elem.at('.//span[@class="TableFootnoteRef"]/..')
142
150
  n = fn.next_element
143
151
  n&.children&.first&.add_previous_sibling(fn.remove)
144
152
  end
145
153
 
154
+ # preempt html2doc putting MsoNormal under TableFootnote class
146
155
  def table_footnote_cleanup(docxml)
147
156
  docxml.xpath("//table[descendant::aside]").each do |t|
148
157
  t.xpath(".//aside").each do |a|
@@ -152,36 +161,36 @@ module IsoDoc::Function
152
161
  t << a.remove
153
162
  end
154
163
  end
155
- # preempt html2doc putting MsoNormal there
156
164
  docxml.xpath("//p[not(self::*[@class])]"\
157
165
  "[ancestor::*[@class = 'TableFootnote']]").each do |p|
158
166
  p["class"] = "TableFootnote"
159
167
  end
160
168
  end
161
169
 
162
- def remove_bottom_border(td)
163
- td["style"] =
164
- td["style"].gsub(/border-bottom:[^;]+;/, "border-bottom:0pt;")
170
+ def remove_bottom_border(cell)
171
+ cell["style"] =
172
+ cell["style"].gsub(/border-bottom:[^;]+;/, "border-bottom:0pt;")
165
173
  end
166
174
 
167
- def table_get_or_make_tfoot(t)
168
- tfoot = t.at(".//tfoot")
175
+ def table_get_or_make_tfoot(table)
176
+ tfoot = table.at(".//tfoot")
169
177
  if tfoot.nil?
170
- t.add_child("<tfoot></tfoot>")
171
- tfoot = t.at(".//tfoot")
178
+ table.add_child("<tfoot></tfoot>")
179
+ tfoot = table.at(".//tfoot")
172
180
  else
173
181
  tfoot.xpath(".//td | .//th").each { |td| remove_bottom_border(td) }
174
182
  end
175
183
  tfoot
176
184
  end
177
185
 
178
- def new_fullcolspan_row(t, tfoot)
186
+ def new_fullcolspan_row(table, tfoot)
179
187
  # how many columns in the table?
180
188
  cols = 0
181
- t.at(".//tr").xpath("./td | ./th").each do |td|
189
+ table.at(".//tr").xpath("./td | ./th").each do |td|
182
190
  cols += (td["colspan"] ? td["colspan"].to_i : 1)
183
191
  end
184
- style = %{border-top:0pt;border-bottom:#{IsoDoc::Function::Table::SW} 1.5pt;}
192
+ style =
193
+ %{border-top:0pt;border-bottom:#{IsoDoc::Function::Table::SW} 1.5pt;}
185
194
  tfoot.add_child("<tr><td colspan='#{cols}' style='#{style}'/></tr>")
186
195
  tfoot.xpath(".//td").last
187
196
  end
@@ -206,12 +215,12 @@ module IsoDoc::Function
206
215
 
207
216
  def symbols_cleanup(docxml); end
208
217
 
209
- def table_footnote_reference_format(a)
210
- a
218
+ def table_footnote_reference_format(link)
219
+ link
211
220
  end
212
221
 
213
- def footnote_reference_format(a)
214
- a
222
+ def footnote_reference_format(link)
223
+ link
215
224
  end
216
225
  end
217
226
  end
@@ -3,11 +3,12 @@ require_relative "inline_simple"
3
3
  module IsoDoc::Function
4
4
  module Inline
5
5
  def link_parse(node, out)
6
- out.a **attr_code(href: node["target"], title: node["alt"]) do |l|
6
+ url = node["target"]
7
+ node["updatetype"] == "true" and url = suffix_url(url)
8
+ out.a **attr_code(href: url, title: node["alt"]) do |l|
7
9
  if node.text.empty?
8
10
  l << node["target"].sub(/^mailto:/, "")
9
- else
10
- node.children.each { |n| parse(n, l) }
11
+ else node.children.each { |n| parse(n, l) }
11
12
  end
12
13
  end
13
14
  end
@@ -79,8 +80,7 @@ module IsoDoc::Function
79
80
  "#{@openmathdelim}#{HTMLEntities.new.encode(node.text)}"\
80
81
  "#{@closemathdelim}"
81
82
  when "MathML" then node.first_element_child.to_s
82
- else
83
- HTMLEntities.new.encode(node.text)
83
+ else HTMLEntities.new.encode(node.text)
84
84
  end
85
85
  out.span **{ class: "stem" } do |span|
86
86
  span.parent.add_child ooml
@@ -123,13 +123,13 @@ module IsoDoc::Function
123
123
  end
124
124
 
125
125
  def add_parse(node, out)
126
- out.span **{class: "addition"} do |e|
126
+ out.span **{ class: "addition" } do |e|
127
127
  node.children.each { |n| parse(n, e) }
128
128
  end
129
129
  end
130
130
 
131
131
  def del_parse(node, out)
132
- out.span **{class: "deletion"} do |e|
132
+ out.span **{ class: "deletion" } do |e|
133
133
  node.children.each { |n| parse(n, e) }
134
134
  end
135
135
  end
@@ -8,11 +8,11 @@ module IsoDoc::Function
8
8
  insert_tab(out, 1)
9
9
  end
10
10
 
11
- def inline_header_title(out, node, title)
11
+ def inline_header_title(out, _node, title)
12
12
  out.span **{ class: "zzMoveToFollowing" } do |s|
13
13
  s.b do |b|
14
14
  title&.children&.each { |c2| parse(c2, b) }
15
- clausedelimspace(out) if /\S/.match(title&.text)
15
+ clausedelimspace(out) if /\S/.match?(title&.text)
16
16
  end
17
17
  end
18
18
  end
@@ -20,12 +20,14 @@ module IsoDoc::Function
20
20
  # used for subclauses
21
21
  def clause_parse_title(node, div, title, out, header_class = {})
22
22
  return if title.nil?
23
+
23
24
  if node["inline-header"] == "true"
24
25
  inline_header_title(out, node, title)
25
26
  else
26
- depth = (title && title["depth"]) ? title["depth"] :
27
- node.ancestors("clause, annex, terms, references, definitions, "\
28
- "acknowledgements, introduction, foreword").size + 1
27
+ depth = if title && title["depth"] then title["depth"]
28
+ else node.ancestors("clause, annex, terms, references, definitions, "\
29
+ "acknowledgements, introduction, foreword").size + 1
30
+ end
29
31
  div.send "h#{depth}", **attr_code(header_class) do |h|
30
32
  title&.children&.each { |c2| parse(c2, h) }
31
33
  end
@@ -49,8 +51,11 @@ module IsoDoc::Function
49
51
  def clause_name(_num, title, div, header_class)
50
52
  header_class = {} if header_class.nil?
51
53
  div.h1 **attr_code(header_class) do |h1|
52
- title.is_a?(String) ? h1 << title :
54
+ if title.is_a?(String)
55
+ h1 << title
56
+ else
53
57
  title&.children&.each { |c2| parse(c2, h1) }
58
+ end
54
59
  end
55
60
  div.parent.at(".//h1")
56
61
  end
@@ -66,8 +71,9 @@ module IsoDoc::Function
66
71
  end
67
72
  end
68
73
 
69
- def annex_name(annex, name, div)
74
+ def annex_name(_annex, name, div)
70
75
  return if name.nil?
76
+
71
77
  div.h1 **{ class: "Annex" } do |t|
72
78
  name.children.each { |c2| parse(c2, t) }
73
79
  end
@@ -144,7 +150,6 @@ module IsoDoc::Function
144
150
 
145
151
  def introduction(isoxml, out)
146
152
  f = isoxml.at(ns("//introduction")) || return
147
- title_attr = { class: "IntroTitle" }
148
153
  page_break(out)
149
154
  out.div **{ class: "Section3", id: f["id"] } do |div|
150
155
  clause_name(nil, f.at(ns("./title")), div, { class: "IntroTitle" })
@@ -160,7 +165,7 @@ module IsoDoc::Function
160
165
  out.div **attr_code(id: f["id"]) do |s|
161
166
  clause_name(nil, f.at(ns("./title")) || @i18n.foreword, s,
162
167
  { class: "ForewordTitle" })
163
- #s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @i18n.foreword }
168
+ # s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @i18n.foreword }
164
169
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
165
170
  end
166
171
  end
@@ -187,12 +192,11 @@ module IsoDoc::Function
187
192
  end
188
193
 
189
194
  def preface(isoxml, out)
190
- title_attr = { class: "IntroTitle" }
191
195
  isoxml.xpath(ns("//preface/clause | //preface/references | "\
192
196
  "//preface/definitions | //preface/terms")).each do |f|
193
197
  page_break(out)
194
198
  out.div **{ class: "Section3", id: f["id"] } do |div|
195
- clause_name(nil, f&.at(ns("./title")), div, title_attr)
199
+ clause_name(nil, f&.at(ns("./title")), div, { class: "IntroTitle" })
196
200
  f.elements.each do |e|
197
201
  parse(e, div) unless e.name == "title"
198
202
  end
@@ -202,37 +206,46 @@ module IsoDoc::Function
202
206
 
203
207
  def is_clause?(name)
204
208
  %w(clause references definitions terms foreword introduction abstract
205
- acknowledgements).include? name
209
+ acknowledgements).include? name
206
210
  end
207
211
 
208
212
  def preface_block(isoxml, out)
209
213
  p = isoxml.at(ns("//preface")) or return
210
214
  p.elements.each do |e|
211
215
  next if is_clause?(e.name)
216
+
212
217
  parse(e, out)
213
218
  end
214
219
  end
215
220
 
216
221
  def copyright_parse(node, out)
217
- out.div **{class: "boilerplate-copyright"} do |div|
222
+ return if @bare
223
+
224
+ out.div **{ class: "boilerplate-copyright" } do |div|
218
225
  node.children.each { |n| parse(n, div) }
219
226
  end
220
227
  end
221
228
 
222
229
  def license_parse(node, out)
223
- out.div **{class: "boilerplate-license"} do |div|
230
+ return if @bare
231
+
232
+ out.div **{ class: "boilerplate-license" } do |div|
224
233
  node.children.each { |n| parse(n, div) }
225
234
  end
226
235
  end
227
236
 
228
237
  def legal_parse(node, out)
229
- out.div **{class: "boilerplate-legal"} do |div|
238
+ return if @bare
239
+
240
+ out.div **{ class: "boilerplate-legal" } do |div|
230
241
  node.children.each { |n| parse(n, div) }
231
242
  end
232
243
  end
233
244
 
234
245
  def feedback_parse(node, out)
235
- out.div **{class: "boilerplate-feedback"} do |div|
246
+ return if @bare
247
+
248
+ out.div **{ class: "boilerplate-feedback" } do |div|
236
249
  node.children.each { |n| parse(n, div) }
237
250
  end
238
251
  end