metanorma-bipm 0.0.3 → 1.0.2

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.
@@ -28,11 +28,17 @@
28
28
  </div>
29
29
 
30
30
  <div class="coverpage-title">
31
- {% if appendixtitle %}
31
+ {% if appendixtitle or parttitle or subparttitle %}
32
32
  <span class="title-third">{{ doctitle }}</span>
33
33
  <span class="title-third">{{ docsubtitle }}</span><br/>
34
- <span class="title-first">{% if appendixid %}{{ appendixid}}: {% endif %}{{ appendixtitle }}</span><br/>
35
- <span class="title-second">{% if appendixid_alt %}{{ appendixid_alt}}: {% endif %}{{ appendixsubtitle }}</span>
34
+ {% if partid %}<span class="title-first">{{ partid}}: {{ parttitle }}</span><br/>{% endif %}
35
+ {% if partid_alt %}<span class="title-second">{{ partid_alt}}: {{ partsubtitle }}</span>{% endif %}
36
+ {% if subparttitle %}<span class="title-first">{{ subparttitle }}</span><br/>{% endif %}
37
+ {% if subpartsubtitle %}<span class="title-second">{{ subpartsubtitle }}</span><br/>{% endif %}
38
+ {% if appendixid %}<span class="title-first">{{ appendixid}}: {{ appendixtitle }}</span><br/>{% endif %}
39
+ {% if appendixid_alt %}<span class="title-second">{{ appendixid_alt}}: {{ appendixsubtitle }}</span>{% endif %}
40
+ {% if annexid %}<span class="title-first">{{ annexid}}: {{ annextitle }}</span><br/>{% endif %}
41
+ {% if annexid_alt %}<span class="title-second">{{ annexid_alt}}: {{ annexsubtitle }}</span>{% endif %}
36
42
  {% else %}
37
43
  <span class="title-first">{{ doctitle }}</span><br/>
38
44
  <span class="title-second">{{ docsubtitle }}</span>
@@ -61,6 +67,15 @@
61
67
  <div class="coverpage-tc-name">
62
68
  <span>{{ metadata_extensions["editorialgroup"]["committee_acronym"] }}{% if metadata_extensions["editorialgroup"]["committee_acronym"] and committee %}: {% endif %}{{ committee }}</span>
63
69
  </div>
70
+
71
+ {% if authors %}
72
+ <div class="coverpage-tc-name">
73
+ {% for item in authors %}
74
+ <span>{{item}} {% if authors_affiliations[forloop.index0] %}({{ authors_affiliations[forloop.index0] }}){% endif %}{% if forloop.last == false %}, {% endif %}{% endfor %}.
75
+ </div>
76
+ {% endif %}
77
+
78
+
64
79
  </div>
65
80
 
66
81
  <div class="wrapper-top-bottom"></div>
