isodoc 1.6.7.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc-yaml/i18n-ar.yaml +19 -25
- data/lib/isodoc-yaml/i18n-de.yaml +1 -0
- data/lib/isodoc-yaml/i18n-en.yaml +1 -0
- data/lib/isodoc-yaml/i18n-es.yaml +1 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- data/lib/isodoc/convert.rb +1 -1
- data/lib/isodoc/function/blocks.rb +1 -1
- data/lib/isodoc/html_function/postprocess.rb +8 -4
- data/lib/isodoc/html_function/sectionsplit.rb +18 -4
- data/lib/isodoc/presentation_function/block.rb +7 -4
- data/lib/isodoc/presentation_function/inline.rb +7 -12
- data/lib/isodoc/presentation_xml_convert.rb +1 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xref.rb +8 -7
- data/lib/isodoc/xref/xref_anchor.rb +45 -44
- data/lib/isodoc/xref/xref_counter.rb +113 -103
- data/lib/isodoc/xref/xref_gen.rb +39 -11
- data/spec/isodoc/inline_spec.rb +157 -169
- data/spec/isodoc/postproc_spec.rb +68 -24
- data/spec/isodoc/xref_spec.rb +274 -652
- 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: e07a78782a0c09a2c70525f1d7d4b8f5d34ea8d731c3dbc5860b7386250c1e56
|
4
|
+
data.tar.gz: bb3ddf0e119c8cf4b4d25c70ba381dba043020c132edd13fc4934bb08871594e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba808db07e817492e8ceb891771ec1df67f8d4dfab34896eb2eca9accd45ccf110745a5844276e52f1f20c6542cf1d33fdaad816ea3ce0ff264465bd4f4c8d4c
|
7
|
+
data.tar.gz: 0124e13883ab5d0c5f0561c62b924920ae0d73bc4980024f77336a4aed919d175c0f51a464e3574f910ea77ba15bccbf0d86c7e14707a6f4b7bf038ff7f1d80a
|
@@ -18,29 +18,23 @@ clause: فقرة
|
|
18
18
|
annex: ملحق
|
19
19
|
appendix: تذييل
|
20
20
|
no_terms_boilerplate: |
|
21
|
-
<p
|
21
|
+
<p>لم يتم سرد أي مصطلحات وتعريفات في هذا المستند.</p>
|
22
22
|
internal_terms_boilerplate: |
|
23
|
-
<p
|
24
|
-
the following terms and definitions apply.</p>
|
23
|
+
<p>لأغراض هذا المستند، تنطبق المصطلحات والتعريفات التالية.</p>
|
25
24
|
norm_with_refs_pref:
|
26
|
-
|
27
|
-
that some or all of their content constitutes requirements of this
|
28
|
-
document. For dated references, only the edition cited applies.
|
29
|
-
For undated references, the latest edition of the referenced
|
30
|
-
document (including any amendments) applies.
|
25
|
+
تتم الإشارة إلى المستندات التالية في النص بحيث يشكل بعض أو كل محتوياتها متطلبات هذا المستند. للحصول على مراجع مؤرخة، تطبق النسخة المشار إليها فقط. بالنسبة للمراجع غير المؤرخة ، تنطبق أحدث طبعة من الوثيقة المشار إليها (بما في ذلك أي تعديلات).
|
31
26
|
norm_empty_pref:
|
32
|
-
|
27
|
+
لا توجد مراجع معيارية في هذه الوثيقة.
|
33
28
|
external_terms_boilerplate: |
|
34
|
-
<p>
|
35
|
-
the terms and definitions given in % apply.</p>
|
29
|
+
<p> لأغراض هذا المستند ، تنطبق المصطلحات والتعريفات الواردة في%. </ p>
|
36
30
|
internal_external_terms_boilerplate: |
|
37
|
-
<p
|
38
|
-
|
39
|
-
term_defined_in: "[term defined in %]"
|
31
|
+
<p>لأغراض هذه الوثيقة ،تنطبق المصطلحات والتعاريف الواردة في % وما يلي.</p>
|
32
|
+
term_defined_in: "[المصطلح المحدد في %]"
|
40
33
|
note: ملاحظة
|
41
34
|
note_xref: ملاحظة
|
42
|
-
termnote:
|
35
|
+
termnote: ملاحظة % للقيد
|
43
36
|
list: قائمة
|
37
|
+
deflist: قائمة تعريف
|
44
38
|
figure: شكل
|
45
39
|
formula: معادلة
|
46
40
|
inequality: عدم مساواة
|
@@ -48,16 +42,16 @@ table: جدول
|
|
48
42
|
requirement: مطلب
|
49
43
|
recommendation: توصية
|
50
44
|
permission: إذن
|
51
|
-
key:
|
45
|
+
key: مفتاح
|
52
46
|
example: مثال
|
53
47
|
example_xref: مثال
|
54
48
|
where: حيث
|
55
49
|
wholeoftext: كامل النص
|
56
|
-
draft_label:
|
57
|
-
inform_annex:
|
58
|
-
norm_annex:
|
50
|
+
draft_label: مسودة
|
51
|
+
inform_annex: إخباري
|
52
|
+
norm_annex: مقياسي
|
59
53
|
modified: معدلة
|
60
|
-
deprecated:
|
54
|
+
deprecated: مهمل
|
61
55
|
source: مصدر
|
62
56
|
and: و
|
63
57
|
all_parts: كل الأجزاء
|
@@ -78,8 +72,8 @@ subject: موضوع
|
|
78
72
|
inherits: يرث
|
79
73
|
admonition:
|
80
74
|
danger: خطر
|
81
|
-
warning:
|
82
|
-
caution:
|
75
|
+
warning: تحذير
|
76
|
+
caution: حذر
|
83
77
|
important: مهم
|
84
78
|
safety precautions: احتياطات السلامة
|
85
79
|
locality:
|
@@ -108,9 +102,9 @@ inflection:
|
|
108
102
|
ملاحظة:
|
109
103
|
sg: ملاحظة
|
110
104
|
pl: ملاحظات
|
111
|
-
"
|
112
|
-
sg:
|
113
|
-
pl:
|
105
|
+
"ملاحظة % للقيد":
|
106
|
+
sg: ملاحظة % للقيد
|
107
|
+
pl: ملاحظات % للقيد
|
114
108
|
قائمة:
|
115
109
|
sg: قائمة
|
116
110
|
pl: قوائم
|
data/lib/isodoc/convert.rb
CHANGED
@@ -145,7 +145,7 @@ module IsoDoc
|
|
145
145
|
end
|
146
146
|
|
147
147
|
def convert_init(file, input_filename, debug)
|
148
|
-
docxml = Nokogiri::XML(file)
|
148
|
+
docxml = Nokogiri::XML(file) { |config| config.huge }
|
149
149
|
filename, dir = init_file(input_filename, debug)
|
150
150
|
docxml.root.default_namespace = ""
|
151
151
|
lang = docxml&.at(ns("//bibdata/language"))&.text and @lang = lang
|
@@ -19,7 +19,6 @@ module IsoDoc
|
|
19
19
|
|
20
20
|
def toHTML(result, filename)
|
21
21
|
result = from_xhtml(html_cleanup(to_xhtml(result)))
|
22
|
-
# result = populate_template(result, :html)
|
23
22
|
result = from_xhtml(move_images(to_xhtml(result)))
|
24
23
|
result = html5(script_cdata(inject_script(result)))
|
25
24
|
File.open(filename, "w:UTF-8") { |f| f.write(result) }
|
@@ -33,7 +32,14 @@ module IsoDoc
|
|
33
32
|
def html_cleanup(html)
|
34
33
|
html = term_header(html_footnote_filter(html_preface(htmlstyle(html))))
|
35
34
|
html = footnote_format(footnote_backlinks(html_toc(html)))
|
36
|
-
mathml(html_list_clean(html))
|
35
|
+
mathml(html_list_clean(remove_placeholder_paras(html)))
|
36
|
+
end
|
37
|
+
|
38
|
+
def remove_placeholder_paras(html)
|
39
|
+
%w(title-section prefatory-section).each do |s|
|
40
|
+
html&.at("//div[@class = '#{s}']/p[last()]")&.remove
|
41
|
+
end
|
42
|
+
html
|
37
43
|
end
|
38
44
|
|
39
45
|
def html_list_clean(html)
|
@@ -99,7 +105,6 @@ module IsoDoc
|
|
99
105
|
def html_cover(docxml)
|
100
106
|
doc = to_xhtml_fragment(File.read(@htmlcoverpage, encoding: "UTF-8"))
|
101
107
|
d = docxml.at('//div[@class="title-section"]')
|
102
|
-
# d.children.first.add_previous_sibling doc.to_xml(encoding: "US-ASCII")
|
103
108
|
d.children.first.add_previous_sibling(
|
104
109
|
populate_template(doc.to_xml(encoding: "US-ASCII"), :html),
|
105
110
|
)
|
@@ -108,7 +113,6 @@ module IsoDoc
|
|
108
113
|
def html_intro(docxml)
|
109
114
|
doc = to_xhtml_fragment(File.read(@htmlintropage, encoding: "UTF-8"))
|
110
115
|
d = docxml.at('//div[@class="prefatory-section"]')
|
111
|
-
# d.children.first.add_previous_sibling doc.to_xml(encoding: "US-ASCII")
|
112
116
|
d.children.first.add_previous_sibling(
|
113
117
|
populate_template(doc.to_xml(encoding: "US-ASCII"), :html),
|
114
118
|
)
|
@@ -99,7 +99,9 @@ module IsoDoc::HtmlFunction
|
|
99
99
|
refs = eref_to_internal_eref(xml, key)
|
100
100
|
refs += xref_to_internal_eref(xml, key)
|
101
101
|
xml.root["type"] = key # to force recognition of internal refs
|
102
|
-
|
102
|
+
ins = new_hidden_ref(xml)
|
103
|
+
copy_repo_items_biblio(ins, xml)
|
104
|
+
insert_indirect_biblio(ins, refs, key)
|
103
105
|
end
|
104
106
|
|
105
107
|
def svg_preprocess(xml)
|
@@ -164,15 +166,27 @@ module IsoDoc::HtmlFunction
|
|
164
166
|
def eref_to_internal_eref_select(xml)
|
165
167
|
refs = xml.xpath(("//*/@bibitemid")).map { |x| x.text } # rubocop:disable Style/SymbolProc
|
166
168
|
refs.uniq.reject do |x|
|
167
|
-
xml.at(ns("//bibitem[@id = '#{x}'][@type = 'internal']"))
|
169
|
+
xml.at(ns("//bibitem[@id = '#{x}'][@type = 'internal']")) ||
|
170
|
+
xml.at(ns("//bibitem[@id = '#{x}']"\
|
171
|
+
"[docidentifier/@type = 'repository']"))
|
168
172
|
end
|
169
173
|
end
|
170
174
|
|
171
175
|
# from standoc
|
172
|
-
def
|
176
|
+
def new_hidden_ref(xmldoc)
|
173
177
|
ins = xmldoc.at("bibliography") or
|
174
178
|
xmldoc.root << "<bibliography/>" and ins = xmldoc.at("bibliography")
|
175
|
-
ins
|
179
|
+
ins.add_child("<references hidden='true' normative='false'/>").first
|
180
|
+
end
|
181
|
+
|
182
|
+
def copy_repo_items_biblio(ins, xml)
|
183
|
+
xml.xpath(ns("//references/bibitem[docidentifier/@type = 'repository']"))
|
184
|
+
.each do |b|
|
185
|
+
ins << b.dup
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def insert_indirect_biblio(ins, refs, prefix)
|
176
190
|
refs.each do |x|
|
177
191
|
ins << <<~BIBENTRY
|
178
192
|
<bibitem id="#{x}" type="internal">
|
@@ -19,12 +19,15 @@ module IsoDoc
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def svg_extract(
|
23
|
-
return unless %r{^data:image/svg\+xml;base64,}.match?(
|
22
|
+
def svg_extract(elem)
|
23
|
+
return unless %r{^data:image/svg\+xml;base64,}.match?(elem["src"])
|
24
24
|
|
25
|
-
svg = Base64.strict_decode64(
|
25
|
+
svg = Base64.strict_decode64(elem["src"]
|
26
26
|
.sub(%r{^data:image/svg\+xml;base64,}, ""))
|
27
|
-
|
27
|
+
x = Nokogiri::XML.fragment(svg.sub(/<\?xml[^>]*>/, "")) do |config|
|
28
|
+
config.huge
|
29
|
+
end
|
30
|
+
elem.replace(x)
|
28
31
|
end
|
29
32
|
|
30
33
|
def figure1(f)
|
@@ -129,10 +129,8 @@ module IsoDoc
|
|
129
129
|
|
130
130
|
loc = @i18n.locality[type] || type.sub(/^locality:/, "")
|
131
131
|
loc = case node["case"]
|
132
|
-
when "capital" then loc.capitalize
|
133
132
|
when "lowercase" then loc.downcase
|
134
|
-
else
|
135
|
-
loc.capitalize
|
133
|
+
else loc.capitalize
|
136
134
|
end
|
137
135
|
" #{loc}"
|
138
136
|
end
|
@@ -162,15 +160,12 @@ module IsoDoc
|
|
162
160
|
end
|
163
161
|
|
164
162
|
def concept1(node)
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
"<em>#{node.children.to_xml}</em>"
|
172
|
-
end
|
173
|
-
node.replace(n)
|
163
|
+
node&.at(ns("./refterm"))&.remove
|
164
|
+
d = node&.at(ns("./renderterm"))
|
165
|
+
d&.name = "em"
|
166
|
+
r = node.at(ns("./xref | ./eref | ./termref"))
|
167
|
+
r.replace(@i18n.term_defined_in.sub(/%/, r.to_xml))
|
168
|
+
node.replace(node.children)
|
174
169
|
end
|
175
170
|
|
176
171
|
def variant(docxml)
|
data/lib/isodoc/version.rb
CHANGED
data/lib/isodoc/xref.rb
CHANGED
@@ -28,16 +28,16 @@ module IsoDoc
|
|
28
28
|
@anchors
|
29
29
|
end
|
30
30
|
|
31
|
-
def anchor(
|
32
|
-
return nil if
|
31
|
+
def anchor(ident, lbl, warning = true)
|
32
|
+
return nil if ident.nil? || ident.empty?
|
33
33
|
|
34
|
-
if warning && !@anchors[
|
34
|
+
if warning && !@anchors[ident]
|
35
35
|
@seen ||= Seen_Anchor.instance
|
36
|
-
@seen.seen(
|
37
|
-
@seen.add(
|
38
|
-
return "[#{
|
36
|
+
@seen.seen(ident) or warn "No label has been processed for ID #{ident}"
|
37
|
+
@seen.add(ident)
|
38
|
+
return "[#{ident}]"
|
39
39
|
end
|
40
|
-
@anchors.dig(
|
40
|
+
@anchors.dig(ident, lbl)
|
41
41
|
end
|
42
42
|
|
43
43
|
# extract names for all anchors, xref and label
|
@@ -50,6 +50,7 @@ module IsoDoc
|
|
50
50
|
note_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
51
51
|
example_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
52
52
|
list_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
53
|
+
deflist_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
53
54
|
bookmark_anchor_names(docxml)
|
54
55
|
end
|
55
56
|
|
@@ -1,61 +1,62 @@
|
|
1
1
|
require "singleton"
|
2
2
|
|
3
|
-
module IsoDoc
|
4
|
-
module
|
5
|
-
|
6
|
-
|
3
|
+
module IsoDoc
|
4
|
+
module XrefGen
|
5
|
+
module Anchor
|
6
|
+
class Seen_Anchor
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@seen = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def seen(elem)
|
14
|
+
@seen.has_key?(elem)
|
15
|
+
end
|
16
|
+
|
17
|
+
def add(elem)
|
18
|
+
@seen[elem] = true
|
19
|
+
end
|
20
|
+
end
|
7
21
|
|
8
22
|
def initialize
|
9
|
-
@
|
23
|
+
@anchors = {}
|
10
24
|
end
|
11
25
|
|
12
|
-
def
|
13
|
-
@
|
26
|
+
def get_anchors
|
27
|
+
@anchors
|
14
28
|
end
|
15
29
|
|
16
|
-
def
|
17
|
-
|
30
|
+
def anchor_struct_label(lbl, elem)
|
31
|
+
case elem
|
32
|
+
when @labels["appendix"] then l10n("#{elem} #{lbl}")
|
33
|
+
else
|
34
|
+
lbl.to_s
|
35
|
+
end
|
18
36
|
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize()
|
22
|
-
@anchors = {}
|
23
|
-
end
|
24
|
-
|
25
|
-
def get_anchors
|
26
|
-
@anchors
|
27
|
-
end
|
28
37
|
|
29
|
-
|
30
|
-
|
31
|
-
when @labels["appendix"] then l10n("#{elem} #{lbl}")
|
32
|
-
else
|
33
|
-
lbl.to_s
|
38
|
+
def anchor_struct_xref(lbl, elem)
|
39
|
+
l10n("#{elem} #{anchor_struct_value(lbl, elem)}")
|
34
40
|
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def anchor_struct_xref(lbl, elem)
|
38
|
-
l10n("#{elem} #{anchor_struct_value(lbl, elem)}")
|
39
|
-
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
def anchor_struct_value(lbl, elem)
|
43
|
+
case elem
|
44
|
+
when @labels["formula"], @labels["inequality"] then "(#{lbl})"
|
45
|
+
else
|
46
|
+
lbl
|
47
|
+
end
|
47
48
|
end
|
48
|
-
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
def anchor_struct(lbl, container, elem, type, unnumb = false)
|
51
|
+
ret = {}
|
52
|
+
ret[:label] = unnumb == "true" ? nil : anchor_struct_label(lbl, elem)
|
53
|
+
ret[:xref] = anchor_struct_xref(unnumb == "true" ? "(??)" : lbl, elem)
|
54
|
+
ret[:xref].gsub!(/ $/, "")
|
55
|
+
ret[:container] = @klass.get_clause_id(container) unless container.nil?
|
56
|
+
ret[:type] = type
|
57
|
+
ret[:value] = anchor_struct_value(lbl, elem)
|
58
|
+
ret
|
59
|
+
end
|
59
60
|
end
|
60
61
|
end
|
61
62
|
end
|