isodoc 2.6.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/base_style/metanorma_word.css +3 -3
- data/lib/isodoc/base_style/metanorma_word.scss +5 -3
- data/lib/isodoc/common.rb +13 -13
- data/lib/isodoc/init.rb +8 -0
- data/lib/isodoc/metadata.rb +3 -3
- data/lib/isodoc/metadata_contributor.rb +7 -1
- data/lib/isodoc/presentation_function/inline.rb +12 -13
- data/lib/isodoc/presentation_function/section.rb +11 -14
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xref/xref_sect_gen.rb +90 -34
- data/lib/isodoc-yaml/i18n-ar.yaml +1 -1
- data/lib/isodoc-yaml/i18n-de.yaml +1 -1
- data/lib/isodoc-yaml/i18n-en.yaml +1 -1
- data/lib/isodoc-yaml/i18n-es.yaml +1 -1
- data/lib/isodoc-yaml/i18n-fr.yaml +1 -1
- data/lib/isodoc-yaml/i18n-ja.yaml +1 -1
- data/lib/isodoc-yaml/i18n-ru.yaml +1 -1
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b149d913a483c336d7463e587e980fe234f4d1e32d8d683a070d919b0ce7429
|
4
|
+
data.tar.gz: 46e568e2b91f13069f62131ab1b86e28fd74416c55ae0937935575927a578430
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae43a3f990e70f7d1929357172ca48b4cbc5db2750e61d1f91768c8087e796f5e333de64b60fc928434862e1fb874151c6a00a0cd41e25d491fe79e8604dfa9d
|
7
|
+
data.tar.gz: 9abab47db0d610e3971c1f9a19af240449dc11d6cd1d8d0f9e1e860f4b00e4a6947cce60d8483ba8701a180472278badaee6d431a07bd32ba1727ea5ad4d9a16
|
data/lib/isodoc/common.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require_relative "
|
2
|
-
require_relative "
|
3
|
-
require_relative "
|
4
|
-
require_relative "
|
5
|
-
require_relative "
|
6
|
-
require_relative "
|
7
|
-
require_relative "
|
8
|
-
require_relative "
|
9
|
-
require_relative "
|
10
|
-
require_relative "
|
11
|
-
require_relative "
|
12
|
-
require_relative "
|
13
|
-
require_relative "
|
1
|
+
require_relative "function/blocks"
|
2
|
+
require_relative "function/cleanup"
|
3
|
+
require_relative "function/form"
|
4
|
+
require_relative "function/inline"
|
5
|
+
require_relative "function/lists"
|
6
|
+
require_relative "function/references"
|
7
|
+
require_relative "function/section"
|
8
|
+
require_relative "function/table"
|
9
|
+
require_relative "function/terms"
|
10
|
+
require_relative "function/to_word_html"
|
11
|
+
require_relative "function/utils"
|
12
|
+
require_relative "function/reqt"
|
13
|
+
require_relative "class_utils"
|
14
14
|
|
15
15
|
module IsoDoc
|
16
16
|
class Common
|
data/lib/isodoc/init.rb
CHANGED
@@ -129,5 +129,13 @@ module IsoDoc
|
|
129
129
|
@toctables = options[:toctables]
|
130
130
|
@tocrecommendations = options[:tocrecommendations]
|
131
131
|
end
|
132
|
+
|
133
|
+
AGENCIES = %w(ISO IEC ITU IETF NIST OGC IEEE BIPM BSI BS JIS IANA UN W3C
|
134
|
+
IHO CSA IEV)
|
135
|
+
.freeze
|
136
|
+
|
137
|
+
def agency?(text)
|
138
|
+
self.class::AGENCIES.include?(text)
|
139
|
+
end
|
132
140
|
end
|
133
141
|
end
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require_relative "
|
2
|
-
require_relative "
|
1
|
+
require_relative "metadata_date"
|
2
|
+
require_relative "metadata_contributor"
|
3
3
|
|
4
4
|
module IsoDoc
|
5
5
|
class Metadata
|
@@ -15,7 +15,7 @@ module IsoDoc
|
|
15
15
|
|
16
16
|
def initialize(lang, script, locale, i18n, fonts_options = {})
|
17
17
|
@metadata = { lang: lang, script: script }
|
18
|
-
DATETYPES.each { |w| @metadata["#{w.gsub(
|
18
|
+
DATETYPES.each { |w| @metadata["#{w.gsub('-', '_')}date".to_sym] = "XXX" }
|
19
19
|
@lang = lang
|
20
20
|
@script = script
|
21
21
|
@locale = locale
|
@@ -67,7 +67,7 @@ module IsoDoc
|
|
67
67
|
publisher = []
|
68
68
|
xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'publisher']/" \
|
69
69
|
"organization")).each do |org|
|
70
|
-
name = org.at(ns("./name"))
|
70
|
+
name = extract_variant(org.at(ns("./name")))
|
71
71
|
agency1 = org.at(ns("./abbreviation"))&.text || name
|
72
72
|
publisher << name if name
|
73
73
|
agency = iso?(org) ? "ISO/#{agency}" : "#{agency}#{agency1}/"
|
@@ -75,6 +75,12 @@ module IsoDoc
|
|
75
75
|
[agency, publisher]
|
76
76
|
end
|
77
77
|
|
78
|
+
def extract_variant(node)
|
79
|
+
node.nil? and return node
|
80
|
+
x = node.at(ns("./variant[@language = '#{@lang}']")) and node = x
|
81
|
+
node.text
|
82
|
+
end
|
83
|
+
|
78
84
|
def agency(xml)
|
79
85
|
agency, publisher = agency1(xml)
|
80
86
|
set(:agency, agency.sub(%r{/$}, ""))
|
@@ -10,10 +10,10 @@ module IsoDoc
|
|
10
10
|
|
11
11
|
def get_linkend(node)
|
12
12
|
node["style"] == "id" and anchor_id_postprocess(node)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
xref_empty?(node) or return
|
14
|
+
target = docid_l10n(node["target"]) ||
|
15
|
+
expand_citeas(docid_l10n(node["citeas"]))
|
16
|
+
link = anchor_linkend(node, target)
|
17
17
|
link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
|
18
18
|
link, node)
|
19
19
|
non_locality_elems(node).each(&:remove)
|
@@ -24,8 +24,7 @@ module IsoDoc
|
|
24
24
|
# <locality type="section"><reference>3.1</reference></locality></origin>
|
25
25
|
|
26
26
|
def unnest_linkend(node)
|
27
|
-
|
28
|
-
|
27
|
+
node.at(ns("./xref[@nested]")) or return
|
29
28
|
node.xpath(ns("./xref[@nested]")).each { |x| x.delete("nested") }
|
30
29
|
node.xpath(ns("./location | ./locationStack")).each(&:remove)
|
31
30
|
node.replace(node.children)
|
@@ -64,15 +63,15 @@ module IsoDoc
|
|
64
63
|
get_linkend(node)
|
65
64
|
end
|
66
65
|
|
67
|
-
def variant(
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
66
|
+
def variant(xml)
|
67
|
+
b = xml.xpath(ns("//bibdata//variant"))
|
68
|
+
(xml.xpath(ns("//variant")) - b).each { |f| variant1(f) }
|
69
|
+
(xml.xpath(ns("//variant[@remove = 'true']")) - b).each(&:remove)
|
70
|
+
(xml.xpath(ns("//variant")) - b).each do |v|
|
71
|
+
v.next&.name == "variant" or next
|
73
72
|
v.next = "/"
|
74
73
|
end
|
75
|
-
|
74
|
+
(xml.xpath(ns("//variant")) - b).each { |f| f.replace(f.children) }
|
76
75
|
end
|
77
76
|
|
78
77
|
def variant1(node)
|
@@ -25,9 +25,8 @@ module IsoDoc
|
|
25
25
|
level = @xrefs.anchor(elem["id"], :level, false) ||
|
26
26
|
(elem.ancestors("clause, annex").size + 1)
|
27
27
|
t = elem.at(ns("./title")) and t["depth"] = level
|
28
|
-
|
29
|
-
@suppressheadingnumbers || elem["unnumbered"]
|
30
|
-
|
28
|
+
!elem.ancestors("boilerplate, metanorma-extension").empty? ||
|
29
|
+
@suppressheadingnumbers || elem["unnumbered"] and return
|
31
30
|
lbl = @xrefs.anchor(elem["id"], :label,
|
32
31
|
elem.parent.name != "sections") or return
|
33
32
|
prefix_name(elem, "<tab/>", "#{lbl}#{clausedelim}", "title")
|
@@ -133,17 +132,15 @@ module IsoDoc
|
|
133
132
|
|
134
133
|
def display_order(docxml)
|
135
134
|
i = 0
|
136
|
-
|
137
|
-
i
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
i = display_order_xpath(docxml, "//indexsect", i)
|
146
|
-
display_order_xpath(docxml, "//colophon/*", i)
|
135
|
+
d = @xrefs.clause_order(docxml)
|
136
|
+
%i(preface main annex back).each do |s|
|
137
|
+
d[s].each do |a|
|
138
|
+
i = if a[:multi]
|
139
|
+
display_order_xpath(docxml, a[:path], i)
|
140
|
+
else display_order_at(docxml, a[:path], i)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
147
144
|
end
|
148
145
|
|
149
146
|
def clausetitle(docxml)
|
data/lib/isodoc/version.rb
CHANGED
@@ -1,18 +1,66 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module XrefGen
|
3
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: "//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][not(descendant::terms)]" },
|
23
|
+
{ path: @klass.middle_clause(docxml), multi: true },
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
def clause_order_annex(_docxml)
|
28
|
+
[{ path: "//annex", multi: true }]
|
29
|
+
end
|
30
|
+
|
31
|
+
def clause_order_back(_docxml)
|
32
|
+
[
|
33
|
+
{ path: @klass.bibliography_xpath },
|
34
|
+
{ path: "//indexsect", multi: true },
|
35
|
+
{ path: "//colophon/*", multi: true },
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
4
39
|
def back_anchor_names(xml)
|
5
40
|
if @parse_settings.empty? || @parse_settings[:clauses]
|
6
|
-
|
7
|
-
xml
|
41
|
+
annex_anchor_names(xml)
|
42
|
+
back_clauses_anchor_names(xml)
|
43
|
+
end
|
44
|
+
references(xml) if @parse_settings.empty? || @parse_settings[:refs]
|
45
|
+
end
|
46
|
+
|
47
|
+
def annex_anchor_names(xml)
|
48
|
+
i = Counter.new("@")
|
49
|
+
clause_order_annex(xml).each do |a|
|
50
|
+
xml.xpath(ns(a[:path])).each do |c|
|
8
51
|
annex_names(c, i.increment(c).print)
|
52
|
+
a[:multi] or break
|
9
53
|
end
|
10
|
-
|
11
|
-
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def back_clauses_anchor_names(xml)
|
58
|
+
clause_order_back(xml).each do |a|
|
59
|
+
xml.xpath(ns(a[:path])).each do |c|
|
60
|
+
back_names(c)
|
61
|
+
a[:multi] or break
|
12
62
|
end
|
13
|
-
xml.xpath(ns("//colophon/clause")).each { |b| preface_names(b) }
|
14
63
|
end
|
15
|
-
references(xml) if @parse_settings.empty? || @parse_settings[:refs]
|
16
64
|
end
|
17
65
|
|
18
66
|
def references(docxml)
|
@@ -21,20 +69,29 @@ module IsoDoc
|
|
21
69
|
end
|
22
70
|
end
|
23
71
|
|
24
|
-
def initial_anchor_names(
|
72
|
+
def initial_anchor_names(xml)
|
25
73
|
if @parse_settings.empty? || @parse_settings[:clauses]
|
26
|
-
|
27
|
-
|
74
|
+
preface_anchor_names(xml)
|
75
|
+
main_anchor_names(xml)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def preface_anchor_names(xml)
|
80
|
+
clause_order_preface(xml).each do |a|
|
81
|
+
xml.xpath(ns(a[:path])).each do |c|
|
82
|
+
preface_names(c)
|
83
|
+
a[:multi] or break
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def main_anchor_names(xml)
|
89
|
+
n = Counter.new
|
90
|
+
clause_order_main(xml).each do |a|
|
91
|
+
xml.xpath(ns(a[:path])).each do |c|
|
92
|
+
section_names(c, n, 1)
|
93
|
+
a[:multi] or break
|
28
94
|
end
|
29
|
-
# potentially overridden in middle_section_asset_names()
|
30
|
-
sequential_asset_names(doc.xpath(ns("//preface/*")))
|
31
|
-
n = Counter.new
|
32
|
-
n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
|
33
|
-
n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
|
34
|
-
n = section_names(doc.at(ns("//sections/terms | " \
|
35
|
-
"//sections/clause[descendant::terms]")), n, 1)
|
36
|
-
n = section_names(doc.at(ns("//sections/definitions")), n, 1)
|
37
|
-
clause_names(doc, n)
|
38
95
|
end
|
39
96
|
end
|
40
97
|
|
@@ -57,8 +114,7 @@ module IsoDoc
|
|
57
114
|
ret = clause.at(ns("./title"))&.text
|
58
115
|
if use_elem_name && !ret
|
59
116
|
clause.name.capitalize
|
60
|
-
else
|
61
|
-
ret
|
117
|
+
else ret
|
62
118
|
end
|
63
119
|
end
|
64
120
|
|
@@ -67,8 +123,15 @@ module IsoDoc
|
|
67
123
|
|
68
124
|
# in StanDoc, prefaces have no numbering; they are referenced only by title
|
69
125
|
def preface_names(clause)
|
70
|
-
|
126
|
+
unnumbered_names(clause)
|
127
|
+
end
|
128
|
+
|
129
|
+
def back_names(clause)
|
130
|
+
unnumbered_names(clause)
|
131
|
+
end
|
71
132
|
|
133
|
+
def unnumbered_names(clause)
|
134
|
+
clause.nil? and return
|
72
135
|
preface_name_anchors(clause, 1,
|
73
136
|
clause_title(clause, use_elem_name: true))
|
74
137
|
clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
|
@@ -94,23 +157,15 @@ module IsoDoc
|
|
94
157
|
end
|
95
158
|
|
96
159
|
def middle_section_asset_names(doc)
|
97
|
-
middle_sections =
|
98
|
-
|
99
|
-
|
100
|
-
|
160
|
+
middle_sections =
|
161
|
+
"//clause[@type = 'scope'] | #{@klass.norm_ref_xpath} | " \
|
162
|
+
"//sections/terms | //preface/* | " \
|
163
|
+
"//sections/definitions | //clause[parent::sections]"
|
101
164
|
sequential_asset_names(doc.xpath(ns(middle_sections)))
|
102
165
|
end
|
103
166
|
|
104
|
-
def clause_names(docxml, num)
|
105
|
-
docxml.xpath(ns(@klass.middle_clause(docxml)))
|
106
|
-
.each_with_index do |c, _i|
|
107
|
-
section_names(c, num, 1)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
167
|
def section_names(clause, num, lvl)
|
112
168
|
clause.nil? and return num
|
113
|
-
|
114
169
|
num.increment(clause)
|
115
170
|
section_name_anchors(clause, num.print, lvl)
|
116
171
|
clause.xpath(ns(SUBCLAUSES)).each_with_object(Counter.new) do |c, i|
|
@@ -138,7 +193,8 @@ module IsoDoc
|
|
138
193
|
obl = l10n("(#{@labels['inform_annex']})")
|
139
194
|
clause["obligation"] == "normative" and
|
140
195
|
obl = l10n("(#{@labels['norm_annex']})")
|
141
|
-
title = Common::case_with_markup(@labels["annex"], "capital",
|
196
|
+
title = Common::case_with_markup(@labels["annex"], "capital",
|
197
|
+
@script)
|
142
198
|
l10n("<strong>#{title} #{num}</strong><br/>#{obl}")
|
143
199
|
end
|
144
200
|
|
@@ -30,7 +30,7 @@ external_terms_boilerplate: |
|
|
30
30
|
<p> لأغراض هذا المستند ، تنطبق المصطلحات والتعريفات الواردة في%. </ p>
|
31
31
|
internal_external_terms_boilerplate: |
|
32
32
|
<p>لأغراض هذه الوثيقة ،تنطبق المصطلحات والتعاريف الواردة في % وما يلي.</p>
|
33
|
-
term_defined_in: "
|
33
|
+
term_defined_in: "(%)"
|
34
34
|
binary_and: "%1 و %2"
|
35
35
|
multiple_and: "%1, و %2"
|
36
36
|
binary_or: "%1 او %2"
|
@@ -32,7 +32,7 @@ external_terms_boilerplate: |
|
|
32
32
|
<p>Für die Zwecke dieses Dokuments gelten die in % angegebenen Begriffe und Definitionen.</p>
|
33
33
|
internal_external_terms_boilerplate: |
|
34
34
|
<p>Für die Zwecke dieses Dokuments gelten die in % und im Folgenden aufgeführten Begriffe und Definitionen.</p>
|
35
|
-
term_defined_in: "
|
35
|
+
term_defined_in: "(%)"
|
36
36
|
binary_and: "%1 und %2"
|
37
37
|
multiple_and: "%1, und %2"
|
38
38
|
binary_or: "%1 oder %2"
|
@@ -38,7 +38,7 @@ external_terms_boilerplate: |
|
|
38
38
|
internal_external_terms_boilerplate: |
|
39
39
|
<p>For the purposes of this document, the terms and definitions
|
40
40
|
given in % and the following apply.</p>
|
41
|
-
term_defined_in: "
|
41
|
+
term_defined_in: "(%)"
|
42
42
|
binary_and: "%1 and %2"
|
43
43
|
multiple_and: "%1, and %2"
|
44
44
|
binary_or: "%1 or %2"
|
@@ -34,7 +34,7 @@ external_terms_boilerplate: |
|
|
34
34
|
<p>Para los propósitos de este documento, se aplican los términos y definiciones dados en %.</p>
|
35
35
|
internal_external_terms_boilerplate: |
|
36
36
|
<p>Para los propósitos de este documento, se aplican los términos y definiciones dados en % y los siguientes.</p>
|
37
|
-
term_defined_in: "
|
37
|
+
term_defined_in: "(%)"
|
38
38
|
binary_and: "%1 y %2"
|
39
39
|
multiple_and: "%1, y %2"
|
40
40
|
binary_or: "%1 o %2"
|
@@ -31,7 +31,7 @@ external_terms_boilerplate: |
|
|
31
31
|
<p>Pour les besoins du présent document, les termes et définitions de % s’appliquent.</p>
|
32
32
|
internal_external_terms_boilerplate: |
|
33
33
|
<p>Pour les besoins du présent document, les termes et définitions de % ainsi que les suivants, s’appliquent.</p>
|
34
|
-
term_defined_in: "
|
34
|
+
term_defined_in: "(%)"
|
35
35
|
binary_and: "%1 et %2"
|
36
36
|
multiple_and: "%1, et %2"
|
37
37
|
binary_or: "%1 ou %2"
|
@@ -31,7 +31,7 @@ external_terms_boilerplate: |
|
|
31
31
|
<p>この規格で用いる主な用語及び定義は,% による。</p>
|
32
32
|
internal_external_terms_boilerplate: |
|
33
33
|
<p>この規格で用いる主な用語及び定義は,次によるほか,% による。</p>
|
34
|
-
term_defined_in: "
|
34
|
+
term_defined_in: "(%)"
|
35
35
|
binary_and: "%1 and %2"
|
36
36
|
multiple_and: "%1, and %2"
|
37
37
|
binary_or: "%1 or %2"
|
@@ -37,7 +37,7 @@ external_terms_boilerplate: |
|
|
37
37
|
internal_external_terms_boilerplate: |
|
38
38
|
<p>Для целей этого документа применяются
|
39
39
|
термины и определения, данные в % и следующие.</p>
|
40
|
-
term_defined_in: "
|
40
|
+
term_defined_in: "(%)"
|
41
41
|
binary_and: "%1 и %2"
|
42
42
|
multiple_and: "%1, и %2"
|
43
43
|
binary_or: "%1 или %2"
|
@@ -33,7 +33,7 @@ external_terms_boilerplate: |
|
|
33
33
|
<p>% 界定的术语和定义适用于本文件。</p>
|
34
34
|
internal_external_terms_boilerplate: |
|
35
35
|
<p>% 界定的以及下列术语和定义适用于本文件。</p>
|
36
|
-
term_defined_in: "
|
36
|
+
term_defined_in: "(%)"
|
37
37
|
binary_and: "%1和%2"
|
38
38
|
multiple_and: "%1、和%2"
|
39
39
|
binary_or: "%1或%2"
|
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.6.
|
4
|
+
version: 2.6.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: 2023-08-
|
11
|
+
date: 2023-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html2doc
|