metanorma-itu 1.1.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,4 @@
1
1
  require "isodoc"
2
- require_relative "metadata"
3
2
  require "fileutils"
4
3
 
5
4
  module IsoDoc
@@ -11,15 +10,17 @@ module IsoDoc
11
10
  end
12
11
 
13
12
  def annex_name_lbl(clause, num)
14
- lbl = clause["obligation"] == "informative" ? @labels["appendix"] : @labels["annex"]
15
- l10n("<b>#{lbl} #{num}</b>")
13
+ lbl = clause["obligation"] == "informative" ?
14
+ @labels["appendix"] : @labels["annex"]
15
+ l10n("<strong>#{lbl} #{num}</strong>")
16
16
  end
17
17
 
18
18
  def annex_names(clause, num)
19
- lbl = clause["obligation"] == "informative" ? @labels["appendix"] : @labels["annex"]
19
+ lbl = clause["obligation"] == "informative" ?
20
+ @labels["appendix"] : @labels["annex"]
20
21
  @anchors[clause["id"]] =
21
22
  { label: annex_name_lbl(clause, num), type: "clause",
22
- xref: "#{lbl} #{num}", level: 1 }
23
+ xref: "#{lbl} #{num}", level: 1, value: num }
23
24
  if a = single_annex_special_section(clause)
24
25
  annex_names1(a, "#{num}", 1)
25
26
  else
@@ -33,13 +34,16 @@ module IsoDoc
33
34
 
34
35
  def back_anchor_names(docxml)
35
36
  super
36
- if annexid = docxml&.at(ns("//bibdata/ext/structuredidentifier/annexid"))&.text
37
+ if annexid =
38
+ docxml&.at(ns("//bibdata/ext/structuredidentifier/annexid"))&.text
37
39
  docxml.xpath(ns("//annex")).each { |c| annex_names(c, annexid) }
38
40
  else
39
- docxml.xpath(ns("//annex[@obligation = 'informative']")).each_with_index do |c, i|
41
+ docxml.xpath(ns("//annex[@obligation = 'informative']"))
42
+ .each_with_index do |c, i|
40
43
  annex_names(c, RomanNumerals.to_roman(i + 1))
41
44
  end
42
- docxml.xpath(ns("//annex[not(@obligation = 'informative')]")).each_with_index do |c, i|
45
+ docxml.xpath(ns("//annex[not(@obligation = 'informative')]"))
46
+ .each_with_index do |c, i|
43
47
  annex_names(c, (65 + i + (i > 7 ? 1 : 0)).chr.to_s)
44
48
  end
45
49
  end
@@ -49,7 +53,8 @@ module IsoDoc
49
53
  @anchors[clause["id"]] =
50
54
  { label: num, xref: "#{@labels["annex_subclause"]} #{num}",
51
55
  level: level, type: "clause" }
52
- clause.xpath(ns("./clause | ./references | ./terms | ./definitions")).each_with_index do |c, i|
56
+ clause.xpath(ns("./clause | ./references | ./terms | ./definitions"))
57
+ .each_with_index do |c, i|
53
58
  annex_names1(c, "#{num}.#{i + 1}", level + 1)
54
59
  end
55
60
  end
@@ -58,11 +63,11 @@ module IsoDoc
58
63
  d.xpath(ns("//boilerplate//clause")).each { |c| preface_names(c) }
59
64
  d.xpath("//xmlns:preface/child::*").each { |c| preface_names(c) }
60
65
  @hierarchical_assets ?
61
- hierarchical_asset_names(d.xpath("//xmlns:preface/child::*"), "Preface") :
62
- sequential_asset_names(d.xpath("//xmlns:preface/child::*"))
63
- n = section_names(d.at(ns("//clause[title = 'Scope']")), 0, 1)
64
- n = section_names(d.at(ns("//bibliography/clause[.//references[@normative = 'true']] | "\
65
- "//bibliography/references[@normative = 'true']")), n, 1)
66
+ hierarchical_asset_names(d.xpath("//xmlns:preface/child::*"),
67
+ "Preface") :
68
+ sequential_asset_names(d.xpath("//xmlns:preface/child::*"))
69
+ n = section_names(d.at(ns("//clause[@type = 'scope']")), 0, 1)
70
+ n = section_names(d.at(ns(@klass.norm_ref_xpath)), n, 1)
66
71
  n = section_names(d.at(ns("//sections/terms | "\
67
72
  "//sections/clause[descendant::terms]")), n, 1)
68
73
  n = section_names(d.at(ns("//sections/definitions")), n, 1)
@@ -72,15 +77,17 @@ module IsoDoc
72
77
  termexample_anchor_names(d)
73
78
  end
74
79
 