@@ -213,7 +213,7 @@ body {
213
213
  margin-left: auto;
214
214
  margin-right: auto;
215
215
  max-width: 100%;
216
- font-size: 15px;
216
+ font-size: {{normalfontsize}};
217
217
  font-weight: 300;
218
218
  line-height: 1.4em;
219
219
  color: #1d1d1d;
@@ -450,31 +450,6 @@ p.document-stage {
450
450
  font-weight: 300;
451
451
  height: 160px; }
452
452
 
453
- #proposal-band p {
454
- height: 150px; }
455
-
456
- #standard-band,
457
- #published-band {
458
- background-color: #007864; }
459
-
460
- #standard,
461
- #published {
462
- border-bottom: solid 3px #007864; }
463
-
464
- #governance,
465
- #policy-and-procedures {
466
- border-bottom: solid 3px #750697; }
467
-
468
- #governance-band,
469
- #policy-and-procedures-band {
470
- background-color: #750697; }
471
-
472
- #guide {
473
- border-bottom: solid 3px #48a0e7; }
474
-
475
- #guide-band {
476
- background-color: #48a0e7; }
477
-
478
453
  .coverpage-maturity {
479
454
  font-family: {{bodyfont}};
480
455
  font-weight: 400;
@@ -482,38 +457,6 @@ p.document-stage {
482
457
  margin: 0 0 2em 0;
483
458
  text-transform: uppercase; }
484
459
 
485
- #working-draft,
486
- #proposal {
487
- border-bottom: solid 3px #F7803C; }
488
-
489
- #working-draft-band,
490
- #proposal-band {
491
- background-color: #F7803C; }
492
-
493
- #committee-draft {
494
- border-bottom: solid 3px #fd06fd; }
495
-
496
- #committee-draft-band {
497
- background-color: #fd06fd; }
498
-
499
- #draft-standard {
500
- border-bottom: solid 3px #fdf906; }
501
-
502
- #draft-standard-band {
503
- background-color: #fdf906; }
504
-
505
- #standard {
506
- border-bottom: solid 3px #007864; }
507
-
508
- #standard-band {
509
- background-color: #007864; }
510
-
511
- #obsolete {
512
- border-bottom: solid 3px #7e0d13; }
513
-
514
- #obsolete-band {
515
- background-color: #7e0d13; }
516
-
517
460
  /*
518
461
  3. TYPOGRAPHY
519
462
  */
@@ -612,6 +555,53 @@ ul li:first-child {
612
555
  content: " ";
613
556
  display: none; }
614
557
 
558
+ /* https://github.com/metanorma/metanorma-bipm/issues/47 */
559
+ ol[class="alphabet"] {
560
+ counter-reset: alphabet; }
561
+
562
+ ol[class="roman"] {
563
+ counter-reset: roman; }
564
+
565
+ ol[class="alphabet"] ol[class="alphabet"] {
566
+ counter-reset: none; }
567
+
568
+ ol[class="alphabet"] > li {
569
+ list-style: none;
570
+ position: relative; }
571
+
572
+ ol[class="alphabet"] ol[class="alphabet"] > li {
573
+ list-style: inherit; }
574
+
575
+ ol[class="alphabet"] > li:before {
576
+ counter-increment: alphabet;
577
+ content: counter(alphabet, lower-alpha) ") ";
578
+ position: absolute;
579
+ left: -1.4em; }
580
+
581
+ ol[class="alphabet"] ol[class="alphabet"] > li:before {
582
+ counter-increment: none;
583
+ content: initial; }
584
+
585
+ ol[class="roman"] ol[class="roman"] {
586
+ counter-reset: none; }
587
+
588
+ ol[class="roman"] > li {
589
+ list-style: none;
590
+ position: relative; }
591
+
592
+ ol[class="roman"] ol[class="roman"] > li {
593
+ list-style: inherit; }
594
+
595
+ ol[class="roman"] > li:before {
596
+ counter-increment: roman;
597
+ content: "(" counter(roman, lower-roman) ") ";
598
+ position: absolute;
599
+ left: -2.0em; }
600
+
601
+ ol[class="roman"] ol[class="roman"] > li:before {
602
+ counter-increment: none;
603
+ content: initial; }
604
+
615
605
  /*
616
606
  3.4 Rules
617
607
  */
@@ -635,7 +625,7 @@ p.Biblio, p.NormRef {
635
625
  pre,
636
626
  .pseudocode {
637
627
  background-color: #f7f7f7;
638
- font-size: 0.8em;
628
+ font-size: {{monospacefontsize}};
639
629
  line-height: 1.6em;
640
630
  padding: 1.5em;
641
631
  margin: 2em 0 1em 0;
@@ -731,7 +721,7 @@ a.footnote-number {
731
721
  font-size: 0.8em; }
732
722
 
733
723
  .footnote {
734
- font-size: 0.9em; }
724
+ font-size: {{footnotefontsize}}; }
735
725
 
736
726
  /*
737
727
  3.11 Blockquotes
@@ -36,7 +36,7 @@ $docstage-colors-list: (
36
36
  */
37
37
 
38
38
  body {
39
- @include bodyStyle1(15px, 1.4em, #1d1d1d, #ffffff, 300);
39
+ @include bodyStyle1($normalfontsize, 1.4em, #1d1d1d, #ffffff, 300);
40
40
  font-weight: 400;
41
41
 
42
42
  pre * {
@@ -147,84 +147,10 @@ p.document-stage {
147
147
  height: 160px;
148
148
  }
149
149
 
150
- #proposal-band p {
151
- height: 150px;
152
- }
153
-
154
- #standard-band,
155
- #published-band {
156
- background-color: #007864;
157
- }
158
-
159
- #standard,
160
- #published {
161
- border-bottom: solid 3px #007864;
162
- }
163
-
164
- #governance,
165
- #policy-and-procedures {
166
- border-bottom: solid 3px #750697;
167
- }
168
-
169
- #governance-band,
170
- #policy-and-procedures-band {
171
- background-color: #750697;
172
- }
173
-
174
- #guide {
175
- border-bottom: solid 3px #48a0e7;
176
- }
177
-
178
- #guide-band {
179
- background-color: #48a0e7;
180
- }
181
-
182
150
  .coverpage-maturity {
183
151
  @include coverpageStageBlock();
184
152
  }
