isodoc 1.7.4 → 1.7.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,160 +1,165 @@
1
- module IsoDoc::XrefGen
2
- module Sections
3
- def back_anchor_names(docxml)
4
- i = Counter.new("@")
5
- docxml.xpath(ns("//annex")).each do |c|
6
- i.increment(c)
7
- annex_names(c, i.print)
1
+ module IsoDoc
2
+ module XrefGen
3
+ module Sections
4
+ def back_anchor_names(docxml)
5
+ i = Counter.new("@")
6
+ docxml.xpath(ns("//annex")).each do |c|
7
+ i.increment(c)
8
+ annex_names(c, i.print)
9
+ end
10
+ docxml.xpath(ns(@klass.bibliography_xpath)).each do |b|
11
+ preface_names(b)
12
+ end
13
+ docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
14
+ reference_names(ref)
15
+ end
8
16
  end
9
- docxml.xpath(ns(@klass.bibliography_xpath)).each do |b|
10
- preface_names(b)
17
+
18
+ def initial_anchor_names(doc)
19
+ doc.xpath(ns("//preface/*")).each do |c|
20
+ c.element? and preface_names(c)
21
+ end
22
+ # potentially overridden in middle_section_asset_names()
23
+ sequential_asset_names(doc.xpath(ns("//preface/*")))
24
+ n = Counter.new
25
+ n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
26
+ n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
27
+ n = section_names(doc.at(ns("//sections/terms | "\
28
+ "//sections/clause[descendant::terms]")), n, 1)
29
+ n = section_names(doc.at(ns("//sections/definitions")), n, 1)
30
+ clause_names(doc, n)
31
+ middle_section_asset_names(doc)
32
+ termnote_anchor_names(doc)
33
+ termexample_anchor_names(doc)
11
34
  end
12
- docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
13
- reference_names(ref)
35
+
36
+ def preface_clause_name(clause)
37
+ clause.at(ns("./title"))&.text || clause.name.capitalize
14
38
  end
15
- end
16
39
 
17
- def initial_anchor_names(doc)
18
- doc.xpath(ns("//preface/*")).each { |c| c.element? and preface_names(c) }
19
- # potentially overridden in middle_section_asset_names()
20
- sequential_asset_names(doc.xpath(ns("//preface/*")))
21
- n = Counter.new
22
- n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
23
- n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
24
- n = section_names(doc.at(ns("//sections/terms | "\
25
- "//sections/clause[descendant::terms]")), n, 1)
26
- n = section_names(doc.at(ns("//sections/definitions")), n, 1)
27
- clause_names(doc, n)
28
- middle_section_asset_names(doc)
29
- termnote_anchor_names(doc)
30
- termexample_anchor_names(doc)
31
- end
40
+ SUBCLAUSES =
41
+ "./clause | ./references | ./term | ./terms | ./definitions".freeze
32
42
 
33
- def preface_clause_name(clause)
34
- clause.at(ns("./title"))&.text || clause.name.capitalize
35
- end
43
+ # in StanDoc, prefaces have no numbering; they are referenced only by title
44
+ def preface_names(clause)
45
+ return if clause.nil?
36
46
 
37
- SUBCLAUSES =
38
- "./clause | ./references | ./term | ./terms | ./definitions".freeze
47
+ @anchors[clause["id"]] =
48
+ { label: nil, level: 1, xref: preface_clause_name(clause),
49
+ type: "clause" }
50
+ clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
51
+ preface_names1(c, c.at(ns("./title"))&.text,
52
+ "#{preface_clause_name(clause)}, #{i + 1}", 2)
53
+ end
54
+ end
39
55
 
40
- # in StanDoc, prefaces have no numbering; they are referenced only by title
41
- def preface_names(clause)
42
- return if clause.nil?
56
+ def preface_names1(clause, title, parent_title, level)
57
+ label = title || parent_title
58
+ @anchors[clause["id"]] =
59
+ { label: nil, level: level, xref: label, type: "clause" }
60
+ clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
61
+ preface_names1(c, c.at(ns("./title"))&.text, "#{label} #{i + 1}",
62
+ level + 1)
63
+ end
64
+ end
43
65
 
44
- @anchors[clause["id"]] =
45
- { label: nil, level: 1, xref: preface_clause_name(clause),
46
- type: "clause" }
47
- clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
48
- preface_names1(c, c.at(ns("./title"))&.text,
49
- "#{preface_clause_name(clause)}, #{i + 1}", 2)
66
+ def middle_section_asset_names(doc)
67
+ middle_sections = "//clause[@type = 'scope'] | "\
68
+ "#{@klass.norm_ref_xpath} | "\
69
+ "//sections/terms | //preface/* | "\
70
+ "//sections/definitions | //clause[parent::sections]"
71
+ sequential_asset_names(doc.xpath(ns(middle_sections)))
50
72
  end
51
- end
52
73
 