75
- MIDDLE_SECTIONS = "//clause[title = 'Scope'] | "\
76
- "//foreword | //introduction | //acknowledgements | "\
77
- "//references[@normative = 'true'] | "\
78
- "//sections/terms | //preface/clause | "\
79
- "//sections/definitions | //clause[parent::sections]".freeze
80
+ def middle_sections
81
+ "//clause[@type = 'scope'] | "\
82
+ "//foreword | //introduction | //acknowledgements | "\
83
+ " #{@klass.norm_ref_xpath} | "\
84
+ "//sections/terms | //preface/clause | "\
85
+ "//sections/definitions | //clause[parent::sections]"
86
+ end
80
87
 
81
88
  def middle_section_asset_names(d)
82
89
  return super unless @hierarchical_assets
83
- d.xpath(ns(MIDDLE_SECTIONS)).each do |c|
90
+ d.xpath(ns(middle_sections)).each do |c|
84
91
  hierarchical_asset_names(c, @anchors[c["id"]][:label])
85
92
  end
86
93
  end
@@ -94,7 +101,7 @@ module IsoDoc
94
101
  j = 0
95
102
  c.increment(t)
96
103
  end
97
- label = c.print + (j.zero? ? "" : "-#{(96 + j).chr.to_s}")
104
+ label = c.print + (j.zero? ? "" : "#{hierfigsep}#{(96 + j).chr.to_s}")
98
105
  next if t["id"].nil? || t["id"].empty?
99
106
  @anchors[t["id"]] =
100
107
  anchor_struct(label, nil, @labels["figure"], "figure", t["unnumbered"])
@@ -104,7 +111,8 @@ module IsoDoc
104
111
  def hierarchical_figure_names(clause, num)
105
112
  c = IsoDoc::XrefGen::Counter.new
106
113
  j = 0
107
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).each do |t|
114
+ clause.xpath(ns(".//figure | "\
115
+ ".//sourcecode[not(ancestor::example)]")).each do |t|
108
116
  if t.parent.name == "figure" then j += 1
109
117
  else
110
118
  j = 0
@@ -113,13 +121,14 @@ module IsoDoc
113
121
  label = "#{num}#{hiersep}#{c.print}" +
114
122
  (j.zero? ? "" : "#{hierfigsep}#{(96 + j).chr.to_s}")
115
123
  next if t["id"].nil? || t["id"].empty?
116
- @anchors[t["id"]] = anchor_struct(label, nil, @labels["figure"], "figure",
117
- t["unnumbered"])
124
+ @anchors[t["id"]] =
125
+ anchor_struct(label, nil, @labels["figure"], "figure",
126
+ t["unnumbered"])
118
127
  end
119
128
  end
120
129
 
121
130
  def sequential_formula_names(clause)
122
- clause&.first&.xpath(ns(MIDDLE_SECTIONS))&.each do |c|
131
+ clause&.first&.xpath(ns(middle_sections))&.each do |c|
123
132
  if c["id"] && @anchors[c["id"]]
124
133
  hierarchical_formula_names(c, @anchors[c["id"]][:label] ||
125
134
  @anchors[c["id"]][:xref] || "???")
@@ -133,16 +142,17 @@ module IsoDoc
133
142
  c = IsoDoc::XrefGen::Counter.new
134
143
  clause.xpath(ns(".//formula")).each do |t|
135
144
  next if t["id"].nil? || t["id"].empty?
136
- @anchors[t["id"]] =
137
- anchor_struct("#{num}-#{c.increment(t).print}", nil,
138
- t["inequality"] ? @labels["inequality"] : @labels["formula"],
139
- "formula", t["unnumbered"])
145
+ @anchors[t["id"]] = anchor_struct(
146
+ "#{num}-#{c.increment(t).print}", nil,
147
+ t["inequality"] ? @labels["inequality"] : @labels["formula"],
148
+ "formula", t["unnumbered"])
140
149
  end
141
150
  end
142
151
 
143
152
  def reference_names(ref)
144
153
  super
145
- @anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref].sub(/^\[/, '').sub(/\]$/, '') }
154
+ @anchors[ref["id"]] =
155
+ { xref: @anchors[ref["id"]][:xref].sub(/^\[/, '').sub(/\]$/, '') }
146
156
  end
147
157
 
148
158
  def termnote_anchor_names(docxml)
@@ -152,8 +162,12 @@ module IsoDoc
152
162
  notes.each do |n|
153
163
  return if n["id"].nil? || n["id"].empty?
154
164
  idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
155
- @anchors[n["id"]] = anchor_struct(idx, n, @labels["note_xref"],
156
- "termnote", false)
165
+ @anchors[n["id"]] =
166
+ { label: termnote_label(idx).strip, type: "termnote",
167
+ value: idx,
168
+ xref: l10n("#{anchor(t['id'], :xref)}, "\
169
+ "#{@labels["note_xref"]} #{c.print}") }
170
+
157
171
  end