185
153
 
186
- #working-draft,
187
- #proposal {
188
- border-bottom: solid 3px #F7803C;
189
- }
190
-
191
- #working-draft-band,
192
- #proposal-band {
193
- background-color: #F7803C;
194
- }
195
-
196
- #committee-draft {
197
- border-bottom: solid 3px #fd06fd;
198
- }
199
-
200
- #committee-draft-band {
201
- background-color: #fd06fd;
202
- }
203
-
204
- #draft-standard {
205
- border-bottom: solid 3px #fdf906;
206
- }
207
-
208
- #draft-standard-band {
209
- background-color: #fdf906;
210
- }
211
-
212
- #standard {
213
- border-bottom: solid 3px #007864;
214
- }
215
-
216
- #standard-band {
217
- background-color: #007864;
218
- }
219
-
220
- #obsolete {
221
- border-bottom: solid 3px #7e0d13;
222
- }
223
-
224
- #obsolete-band {
225
- background-color: #7e0d13;
226
- }
227
-
228
154
  /*
229
155
  3. TYPOGRAPHY
230
156
  */
@@ -330,6 +256,56 @@ ul li:first-child {
330
256
  display: none;
331
257
  }
332
258
 
259
+ /* https://github.com/metanorma/metanorma-bipm/issues/47 */
260
+
261
+ ol[class="alphabet"] {
262
+ counter-reset: alphabet;
263
+ }
264
+ ol[class="roman"] {
265
+ counter-reset: roman;
266
+ }
267
+ ol[class="alphabet"] ol[class="alphabet"] {
268
+ counter-reset: none;
269
+ }
270
+ ol[class="alphabet"] > li {
271
+ list-style: none;
272
+ position: relative;
273
+ }
274
+ ol[class="alphabet"] ol[class="alphabet"] > li {
275
+ list-style: inherit;
276
+ }
277
+ ol[class="alphabet"] > li:before {
278
+ counter-increment: alphabet;
279
+ content: counter(alphabet, lower-alpha)") ";
280
+ position: absolute;
281
+ left: -1.4em;
282
+ }
283
+ ol[class="alphabet"] ol[class="alphabet"] > li:before {
284
+ counter-increment: none;
285
+ content: initial;
286
+ }
287
+ ol[class="roman"] ol[class="roman"] {
288
+ counter-reset: none;
289
+ }
290
+ ol[class="roman"] > li {
291
+ list-style: none;
292
+ position: relative;
293
+ }
294
+ ol[class="roman"] ol[class="roman"] > li {
295
+ list-style: inherit;
296
+ }
297
+ ol[class="roman"] > li:before {
298
+ counter-increment: roman;
299
+ content: "("counter(roman, lower-roman)") ";
300
+ position: absolute;
301
+ left: -2.0em;
302
+ }
303
+ ol[class="roman"] ol[class="roman"] > li:before {
304
+ counter-increment: none;
305
+ content: initial;
306
+ }
307
+
308
+
333
309
 