53
- def preface_names1(clause, title, parent_title, level)
54
- label = title || parent_title
55
- @anchors[clause["id"]] =
56
- { label: nil, level: level, xref: label, type: "clause" }
57
- clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
58
- preface_names1(c, c.at(ns("./title"))&.text, "#{label} #{i + 1}",
59
- level + 1)
74
+ def clause_names(docxml, num)
75
+ docxml.xpath(ns(@klass.middle_clause(docxml))).each_with_index do |c, _i|
76
+ section_names(c, num, 1)
77
+ end
60
78
  end
61
- end
62
79
 
63
- def middle_section_asset_names(doc)
64
- middle_sections = "//clause[@type = 'scope'] | "\
65
- "#{@klass.norm_ref_xpath} | "\
66
- "//sections/terms | //preface/* | "\
67
- "//sections/definitions | //clause[parent::sections]"
68
- sequential_asset_names(doc.xpath(ns(middle_sections)))
69
- end
80
+ def section_names(clause, num, lvl)
81
+ return num if clause.nil?
70
82
 
71
- def clause_names(docxml, num)
72
- docxml.xpath(ns(@klass.middle_clause(docxml))).each_with_index do |c, _i|
73
- section_names(c, num, 1)
83
+ num.increment(clause)
84
+ @anchors[clause["id"]] =
85
+ { label: num.print, xref: l10n("#{@labels['clause']} #{num.print}"),
86
+ level: lvl, type: "clause" }
87
+ i = Counter.new
88
+ clause.xpath(ns(SUBCLAUSES)).each do |c|
89
+ i.increment(c)
90
+ section_names1(c, "#{num.print}.#{i.print}", lvl + 1)
91
+ end
92
+ num
74
93
  end
75
- end
76
94
 
77
- def section_names(clause, num, lvl)
78
- return num if clause.nil?
79
-
80
- num.increment(clause)
81
- @anchors[clause["id"]] =
82
- { label: num.print, xref: l10n("#{@labels['clause']} #{num.print}"),
83
- level: lvl, type: "clause" }
84
- i = Counter.new
85
- clause.xpath(ns(SUBCLAUSES)).each do |c|
86
- i.increment(c)
87
- section_names1(c, "#{num.print}.#{i.print}", lvl + 1)
95
+ def section_names1(clause, num, level)
96
+ @anchors[clause["id"]] =
97
+ { label: num, level: level, xref: l10n("#{@labels['clause']} #{num}"),
98
+ type: "clause" }
99
+ i = Counter.new
100
+ clause.xpath(ns(SUBCLAUSES)).each do |c|
101
+ i.increment(c)
102
+ section_names1(c, "#{num}.#{i.print}", level + 1)
103
+ end
88
104
  end
89
- num
90
- end
91
105
 
92
- def section_names1(clause, num, level)
93
- @anchors[clause["id"]] =
94
- { label: num, level: level, xref: l10n("#{@labels['clause']} #{num}"),
95
- type: "clause" }
96
- i = Counter.new
97
- clause.xpath(ns(SUBCLAUSES)).each do |c|
98
- i.increment(c)
99
- section_names1(c, "#{num}.#{i.print}", level + 1)
106
+ def annex_name_lbl(clause, num)
107
+ obl = l10n("(#{@labels['inform_annex']})")
108
+ clause["obligation"] == "normative" and
109
+ obl = l10n("(#{@labels['norm_annex']})")
110
+ title = Common::case_with_markup(@labels["annex"], "capital", @script)
111
+ l10n("<strong>#{title} #{num}</strong><br/>#{obl}")
100
112
  end
101
- end
102
113
 
103
- def annex_name_lbl(clause, num)
104
- obl = l10n("(#{@labels['inform_annex']})")
105
- clause["obligation"] == "normative" and
106
- obl = l10n("(#{@labels['norm_annex']})")
107
- l10n("<strong>#{@labels['annex']} #{num}</strong><br/>#{obl}")
108
- end
114
+ def single_annex_special_section(clause)
115
+ a = clause.xpath(ns("./references | ./terms | ./definitions"))
116
+ a.size == 1 or return nil
117
+ clause.xpath(ns("./clause | ./p | ./table | ./ol | ./ul | ./dl | "\
118
+ "./note | ./admonition | ./figure")).empty? or
119
+ return nil
120
+ a[0]
121
+ end
109
122
 
110
- def single_annex_special_section(clause)
111
- a = clause.xpath(ns("./references | ./terms | ./definitions"))
112
- a.size == 1 or return nil
113
- clause.xpath(ns("./clause | ./p | ./table | ./ol | ./ul | ./dl | "\
114
- "./note | ./admonition | ./figure")).empty? or
115
- return nil
116
- a[0]
117
- end
123
+ def annex_names(clause, num)
124
+ @anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
125
+ type: "clause", value: num.to_s, level: 1,
126
+ xref: "#{@labels['annex']} #{num}" }
127
+ if a = single_annex_special_section(clause)
128
+ annex_names1(a, num.to_s, 1)
129
+ else
130
+ i = Counter.new
131
+ clause.xpath(ns(SUBCLAUSES)).each do |c|
132
+ i.increment(c)
133
+ annex_names1(c, "#{num}.#{i.print}", 2)
134
+ end
135
+ end
136
+ hierarchical_asset_names(clause, num)
137
+ end
118
138
 