158
172
  end
159
173
  end
@@ -33,13 +33,17 @@ module Metanorma
33
33
  def output(isodoc_node, inname, outname, format, options={})
34
34
  case format
35
35
  when :html
36
- IsoDoc::ITU::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
36
+ IsoDoc::ITU::HtmlConvert.new(options).convert(inname, isodoc_node,
37
+ nil, outname)
37
38
  when :doc
38
- IsoDoc::ITU::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
39
+ IsoDoc::ITU::WordConvert.new(options).convert(inname, isodoc_node,
40
+ nil, outname)
39
41
  when :pdf
40
- IsoDoc::ITU::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
42
+ IsoDoc::ITU::PdfConvert.new(options).convert(inname, isodoc_node,
43
+ nil, outname)
41
44
  when :presentation
42
- IsoDoc::ITU::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
45
+ IsoDoc::ITU::PresentationXMLConvert.new(options).convert(
46
+ inname, isodoc_node, nil, outname)
43
47
  else
44
48
  super
45
49
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ITU
3
- VERSION = "1.1.3"
3
+ VERSION = "1.2.4"
4
4
  end
5
5
  end
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_dependency "htmlentities", "~> 4.3.4"
28
28
  spec.add_dependency "ruby-jing"
29
- spec.add_dependency "metanorma-standoc", "~> 1.4.0"
30
- spec.add_dependency "isodoc", "~> 1.1.0"
29
+ spec.add_dependency "metanorma-standoc", "~> 1.6.0"
30
+ spec.add_dependency "isodoc", "~> 1.2.0"
31
31
 
32
32
  spec.add_development_dependency "byebug", "~> 9.1"
33
33
  spec.add_development_dependency "sassc", "2.4.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-itu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-26 00:00:00.000000000 Z
11
+ date: 2020-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.4.0
47
+ version: 1.6.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.4.0
54
+ version: 1.6.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: isodoc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.1.0
61
+ version: 1.2.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.1.0
68
+ version: 1.2.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: byebug
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -264,7 +264,6 @@ files:
264
264
  - lib/asciidoctor/itu/cleanup.rb
265
265
  - lib/asciidoctor/itu/converter.rb
266
266
  - lib/asciidoctor/itu/front.rb
267
- - lib/asciidoctor/itu/i18n-en.yaml
268
267
  - lib/asciidoctor/itu/isodoc.rng
269
268
  - lib/asciidoctor/itu/itu.rng
270
269
  - lib/asciidoctor/itu/macros.rb
@@ -292,6 +291,8 @@ files:
292
291
  - lib/isodoc/itu/html/wordstyle.scss
293
292
  - lib/isodoc/itu/html_convert.rb
294
293
  - lib/isodoc/itu/i18n-en.yaml
294
+ - lib/isodoc/itu/i18n.rb
295
+ - lib/isodoc/itu/init.rb
295
296
  - lib/isodoc/itu/itu.recommendation-annex.xsl
296
297
  - lib/isodoc/itu/itu.recommendation.xsl
297
298
  - lib/isodoc/itu/itu.resolution.xsl
@@ -300,6 +301,7 @@ files:
300
301
  - lib/isodoc/itu/presentation_xml_convert.rb
301
302
  - lib/isodoc/itu/ref.rb
302
303
  - lib/isodoc/itu/terms.rb
304
+ - lib/isodoc/itu/word_cleanup.rb
303
305
  - lib/isodoc/itu/word_convert.rb
304
306
  - lib/isodoc/itu/xref.rb
305
307
  - lib/metanorma-itu.rb
@@ -1,16 +0,0 @@
1
- norm_with_refs_pref:
2
- The following ITU-T Recommendations and other references contain provisions which, through reference in this text, constitute provisions of this Recommendation. At the time of publication, the editions indicated were valid. All Recommendations and other references are subject to revision; users of this Recommendation are therefore encouraged to investigate the possibility of applying the most recent edition of the Recommendations and other references listed below. A list of the currently valid ITU-T Recommendations is regularly published. The reference to a document within this Recommendation does not give it, as a stand-alone document, the status of a Recommendation.
3
- term_def_boilerplate:
4
- "This Recommendation defines the following terms:"
5
- internal_terms_boilerplate:
6
- "This Recommendation defines the following terms:"
7
- external_terms_boilerplate:
8
- "This Recommendation uses the following terms defined elsewhere:"
9
- no_terms_boilerplate:
10
- None.
11
- symbols_boilerplate:
12
- "This Recommendation uses the following abbreviations and acronyms:"
13
- norm_empty_pref:
14
- None.
15
- clause_empty:
16
- None.