334
310
  /*
335
311
  3.4 Rules
@@ -425,7 +401,7 @@ a.footnote-number {
425
401
  }
426
402
 
427
403
  .footnote {
428
- font-size: 0.9em;
404
+ font-size: $footnotefontsize;
429
405
  }
430
406
 
431
407
 
@@ -22,6 +22,23 @@ module IsoDoc
22
22
  end
23
23
  end
24
24
 
25
+ def counter_reset(node)
26
+ s = node["start"]
27
+ return nil unless s && !s.empty? && !s.to_i.zero?
28
+ "counter-reset: #{node['type']} #{s.to_i - 1};"
29
+ end
30
+
31
+ def ol_attrs(node)
32
+ klass, style = if node["type"] == "roman" &&
33
+ !node.at("./ancestor::xmlns:ol[@type = 'roman']") ||
34
+ node["type"] == "alphabet" &&
35
+ !node.at("./ancestor::xmlns:ol[@type = 'alphabet']")
36
+ [node["type"], counter_reset(node)]
37
+ end
38
+ super.merge(attr_code(type: ol_style((node["type"] || "arabic").to_sym),
39
+ start: node["start"]), style: style, class: klass)
40
+ end
41
+
25
42
  include BaseConvert
26
43
  include Init
27
44
  end
@@ -1,2 +1,10 @@
1
1
  annex: Appendix
2
+ appendix: Annex
2
3
  see: see
4
+ see_also: see also
5
+ clause: Chapter
6
+ subclause: Section
7
+ formula: Equation
8
+ inequality: Inequality
9
+ bibliography: References
10
+ index: Index
@@ -1,5 +1,22 @@
1
1
  annex: Annexe
2
+ appendix: Appendice
2
3
  see: voir
4
+ see_also: voir aussi
5
+ clause: chapître
6
+ subclause: section
7
+ formula: équation
8
+ inequality: inégalité
9
+ bibliography: Références
10
+ note_xref: note
11
+ termnote: note % à l’article
12
+ list: liste
13
+ figure: figure
14
+ table: tableau
15
+ requirement: exigence
16
+ recommendation: recommandation
17
+ permission: autorisation
18
+ example_xref: exemple
19
+ index: Index
3
20
  doctype_dict:
4
21
  brochure: brochure
5
22
  mise-en-pratique: mise-en-pratique
@@ -13,7 +30,7 @@ doctype_dict:
13
30
  cipm-mra: cipm-mra
14
31
  resolution: résolution
15
32
  stage_dict:
16
- draft-proposal: projet-de-proposition
17
- draft-development: projet-de-développement
18
- in-force: en-vigeur
19
- retired: retiré
33
+ draft-proposal: projet-de-proposition
34
+ draft-development: projet-de-développement
35
+ in-force: en-vigeur
36
+ retired: retiré
@@ -0,0 +1,136 @@
1
+ require "twitter_cldr"
2
+ require "sterile"
3
+
4
+ module IsoDoc
5
+ module BIPM
6
+ class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
7
+ def add_id
8
+ %(id="_#{UUIDTools::UUID.random_create}")
9
+ end
10
+
11
+ def index(docxml)
12
+ return unless docxml.at(ns("//index"))
13
+ i = docxml.root.add_child "<clause type='index' #{add_id}><title>#{@i18n.index}</title></clause>"
14
+ index = sort_indexterms(docxml.xpath(ns("//index")), docxml.xpath(ns("//index-xref[@also = 'false']")),
15
+ docxml.xpath(ns("//index-xref[@also = 'true']")))
16
+ index1(docxml, i, index)
17
+ end
18
+
19
+ def index1(docxml, i, index)
20
+ index.keys.sort.each do |k|
21
+ c = i.first.add_child "<clause #{add_id}><title>#{k}</title><ul></ul></clause>"
22
+ words = index[k].keys.each_with_object({}) { |w, v| v[sortable(w).downcase] = w }
23
+ words.keys.localize(@lang.to_sym).sort.to_a.each do |w|
24
+ c.first.at(ns("./ul")).add_child index_entries(words, index[k], w)
25
+ end
26
+ end
27
+ @xrefs.bookmark_anchor_names(docxml.xpath(ns(@xrefs.sections_xpath)))
28
+ end
29
+
30
+ def sortable(s)
31
+ HTMLEntities.new.decode(Nokogiri::XML.fragment(s).text)
32
+ end
33
+
34
+ def index_entries_opt
35
+ { xref_lbl: ", ", see_lbl: ", #{see_lbl}", also_lbl: ", #{also_lbl}" }
36
+ end
37
+
38
+ def index_entries(words, index, primary)
39
+ ret = index_entries_head(words[primary], index.dig(words[primary], nil, nil), index_entries_opt)
40
+ words2 = index[words[primary]]&.keys&.reject { |k| k.nil?}&.each_with_object({}) { |w, v| v[w.downcase] = w }
41
+ unless words2.empty?
42
+ ret += "<ul>"
43
+ words2.keys.localize(@lang.to_sym).sort.to_a.each do |w|
44
+ ret += index_entries2(words2, index[words[primary]], w)
45
+ end
46
+ ret += "</ul>"
47
+ end
48
+ ret + "</li>"
49
+ end
50
+
51
+ def index_entries2(words, index, secondary)
52
+ ret = index_entries_head(words[secondary], index.dig(words[secondary], nil), index_entries_opt)
53
+ words3 = index[words[secondary]]&.keys&.reject { |k| k.nil?}&.each_with_object({}) { |w, v| v[w.downcase] = w }
54
+ unless words3.empty?
55
+ ret += "<ul>"
56
+ words3.keys.localize(@lang.to_sym).sort.to_a.each do |w|
57
+ ret += (index_entries_head(words3[w], index[words[secondary]][words3[w]], index_entries_opt) + "</li>")
58
+ end
59
+ ret += "</ul>"
60
+ end
61
+ ret + "</li>"
62
+ end
63
+
64
+ def index_entries_head(head, entries, opt)
65
+ ret = "<li>#{head}"
66
+ xref = entries&.dig(:xref)&.join(", ")
67
+ see_sort = entries&.dig(:see)&.each_with_object({}) { |w, v| v[sortable(w).downcase] = w }
68
+ see = see_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map { |k| see_sort[k] }&.join(", ")
69
+ also_sort = entries&.dig(:also)&.each_with_object({}) { |w, v| v[sortable(w).downcase] = w }
70
+ also = also_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map { |k| also_sort[k] }&.join(", ")
71
+ ret += "#{opt[:xref_lbl]} #{xref}" if xref
72
+ ret += "#{opt[:see_lbl]} #{see}" if see
73
+ ret += "#{opt[:also_lbl]} #{also}" if also
74
+ ret
75
+ end
76
+
77
+ def see_lbl
78
+ @lang == "en" ? @i18n.see : "<em>#{@i18n.see}</em>"
79
+ end
80
+
81
+ def also_lbl
82
+ @lang == "en" ? @i18n.see_also : "<em>#{@i18n.see_also}</em>"
83
+ end
84
+
85
+ def sort_indexterms(terms, see, also)
86
+ index = extract_indexterms(terms)
87
+ index = extract_indexsee(index, see, :see)
88
+ index = extract_indexsee(index, also, :also)
89
+ index.keys.sort.each_with_object({}) do |k, v|
90
+ v[sortable(k)[0].upcase.transliterate] ||= {}
91
+ v[sortable(k)[0].upcase.transliterate][k] = index[k]
92
+ end
93
+ end
94
+
95
+ def extract_indexsee(v, terms, label)
96
+ terms.each_with_object(v) do |t, v|
97
+ term = t&.at(ns("./primary"))&.children&.to_xml
98
+ term2 = t&.at(ns("./secondary"))&.children&.to_xml
99
+ term3 = t&.at(ns("./tertiary"))&.children&.to_xml
100
+ v[term] ||= {}
101
+ v[term][term2] ||= {}
102
+ v[term][term2][term3] ||= {}
103
+ v[term][term2][term3][label] ||= []
104
+ v[term][term2][term3][label] << t&.at(ns("./target"))&.children&.to_xml
105
+ t.remove
106
+ end
107
+ end
108
+
109
+ def xml_encode_attr(s)
110
+ HTMLEntities.new.encode(s, :basic, :hexadecimal).gsub(/\&#x([^;]+);/) { |x| "&#x#{$1.upcase};" }
111
+ end
112
+
113
+ # attributes are decoded into UTF-8, elements in extract_indexsee are still in entities
114
+ def extract_indexterms(terms)
115
+ terms.each_with_object({}) do |t, v|
116
+ term = t&.at(ns("./primary"))&.children&.to_xml
117
+ term2 = t&.at(ns("./secondary"))&.children&.to_xml
118
+ term3 = t&.at(ns("./tertiary"))&.children&.to_xml
119
+ index2bookmark(t)
120
+ v[term] ||= {}
121
+ v[term][term2] ||= {}
122
+ v[term][term2][term3] ||= {}
123
+ v[term][term2][term3][:xref] ||= []
124
+ to = t["to"] ? "to='#{t['to']}' " : ""
125
+ v[term][term2][term3][:xref] << "<xref target='#{t['id']}' #{to}pagenumber='true'/>"
126
+ end
127
+ end
128
+
129
+ def index2bookmark(t)
130
+ t.name = "bookmark"
131
+ t.children.each { |x| x.remove }
132
+ t["id"] = "_#{UUIDTools::UUID.random_create}"
133
+ end
134
+ end
135
+ end
136
+ end