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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17e14b978b65a7667074ab1dff17bd5dc76a58e6baf7ace593407dc921ddf558
4
- data.tar.gz: 3622549bc44570ec6e8de62fb55a62af937e32306ccc444bfaf0a1063caae511
3
+ metadata.gz: e07a78782a0c09a2c70525f1d7d4b8f5d34ea8d731c3dbc5860b7386250c1e56
4
+ data.tar.gz: bb3ddf0e119c8cf4b4d25c70ba381dba043020c132edd13fc4934bb08871594e
5
5
  SHA512:
6
- metadata.gz: 2cffca2a878c9bc3e05d26b85edb21be9ff27a75b8fd6e9ab7b31cdb861915b41baeb9e4b4027fb5f8f5e751879143dd55ea7cc35d46d6feb507d2a83632ff2b
7
- data.tar.gz: 5146c2a8457a5f41232b6176acb3bf5fd77bfb75941b9030f6c015463cfe7646e6a3df153423229a3c9a17e0aa6c02529062bffdd1e98ad116fb91f1d61f6306
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>No terms and definitions are listed in this document.</p>
21
+ <p>لم يتم سرد أي مصطلحات وتعريفات في هذا المستند.</p>
22
22
  internal_terms_boilerplate: |
23
- <p>For the purposes of this document,
24
- the following terms and definitions apply.</p>
23
+ <p>لأغراض هذا المستند، تنطبق المصطلحات والتعريفات التالية.</p>
25
24
  norm_with_refs_pref:
26
- The following documents are referred to in the text in such a way
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
- There are no normative references in this document.
27
+ لا توجد مراجع معيارية في هذه الوثيقة.
33
28
  external_terms_boilerplate: |
34
- <p>For the purposes of this document,
35
- the terms and definitions given in % apply.</p>
29
+ <p> لأغراض هذا المستند ، تنطبق المصطلحات والتعريفات الواردة في%. </ p>
36
30
  internal_external_terms_boilerplate: |
37
- <p>For the purposes of this document, the terms and definitions
38
- given in % and the following apply.</p>
39
- term_defined_in: "[term defined in %]"
31
+ <p>لأغراض هذه الوثيقة ،تنطبق المصطلحات والتعاريف الواردة في % وما يلي.</p>
32
+ term_defined_in: "[المصطلح المحدد في %]"
40
33
  note: ملاحظة
41
34
  note_xref: ملاحظة
42
- termnote: Note % to entry
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: Key
45
+ key: مفتاح
52
46
  example: مثال
53
47
  example_xref: مثال
54
48
  where: حيث
55
49
  wholeoftext: كامل النص
56
- draft_label: draft
57
- inform_annex: informative
58
- norm_annex: normative
50
+ draft_label: مسودة
51
+ inform_annex: إخباري
52
+ norm_annex: مقياسي
59
53
  modified: معدلة
60
- deprecated: 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: Warning
82
- caution: 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
- "Note % to entry":
112
- sg: Note % to entry
113
- pl: Notes % to entry
105
+ "ملاحظة % للقيد":
106
+ sg: ملاحظة % للقيد
107
+ pl: ملاحظات % للقيد
114
108
  قائمة:
115
109
  sg: قائمة
116
110
  pl: قوائم
@@ -36,6 +36,7 @@ note: HINWEIS
36
36
  note_xref: Hinweis
37
37
  termnote: Hinweis % zum Eintrag
38
38
  list: Liste
39
+ deflist: Definitionsliste
39
40
  figure: Abbildung
40
41
  formula: Formel
41
42
  inequality: Formel
@@ -42,6 +42,7 @@ note: NOTE
42
42
  note_xref: Note
43
43
  termnote: Note % to entry
44
44
  list: List
45
+ deflist: Definition List
45
46
  figure: Figure
46
47
  formula: Formula
47
48
  inequality: Formula
@@ -38,6 +38,7 @@ note: NOTA
38
38
  note_xref: Nota
39
39
  termnote: Nota % a la entrada
40
40
  list: Lista
41
+ deflist: Lista de definiciones
41
42
  figure: Figura
42
43
  formula: Fórmula
43
44
  inequality: Fórmula
@@ -38,6 +38,7 @@ figure: Figure
38
38
  formula: Formule
