isodoc 2.11.0 → 2.11.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: c38cf2267396e98d1de955feacbd9002b32d6f076593c414d8395eea21f08510
4
- data.tar.gz: 433c3e2d54797e3f22eb693f714163f4c3ac523a7584730872e1f7316b2dec81
3
+ metadata.gz: 0b983ef5d3072f012ede53a44cf7ac4fd8d14c4a554224e34b83024524a44d66
4
+ data.tar.gz: b0d51de25b3f14dc15a68aa9a2cc20f14ff63cd38075d725a4bddb41818a2249
5
5
  SHA512:
6
- metadata.gz: b36c7d9e7676ba7df00d34bb78797649b683a454776605249861978cf4ec5df3bdf61b7e4f05ec4e6644f62ac15aaa2e840cb5c36afb654e5c3d5457ddbd023e
7
- data.tar.gz: bce31398c2b4b23f8e4b1a3192a73564f69ebfc0859320aff702c8eb3d2eadc9ae84e05275d6be1a54abb2a1be1146786925c2452a9e7ae8caac3d285f10beb6
6
+ metadata.gz: 6889f50e0c7a00076784e74e2ed8aea85f1eacda8b97acce91b949335d6eb42f432c005094d23fc96b99971d3316727737001fc59bdfc4d7370c1692ee01d619
7
+ data.tar.gz: 407ce914a5c8af0e4aded2a7fefd166b1f13b5673498585d6f5d8b29c378ede3d9d8d22613cc74447a649557dc0d9b24bf9709cafc4a5dee20cc2e4a5026185d
@@ -222,6 +222,46 @@ h6:hover > a.anchor,
222
222
  .inline-header:hover > a.anchor {
223
223
  visibility: visible; }
224
224
 