119
- def annex_names(clause, num)
120
- @anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
121
- type: "clause", value: num.to_s,
122
- xref: "#{@labels['annex']} #{num}", level: 1 }
123
- if a = single_annex_special_section(clause)
124
- annex_names1(a, num.to_s, 1)
125
- else
139
+ def annex_names1(clause, num, level)
140
+ @anchors[clause["id"]] = { xref: "#{@labels['annex']} #{num}",
141
+ label: num, level: level, type: "clause" }
126
142
  i = Counter.new
127
143
  clause.xpath(ns(SUBCLAUSES)).each do |c|
128
144
  i.increment(c)
129
- annex_names1(c, "#{num}.#{i.print}", 2)
145
+ annex_names1(c, "#{num}.#{i.print}", level + 1)
130
146
  end
131
147
  end
132
- hierarchical_asset_names(clause, num)
133
- end
134
148
 
135
- def annex_names1(clause, num, level)
136
- @anchors[clause["id"]] = { label: num, xref: "#{@labels['annex']} #{num}",
137
- level: level, type: "clause" }
138
- i = Counter.new
139
- clause.xpath(ns(SUBCLAUSES)).each do |c|
140
- i.increment(c)
141
- annex_names1(c, "#{num}.#{i.print}", level + 1)
149
+ ISO_PUBLISHER_XPATH =
150
+ "./contributor[xmlns:role/@type = 'publisher']/"\
151
+ "organization[abbreviation = 'ISO' or xmlns:abbreviation = 'IEC' or "\
152
+ "xmlns:name = 'International Organization for Standardization' or "\
153
+ "xmlns:name = 'International Electrotechnical Commission']".freeze
154
+
155
+ def reference_names(ref)
156
+ # isopub = ref.at(ns(ISO_PUBLISHER_XPATH))
157
+ ids = @klass.bibitem_ref_code(ref)
158
+ identifiers = @klass.render_identifier(ids)
159
+ # date = ref.at(ns("./date[@type = 'published']"))
160
+ reference = @klass.docid_l10n(identifiers[0] || identifiers[1])
161
+ @anchors[ref["id"]] = { xref: reference }
142
162
  end
143
163
  end
144
-
145
- ISO_PUBLISHER_XPATH =
146
- "./contributor[xmlns:role/@type = 'publisher']/"\
147
- "organization[abbreviation = 'ISO' or xmlns:abbreviation = 'IEC' or "\
148
- "xmlns:name = 'International Organization for Standardization' or "\
149
- "xmlns:name = 'International Electrotechnical Commission']".freeze
150
-
151
- def reference_names(ref)
152
- # isopub = ref.at(ns(ISO_PUBLISHER_XPATH))
153
- ids = @klass.bibitem_ref_code(ref)
154
- identifiers = @klass.render_identifier(ids)
155
- # date = ref.at(ns("./date[@type = 'published']"))
156
- reference = @klass.docid_l10n(identifiers[0] || identifiers[1])
157
- @anchors[ref["id"]] = { xref: reference }
158
- end
159
164
  end
160
165
  end
@@ -20,12 +20,13 @@ module IsoDoc
20
20
  end
21
21
 
22
22
  def pdf_options(_docxml)
23
- if font_manifest_file = @options.dig(MN2PDF_OPTIONS,
24
- MN2PDF_FONT_MANIFEST)
25
- "--font-manifest #{font_manifest_file}"
26
- else
27
- ""
28
- end
23
+ ret = ""
24
+ font_manifest_file = @options.dig(MN2PDF_OPTIONS,
25
+ MN2PDF_FONT_MANIFEST) and
26
+ ret += " --font-manifest #{font_manifest_file}"
27
+ @aligncrosselements && !@aligncrosselements.empty? and
28
+ ret += %( --param align-cross-elements = "#{@aligncrosselements.gsub(/,/, ' ')}")
29
+ ret
29
30
  end
30
31
 
31
32
  def convert(input_filename, file = nil, debug = false,
@@ -6,12 +6,14 @@ source: SOURCE
6
6
  modified: modified
7
7
  scope: Amplekso
8
8
  symbols: Simboloj kai mallongigitaj terminoj
9
- annex: Aldono
9
+ annex: <strong>aldono</strong>
10
10
  normref: Normaj citaĵoj
11
11
  bibliography: Bibliografio
12
12
  inform_annex: informa
13
13
  all_parts: ĉiuj partoj
14
14
  norm_annex: normative
15
+ figure: figur-etikedo duvorta
16
+ example: Ekzempl-etikedo Duvorta
15
17
  note: NOTO
16
18
  locality: {
17
19
  table: Tabelo
data/spec/assets/odf.svg CHANGED
@@ -1,4 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
2
- <circle fill="#009" r="45" cx="50" cy="50"/>
3
- <path d="M33,26H78A37,37,0,0,1,33,83V57H59V43H33Z" fill="#FFF"/>
4
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle fill="#009" r="45" cx="50" cy="50"/><path d="M33,26H78A37,37,0,0,1,33,83V57H59V43H33Z" fill="#FFF"/></svg>