39
39
  inequality: Formule
40
40
  list: Liste
41
+ deflist: Liste de définitions
41
42
  table: Tableau
42
43
  requirement: Exigence
43
44
  recommendation: Recommandation
@@ -41,6 +41,7 @@ note: ПРИМЕЧАНИЕ
41
41
  note_xref: Примечание
42
42
  termnote: Примечание % к определению
43
43
  list: Список
44
+ deflist: Список определений
44
45
  figure: Рисунок
45
46
  formula: Формула
46
47
  inequality: Формула
@@ -40,6 +40,7 @@ figure: 图
40
40
  formula: 公式
41
41
  inequality: 公式
42
42
  list: 列项
43
+ deflist: 定义列表
43
44
  table: 表
44
45
  requirement: 要求
45
46
  recommendation: 建议
@@ -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
@@ -225,7 +225,7 @@ module IsoDoc::Function
225
225
  end
226
226
 
227
227
  def svg_parse(node, out)
228
- out << node.to_xml
228
+ out.parent.add_child(node)
229
229
  end
230
230
  end
231
231
  end
@@ -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
- insert_indirect_biblio(xml, refs, key)
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 insert_indirect_biblio(xmldoc, refs, prefix)
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 = ins.add_child("<references hidden='true' normative='false'/>").first
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(f)
23
- return unless %r{^data:image/svg\+xml;base64,}.match?(f["src"])
22
+ def svg_extract(elem)
23
+ return unless %r{^data:image/svg\+xml;base64,}.match?(elem["src"])
24
24
 
25
- svg = Base64.strict_decode64(f["src"]
25
+ svg = Base64.strict_decode64(elem["src"]
26
26
  .sub(%r{^data:image/svg\+xml;base64,}, ""))
27
- f.replace(svg.sub(/<\?xml[^>]*>/, ""))
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
- content = node.first_element_child.children.reject do |c|
166
- %w{locality localityStack}.include? c.name
167
- end.select { |c| !c.text? || /\S/.match(c) }
168
- n = if content.empty?
169
- @i18n.term_defined_in.sub(/%/, node.first_element_child.to_xml)
170
- else
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)
@@ -29,12 +29,12 @@ module IsoDoc
29
29
  end
30
30
 
31
31
  def section(docxml)
32
- display_order docxml
33
32
  clause docxml
34
33
  annex docxml
35
34
  term docxml
36
35
  references docxml
37
36
  index docxml
37
+ display_order docxml
38
38
  end
39
39
 
40
40
  def block(docxml)
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "1.6.7.1".freeze
2
+ VERSION = "1.7.0".freeze
3
3
  end
data/lib/isodoc/xref.rb CHANGED
@@ -28,16 +28,16 @@ module IsoDoc
28
28
  @anchors
29
29
  end
30
30
 
31
- def anchor(id, lbl, warning = true)
32
- return nil if id.nil? || id.empty?
31
+ def anchor(ident, lbl, warning = true)
32
+ return nil if ident.nil? || ident.empty?
33
33
 
34
- if warning && !@anchors[id]
34
+ if warning && !@anchors[ident]
35
35
  @seen ||= Seen_Anchor.instance
36
- @seen.seen(id) or warn "No label has been processed for ID #{id}"
37
- @seen.add(id)
38
- return "[#{id}]"
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(id, lbl)
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::XrefGen
4
- module Anchor
5
- class Seen_Anchor
6
- include Singleton
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
- @seen = {}
23
+ @anchors = {}
10
24
  end
11
25
 
12
- def seen(x)
13
- @seen.has_key?(x)
26
+ def get_anchors
27
+ @anchors
14
28
  end
15
29
 
16
- def add(x)
17
- @seen[x] = true
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
- def anchor_struct_label(lbl, elem)
30
- case elem
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
- def anchor_struct_value(lbl, elem)
42
- case elem
43
- when @labels["formula"] then "(#{lbl})"
44
- when @labels["inequality"] then "(#{lbl})"
45
- else
46
- lbl
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
- def anchor_struct(lbl, container, elem, type, unnumbered = false)
51
- ret = {}
52
- ret[:label] = unnumbered == "true" ? nil : anchor_struct_label(lbl, elem)
53
- ret[:xref] = anchor_struct_xref(unnumbered == "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
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