225
+ /* collapsible snippets: collapsible before hidable */
226
+ .hidable {
227
+ max-height: 0;
228
+ overflow: hidden;
229
+ transition: max-height 0.2s ease-out; }
230
+
231
+ .collapsible {
232
+ background-color: #777;
233
+ color: white;
234
+ cursor: pointer;
235
+ padding: 12px 0;
236
+ margin: 0;
237
+ width: 100%;
238
+ border: none;
239
+ text-align: left;
240
+ outline: none;
241
+ font-size: 15px; }
242
+
243
+ .active, .collapsible:hover {
244
+ background-color: #555; }
245
+
246
+ .collapsible:after {
247
+ content: '\25bc';
248
+ color: white;
249
+ font-weight: bold;
250
+ float: right;
251
+ margin-left: 12px;
252
+ margin-right: 12px; }
253
+
254
+ .active:after {
255
+ content: "\25b2"; }
256
+
257
+ /* collapsible: */
258
+ .collapsible + .hidable {
259
+ margin-top: 0; }
260
+
261
+ .collapsible:not(.active) + .hidable {
262
+ overflow: hidden;
263
+ padding: 0; }
264
+
225
265
  #standard-band {
226
266
  background-color: #0AC442; }
227
267
 
@@ -221,3 +221,43 @@ h5:hover > a.anchor,
221
221
  h6:hover > a.anchor,
222
222
  .inline-header:hover > a.anchor {
223
223
  visibility: visible; }
224
+
225
+ /* collapsible snippets: collapsible before hidable */
226
+ .hidable {
227
+ max-height: 0;
228
+ overflow: hidden;
229
+ transition: max-height 0.2s ease-out; }
230
+
231
+ .collapsible {
232
+ background-color: #777;
233
+ color: white;
234
+ cursor: pointer;
235
+ padding: 12px 0;
236
+ margin: 0;
237
+ width: 100%;
238
+ border: none;
239
+ text-align: left;
240
+ outline: none;
241
+ font-size: 15px; }
242
+
243
+ .active, .collapsible:hover {
244
+ background-color: #555; }
245
+
246
+ .collapsible:after {
247
+ content: '\25bc';
248
+ color: white;
249
+ font-weight: bold;
250
+ float: right;
251
+ margin-left: 12px;
252
+ margin-right: 12px; }
253
+
254
+ .active:after {
255
+ content: "\25b2"; }
256
+
257
+ /* collapsible: */
258
+ .collapsible + .hidable {
259
+ margin-top: 0; }
260
+
261
+ .collapsible:not(.active) + .hidable {
262
+ overflow: hidden;
263
+ padding: 0; }
@@ -223,3 +223,50 @@ h6:hover>a.anchor,
223
223
  .inline-header:hover>a.anchor{
224
224
  visibility:visible;
225
225
  }
226
+
227
+ /* collapsible snippets: collapsible before hidable */
228
+ .hidable {
229
+ max-height: 0;
230
+ overflow: hidden;
231
+ transition: max-height 0.2s ease-out;
232
+ }
233
+
234
+ .collapsible {
235
+ background-color: #777;
236
+ color: white;
237
+ cursor: pointer;
238
+ padding: 12px 0;
239
+ margin: 0;
240
+ width: 100%;
241
+ border: none;
242
+ text-align: left;
243
+ outline: none;
244
+ font-size: 15px;
245
+ }
246
+
247
+ .active, .collapsible:hover {
248
+ background-color: #555;
249
+ }
250
+
251
+ .collapsible:after {
252
+ content: '\25bc';
253
+ color: white;
254
+ font-weight: bold;
255
+ float: right;
256
+ margin-left: 12px;
257
+ margin-right: 12px;
258
+ }
259
+
260
+ .active:after {
261
+ content: "\25b2";
262
+ }
263
+
264
+ /* collapsible: */
265
+ .collapsible + .hidable {
266
+ margin-top: 0;
267
+ }
268
+
269
+ .collapsible:not(.active) + .hidable {
270
+ overflow: hidden;
271
+ padding: 0;
272
+ }
@@ -185,3 +185,21 @@ $('#toggle').on('click', function(){
185
185
  anchors.add('h1, h2, h3, h4');
186
186
  </script>
187
187
 
188
+ <script>
189
+ // use .collapsible element to toggle visibility of element following it
190
+ var coll = document.getElementsByClassName("collapsible");
191
+ var i;
192
+
193
+ for (i = 0; i < coll.length; i++) {
194
+ coll[i].addEventListener("click", function() {
195
+ this.classList.toggle("active");
196
+ var content = this.nextElementSibling;
197
+ if (content.style.maxHeight){
198
+ content.style.maxHeight = null;
199
+ } else {
200
+ content.style.maxHeight = content.scrollHeight + "px";
201
+ }
202
+ });
203
+ }
204
+ </script>
205
+
@@ -6,7 +6,7 @@ module IsoDoc
6
6
  class PresentationXMLConvert < ::IsoDoc::Convert
7
7
  def lower2cap(text)
8
8
  /^[[:upper:]][[:upper:]]/.match?(text) and return text
9
- text.capitalize
9
+ text&.capitalize
10
10
  end
11
11
 
12
12
  def block_delim
@@ -24,7 +24,7 @@ module IsoDoc
24
24
  def save_attachment(attachment, dir)
25
25
  n = File.join(dir, File.basename(attachment["name"]))
26
26
  c = attachment.text.sub(%r{^data:[^;]+;(?:charset=[^;]+;)?base64,}, "")
27
- File.open(n, "wb") { |f| f.write(Base64.strict_decode64(c)) }
27
+ File.open(n, "wb") { |f| f.write(Base64.decode64(c)) }
28
28
  end
29
29
 
30
30
  def extension_insert(xml, path = [])
@@ -2,19 +2,22 @@ module IsoDoc
2
2
  class PresentationXMLConvert < ::IsoDoc::Convert
3
3
  def recommendation(docxml)
4
4
  docxml.xpath(ns("//recommendation")).each do |f|
5
- recommendation1(f, lower2cap(@i18n.recommendation))
5
+ recommendation1(f, lower2cap(f["class"]) ||
6
+ lower2cap(@i18n.recommendation))
6
7
  end
7
8
  end
8
9
 
9
10
  def requirement(docxml)
10
11
  docxml.xpath(ns("//requirement")).each do |f|
11
- recommendation1(f, lower2cap(@i18n.requirement))
12
+ recommendation1(f, lower2cap(f["class"]) ||
13
+ lower2cap(@i18n.requirement))
12
14
  end
13
15
  end
14
16
 
15
17
  def permission(docxml)
16
18
  docxml.xpath(ns("//permission")).each do |f|
17
- recommendation1(f, lower2cap(@i18n.permission))
19
+ recommendation1(f, lower2cap(f["class"]) ||
20
+ lower2cap(@i18n.permission))
18
21
  end
19
22
  end
20
23
 
@@ -21,12 +21,17 @@ module IsoDoc
21
21
  end
22
22
  end
23
23
 
24
+ def unnumbered_clause?(elem)
25
+ !elem.ancestors("boilerplate, metanorma-extension").empty? ||
26
+ @suppressheadingnumbers || elem["unnumbered"] ||
27
+ elem.at("./ancestor::*[@unnumbered = 'true']")
28
+ end
29
+
24
30
  def clause1(elem)
25
31
  level = @xrefs.anchor(elem["id"], :level, false) ||
26
32
  (elem.ancestors("clause, annex").size + 1)
27
33
  t = elem.at(ns("./title")) and t["depth"] = level
28
- !elem.ancestors("boilerplate, metanorma-extension").empty? ||
29
- @suppressheadingnumbers || elem["unnumbered"] and return
34
+ unnumbered_clause?(elem) and return
30
35
  lbl = @xrefs.anchor(elem["id"], :label,
31
36
  elem.parent.name != "sections") or return
32
37
  prefix_name(elem, "<tab/>", "#{lbl}#{clausedelim}", "title")
@@ -65,6 +70,7 @@ module IsoDoc
65
70
  if t = elem.at(ns("./title"))
66
71
  t.children = "<strong>#{to_xml(t.children)}</strong>"
67
72
  end
73
+ unnumbered_clause?(elem) and return
68
74
  prefix_name(elem, "<br/><br/>", lbl, "title")
69
75
  end
70
76
 
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.11.0".freeze
2
+ VERSION = "2.11.1".freeze
3
3
  end
@@ -132,6 +132,7 @@ container: false)
132
132
  end
133
133
 
134
134
  def reqt2class_label(elem, model)
135
+ elem["class"] and return [elem["class"], elem["class"]]
135
136
  model.req_class_paths.each do |n|
136
137
  v1 = ns("/#{n[:xpath]}").sub(%r{^/}, "")
137
138
  elem.at("./self::#{v1}") and return [n[:klass], n[:label]]
@@ -17,6 +17,7 @@ module IsoDoc
17
17
  i = Counter.new("@")
18
18
  clause_order_annex(xml).each do |a|
19
19
  xml.xpath(ns(a[:path])).each do |c|
20
+ unnumbered_section_name?(c) and next
20
21
  annex_names(c, i.increment(c).print)
21
22
  a[:multi] or break
22
23
  end
@@ -125,7 +126,7 @@ module IsoDoc
125
126
 
126
127
  def preface_name_anchors(clause, level, title)
127
128
  @anchors[clause["id"]] =
128
- { label: nil, level: level,
129
+ { label: nil, level:,
129
130
  xref: title, title: nil,
130
131
  type: "clause", elem: @labels["clause"] }
131
132
  end
@@ -170,7 +171,7 @@ module IsoDoc
170
171
  def section_name_anchors(clause, num, level)
171
172
  @anchors[clause["id"]] =
172
173
  { label: num, xref: l10n("#{@labels['clause']} #{num}"),
173
- title: clause_title(clause), level: level, type: "clause",
174
+ title: clause_title(clause), level:, type: "clause",
174
175
  elem: @labels["clause"] }
175
176
  end
176
177
 
@@ -188,9 +189,9 @@ module IsoDoc
188
189
  level == 1 && clause.name == "annex" and
189
190
  label = annex_name_lbl(clause, num)
190
191
  @anchors[clause["id"]] =
191
- { label: label,
192
+ { label:,
192
193
  elem: @labels["annex"], type: "clause",
193
- subtype: "annex", value: num.to_s, level: level,
194
+ subtype: "annex", value: num.to_s, level:,
194
195
  title: clause_title(clause),
195
196
  xref: "#{@labels['annex']} #{num}" }
196
197
  end
data/lib/isodoc/xref.rb CHANGED
@@ -29,7 +29,7 @@ module IsoDoc
29
29
  @locale = options[:locale]
30
30
  @reqt_models = @klass.requirements_processor
31
31
  .new({
32
- default: "default", lang: lang, script: script,
32
+ default: "default", lang:, script:,
33
33
  labels: @i18n.get
34
34
  })
35
35
  @i18n
@@ -45,7 +45,7 @@ module IsoDoc
45
45
  ret[MN2PDF_FONT_MANIFEST] = font_manifest
46
46
  @aligncrosselements && !@aligncrosselements.empty? and
47
47
  ret["--param align-cross-elements="] =
48
- @aligncrosselements.gsub(/,/, " ")
48
+ @aligncrosselements.tr(",", " ")
49
49
  @baseassetpath and
50
50
  ret["--param baseassetpath="] = @baseassetpath
51
51
  ret.merge(@pdf_cmd_options)
@@ -54,15 +54,14 @@ module IsoDoc
54
54
  # input_file: keep-alive tempfile
55
55
  def convert(input_fname, file = nil, debug = false,
56
56
  output_fname = nil)
57
- file = File.read(input_fname, encoding: "utf-8") if file.nil?
58
- input_file, docxml, filename =
59
- input_xml_path(input_fname, file, debug)
57
+ file ||= File.read(input_fname, encoding: "utf-8")
58
+ _, docxml, filename = input_xml_path(input_fname, file, debug)
59
+ xsl = pdf_stylesheet(docxml) or return
60
+ Pathname.new(xsl).absolute? or xsl = File.join(@libdir, xsl)
60
61
  @doctype = Nokogiri::XML(file).at(ns("//bibdata/ext/doctype"))&.text
61
62
  ::Metanorma::Output::XslfoPdf.new.convert(
62
- filename,
63
- output_fname || output_filename(input_fname),
64
- File.join(@libdir, pdf_stylesheet(docxml)),
65
- pdf_options(docxml),
63
+ filename, output_fname || output_filename(input_fname),
64
+ xsl, pdf_options(docxml)
66
65
  )
67
66
  end
68
67
 
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.11.0
4
+ version: 2.11.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-08-06 00:00:00.000000000 Z
11
+ date: 2024-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64