isodoc 1.0.25 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +12 -2
- data/.github/workflows/ubuntu.yml +15 -3
- data/.github/workflows/windows.yml +12 -2
- data/isodoc.gemspec +2 -2
- data/lib/isodoc.rb +2 -0
- data/lib/isodoc/common.rb +0 -4
- data/lib/isodoc/convert.rb +18 -8
- data/lib/isodoc/function/blocks.rb +46 -52
- data/lib/isodoc/function/blocks_example_note.rb +108 -0
- data/lib/isodoc/function/cleanup.rb +14 -2
- data/lib/isodoc/function/i18n.rb +1 -0
- data/lib/isodoc/function/inline.rb +76 -82
- data/lib/isodoc/function/inline_simple.rb +72 -0
- data/lib/isodoc/function/lists.rb +12 -6
- data/lib/isodoc/function/references.rb +49 -53
- data/lib/isodoc/function/reqt.rb +14 -5
- data/lib/isodoc/function/section.rb +10 -12
- data/lib/isodoc/function/table.rb +4 -5
- data/lib/isodoc/function/terms.rb +3 -3
- data/lib/isodoc/function/to_word_html.rb +22 -12
- data/lib/isodoc/function/utils.rb +9 -3
- data/lib/isodoc/headlesshtml_convert.rb +12 -6
- data/lib/isodoc/html_convert.rb +7 -1
- data/lib/isodoc/html_function/footnotes.rb +1 -1
- data/lib/isodoc/html_function/html.rb +16 -1
- data/lib/isodoc/html_function/postprocess.rb +6 -5
- data/lib/isodoc/metadata.rb +6 -0
- data/lib/isodoc/metadata_date.rb +19 -7
- data/lib/isodoc/pdf_convert.rb +13 -6
- data/lib/isodoc/presentation_xml_convert.rb +29 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_convert.rb +7 -1
- data/lib/isodoc/word_function/body.rb +14 -48
- data/lib/isodoc/word_function/footnotes.rb +1 -1
- data/lib/isodoc/word_function/inline.rb +75 -0
- data/lib/isodoc/word_function/postprocess.rb +1 -0
- data/lib/isodoc/word_function/table.rb +3 -3
- data/lib/isodoc/xref.rb +59 -0
- data/lib/isodoc/{function → xref}/xref_anchor.rb +10 -21
- data/lib/isodoc/xref/xref_counter.rb +74 -0
- data/lib/isodoc/{function → xref}/xref_gen.rb +11 -23
- data/lib/isodoc/{function → xref}/xref_gen_seq.rb +41 -32
- data/lib/isodoc/{function → xref}/xref_sect_gen.rb +54 -40
- data/lib/isodoc/xslfo_convert.rb +21 -4
- data/spec/assets/i18n.yaml +4 -1
- data/spec/assets/odf.emf +0 -0
- data/spec/assets/odf.svg +4 -0
- data/spec/assets/odf1.svg +4 -0
- data/spec/isodoc/blocks_spec.rb +271 -48
- data/spec/isodoc/cleanup_spec.rb +139 -17
- data/spec/isodoc/footnotes_spec.rb +20 -5
- data/spec/isodoc/i18n_spec.rb +8 -8
- data/spec/isodoc/inline_spec.rb +299 -4
- data/spec/isodoc/lists_spec.rb +8 -8
- data/spec/isodoc/metadata_spec.rb +110 -3
- data/spec/isodoc/postproc_spec.rb +10 -14
- data/spec/isodoc/presentation_xml_spec.rb +20 -0
- data/spec/isodoc/ref_spec.rb +121 -52
- data/spec/isodoc/section_spec.rb +232 -208
- data/spec/isodoc/table_spec.rb +28 -28
- data/spec/isodoc/terms_spec.rb +7 -7
- data/spec/isodoc/xref_spec.rb +206 -59
- metadata +24 -17
- data/lib/isodoc/function/blocks_example.rb +0 -53
- data/lib/isodoc/function/xref_counter.rb +0 -50
@@ -1,11 +1,9 @@
|
|
1
|
-
require_relative "
|
2
|
-
require_relative "xref_anchor"
|
3
|
-
require_relative "xref_gen_seq"
|
1
|
+
require_relative "xref_gen_seq.rb"
|
4
2
|
|
5
|
-
module IsoDoc::
|
6
|
-
module
|
3
|
+
module IsoDoc::XrefGen
|
4
|
+
module Blocks
|
7
5
|
def termnote_label(n)
|
8
|
-
@
|
6
|
+
@labels["termnote"].gsub(/%/, n.to_s)
|
9
7
|
end
|
10
8
|
|
11
9
|
def termnote_anchor_names(docxml)
|
@@ -17,7 +15,7 @@ module IsoDoc::Function
|
|
17
15
|
@anchors[n["id"]] =
|
18
16
|
{ label: termnote_label(c.print), type: "termnote",
|
19
17
|
xref: l10n("#{anchor(t['id'], :xref)}, "\
|
20
|
-
"#{@
|
18
|
+
"#{@labels["note_xref"]} #{c.print}") }
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
@@ -33,13 +31,14 @@ module IsoDoc::Function
|
|
33
31
|
@anchors[n["id"]] = {
|
34
32
|
type: "termexample", label: idx,
|
35
33
|
xref: l10n("#{anchor(t['id'], :xref)}, "\
|
36
|
-
"#{@
|
34
|
+
"#{@labels["example_xref"]} #{c.print}") }
|
37
35
|
end
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
41
39
|
SECTIONS_XPATH =
|
42
40
|
"//foreword | //introduction | //acknowledgements | //preface/clause | "\
|
41
|
+
"//preface/terms | preface/definitions | preface/references | "\
|
43
42
|
"//sections/terms | //annex | "\
|
44
43
|
"//sections/clause | //sections/definitions | "\
|
45
44
|
"//bibliography/references | //bibliography/clause".freeze
|
@@ -56,7 +55,7 @@ module IsoDoc::Function
|
|
56
55
|
notes.each do |n|
|
57
56
|
next if @anchors[n["id"]] || n["id"].nil? || n["id"].empty?
|
58
57
|
idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
|
59
|
-
@anchors[n["id"]] = anchor_struct(idx, n, @
|
58
|
+
@anchors[n["id"]] = anchor_struct(idx, n, @labels["note_xref"],
|
60
59
|
"note", false)
|
61
60
|
end
|
62
61
|
note_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
@@ -68,7 +67,7 @@ module IsoDoc::Function
|
|
68
67
|
"not(self::xmlns:terms) and not(self::xmlns:definitions)]//"\
|
69
68
|
"xmlns:example | ./xmlns:example".freeze
|
70
69
|
|
71
|
-
CHILD_SECTIONS = "./clause | ./appendix | ./terms | ./definitions"
|
70
|
+
CHILD_SECTIONS = "./clause | ./appendix | ./terms | ./definitions | ./references"
|
72
71
|
|
73
72
|
def example_anchor_names(sections)
|
74
73
|
sections.each do |s|
|
@@ -78,7 +77,7 @@ module IsoDoc::Function
|
|
78
77
|
next if @anchors[n["id"]]
|
79
78
|
next if n["id"].nil? || n["id"].empty?
|
80
79
|
idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
|
81
|
-
@anchors[n["id"]] = anchor_struct(idx, n, @
|
80
|
+
@anchors[n["id"]] = anchor_struct(idx, n, @labels["example_xref"],
|
82
81
|
"example", n["unnumbered"])
|
83
82
|
end
|
84
83
|
example_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
@@ -93,7 +92,7 @@ module IsoDoc::Function
|
|
93
92
|
notes.each do |n|
|
94
93
|
next if n["id"].nil? || n["id"].empty?
|
95
94
|
idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
|
96
|
-
@anchors[n["id"]] = anchor_struct(idx, n, @
|
95
|
+
@anchors[n["id"]] = anchor_struct(idx, n, @labels["list"], "list", false)
|
97
96
|
list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
|
98
97
|
end
|
99
98
|
list_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
@@ -114,16 +113,5 @@ module IsoDoc::Function
|
|
114
113
|
end
|
115
114
|
end
|
116
115
|
end
|
117
|
-
|
118
|
-
# extract names for all anchors, xref and label
|
119
|
-
def anchor_names(docxml)
|
120
|
-
initial_anchor_names(docxml)
|
121
|
-
back_anchor_names(docxml)
|
122
|
-
# preempt clause notes with all other types of note (ISO default)
|
123
|
-
note_anchor_names(docxml.xpath(ns("//table | //figure")))
|
124
|
-
note_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
125
|
-
example_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
126
|
-
list_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
127
|
-
end
|
128
116
|
end
|
129
117
|
end
|
@@ -1,19 +1,32 @@
|
|
1
|
-
module IsoDoc::
|
2
|
-
module
|
1
|
+
module IsoDoc::XrefGen
|
2
|
+
module Blocks
|
3
|
+
def hiersep
|
4
|
+
"."
|
5
|
+
end
|
6
|
+
|
7
|
+
def hierfigsep
|
8
|
+
"-"
|
9
|
+
end
|
10
|
+
|
11
|
+
def subfigure_increment(j, c, t)
|
12
|
+
if t.parent.name == "figure" then j += 1
|
13
|
+
else
|
14
|
+
j = 0
|
15
|
+
c.increment(t)
|
16
|
+
end
|
17
|
+
j
|
18
|
+
end
|
19
|
+
|
3
20
|
def sequential_figure_names(clause)
|
4
21
|
c = Counter.new
|
5
22
|
j = 0
|
6
23
|
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
|
7
24
|
each do |t|
|
8
|
-
|
9
|
-
else
|
10
|
-
j = 0
|
11
|
-
c.increment(t)
|
12
|
-
end
|
25
|
+
j = subfigure_increment(j, c, t)
|
13
26
|
label = c.print + (j.zero? ? "" : "-#{j}")
|
14
27
|
next if t["id"].nil? || t["id"].empty?
|
15
28
|
@anchors[t["id"]] =
|
16
|
-
anchor_struct(label, nil, @
|
29
|
+
anchor_struct(label, nil, @labels["figure"], "figure", t["unnumbered"])
|
17
30
|
end
|
18
31
|
end
|
19
32
|
|
@@ -22,7 +35,7 @@ module IsoDoc::Function
|
|
22
35
|
clause.xpath(ns(".//table")).each do |t|
|
23
36
|
next if t["id"].nil? || t["id"].empty?
|
24
37
|
@anchors[t["id"]] = anchor_struct(c.increment(t).print, nil,
|
25
|
-
@
|
38
|
+
@labels["table"], "table", t["unnumbered"])
|
26
39
|
end
|
27
40
|
end
|
28
41
|
|
@@ -32,7 +45,7 @@ module IsoDoc::Function
|
|
32
45
|
next if t["id"].nil? || t["id"].empty?
|
33
46
|
@anchors[t["id"]] =
|
34
47
|
anchor_struct(c.increment(t).print, t,
|
35
|
-
t["inequality"] ? @
|
48
|
+
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
36
49
|
"formula", t["unnumbered"])
|
37
50
|
end
|
38
51
|
end
|
@@ -51,9 +64,9 @@ module IsoDoc::Function
|
|
51
64
|
end
|
52
65
|
|
53
66
|
def sequential_permission_names2(t, id)
|
54
|
-
sequential_permission_names1(t, id, "permission", @
|
55
|
-
sequential_permission_names1(t, id, "requirement", @
|
56
|
-
sequential_permission_names1(t, id, "recommendation", @
|
67
|
+
sequential_permission_names1(t, id, "permission", @labels["permission"])
|
68
|
+
sequential_permission_names1(t, id, "requirement", @labels["requirement"])
|
69
|
+
sequential_permission_names1(t, id, "recommendation", @labels["recommendation"])
|
57
70
|
end
|
58
71
|
|
59
72
|
def sequential_permission_names1(block, lbl, klass, label)
|
@@ -70,9 +83,9 @@ module IsoDoc::Function
|
|
70
83
|
sequential_table_names(clause)
|
71
84
|
sequential_figure_names(clause)
|
72
85
|
sequential_formula_names(clause)
|
73
|
-
sequential_permission_names(clause, "permission", @
|
74
|
-
sequential_permission_names(clause, "requirement", @
|
75
|
-
sequential_permission_names(clause, "recommendation", @
|
86
|
+
sequential_permission_names(clause, "permission", @labels["permission"])
|
87
|
+
sequential_permission_names(clause, "requirement", @labels["requirement"])
|
88
|
+
sequential_permission_names(clause, "recommendation", @labels["recommendation"])
|
76
89
|
end
|
77
90
|
|
78
91
|
def hierarchical_figure_names(clause, num)
|
@@ -80,15 +93,11 @@ module IsoDoc::Function
|
|
80
93
|
j = 0
|
81
94
|
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
|
82
95
|
each do |t|
|
83
|
-
|
84
|
-
else
|
85
|
-
j = 0
|
86
|
-
c.increment(t)
|
87
|
-
end
|
96
|
+
j = subfigure_increment(j, c, t)
|
88
97
|
label = "#{num}#{hiersep}#{c.print}" +
|
89
98
|
(j.zero? ? "" : "#{hierfigsep}#{j}")
|
90
99
|
next if t["id"].nil? || t["id"].empty?
|
91
|
-
@anchors[t["id"]] = anchor_struct(label, nil, @
|
100
|
+
@anchors[t["id"]] = anchor_struct(label, nil, @labels["figure"], "figure",
|
92
101
|
t["unnumbered"])
|
93
102
|
end
|
94
103
|
end
|
@@ -99,7 +108,7 @@ module IsoDoc::Function
|
|
99
108
|
next if t["id"].nil? || t["id"].empty?
|
100
109
|
@anchors[t["id"]] =
|
101
110
|
anchor_struct("#{num}#{hiersep}#{c.increment(t).print}",
|
102
|
-
nil, @
|
111
|
+
nil, @labels["table"], "table", t["unnumbered"])
|
103
112
|
end
|
104
113
|
end
|
105
114
|
|
@@ -107,11 +116,11 @@ module IsoDoc::Function
|
|
107
116
|
hierarchical_table_names(clause, num)
|
108
117
|
hierarchical_figure_names(clause, num)
|
109
118
|
hierarchical_formula_names(clause, num)
|
110
|
-
hierarchical_permission_names(clause, num, "permission", @
|
119
|
+
hierarchical_permission_names(clause, num, "permission", @labels["permission"])
|
111
120
|
hierarchical_permission_names(clause, num, "requirement",
|
112
|
-
@
|
121
|
+
@labels["requirement"])
|
113
122
|
hierarchical_permission_names(clause, num, "recommendation",
|
114
|
-
@
|
123
|
+
@labels["recommendation"])
|
115
124
|
end
|
116
125
|
|
117
126
|
def hierarchical_formula_names(clause, num)
|
@@ -120,7 +129,7 @@ module IsoDoc::Function
|
|
120
129
|
next if t["id"].nil? || t["id"].empty?
|
121
130
|
@anchors[t["id"]] =
|
122
131
|
anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", nil,
|
123
|
-
t["inequality"] ? @
|
132
|
+
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
124
133
|
"formula", t["unnumbered"])
|
125
134
|
end
|
126
135
|
end
|
@@ -135,13 +144,13 @@ module IsoDoc::Function
|
|
135
144
|
end
|
136
145
|
end
|
137
146
|
|
138
|
-
|
139
|
-
hierarchical_permission_names1(t, id, "permission", @
|
140
|
-
hierarchical_permission_names1(t, id, "requirement", @
|
141
|
-
hierarchical_permission_names1(t, id, "recommendation", @
|
147
|
+
def hierarchical_permission_names2(t, id)
|
148
|
+
hierarchical_permission_names1(t, id, "permission", @labels["permission"])
|
149
|
+
hierarchical_permission_names1(t, id, "requirement", @labels["requirement"])
|
150
|
+
hierarchical_permission_names1(t, id, "recommendation", @labels["recommendation"])
|
142
151
|
end
|
143
152
|
|
144
|
-
|
153
|
+
def hierarchical_permission_names1(block, lbl, klass, label)
|
145
154
|
c = Counter.new
|
146
155
|
block.xpath(ns("./#{klass}")).each do |t|
|
147
156
|
next if t["id"].nil? || t["id"].empty?
|
@@ -1,39 +1,28 @@
|
|
1
|
-
module IsoDoc::
|
2
|
-
module
|
1
|
+
module IsoDoc::XrefGen
|
2
|
+
module Sections
|
3
3
|
def back_anchor_names(docxml)
|
4
4
|
docxml.xpath(ns("//annex")).each_with_index do |c, i|
|
5
5
|
annex_names(c, (65 + i).chr.to_s)
|
6
6
|
end
|
7
7
|
docxml.xpath(
|
8
|
-
ns("//bibliography/clause[
|
9
|
-
"
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
8
|
+
ns("//bibliography/clause[.//references[@normative = 'false']] | "\
|
9
|
+
"//bibliography/references[@normative = 'false']"
|
10
|
+
)).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
|
17
16
|
end
|
18
17
|
|
19
18
|
def initial_anchor_names(d)
|
20
|
-
|
21
|
-
preface_names(d.at(ns("//foreword")))
|
22
|
-
preface_names(d.at(ns("//introduction")))
|
23
|
-
d.xpath(ns("//preface/clause")).each do |c|
|
24
|
-
preface_names(c)
|
25
|
-
end
|
26
|
-
preface_names(d.at(ns("//acknowledgements")))
|
19
|
+
d.xpath(ns("//preface/*")).each { |c| c.element? and preface_names(c) }
|
27
20
|
# potentially overridden in middle_section_asset_names()
|
28
|
-
sequential_asset_names(
|
29
|
-
d.xpath(ns("//preface/abstract | //foreword | //introduction | "\
|
30
|
-
"//preface/clause | //acknowledgements")))
|
21
|
+
sequential_asset_names(d.xpath(ns("//preface/*")))
|
31
22
|
n = section_names(d.at(ns("//clause[title = 'Scope']")), 0, 1)
|
32
23
|
n = section_names(d.at(ns(
|
33
|
-
"//bibliography/clause[
|
34
|
-
"
|
35
|
-
"//bibliography/references[title = 'Normative References' or "\
|
36
|
-
"title = 'Normative references']")), n, 1)
|
24
|
+
"//bibliography/clause[.//references[@normative = 'true']] | "\
|
25
|
+
"//bibliography/references[@normative = 'true']")), n, 1)
|
37
26
|
n = section_names(d.at(ns("//sections/terms | "\
|
38
27
|
"//sections/clause[descendant::terms]")), n, 1)
|
39
28
|
n = section_names(d.at(ns("//sections/definitions")), n, 1)
|
@@ -76,17 +65,14 @@ module IsoDoc::Function
|
|
76
65
|
|
77
66
|
def middle_section_asset_names(d)
|
78
67
|
middle_sections = "//clause[title = 'Scope'] | "\
|
79
|
-
"//references[
|
80
|
-
"
|
81
|
-
"//sections/terms | //preface/abstract | //foreword | "\
|
82
|
-
"//introduction | //preface/clause | //acknowledgements | "\
|
68
|
+
"//references[@normative = 'true'] | "\
|
69
|
+
"//sections/terms | //preface/* | "\
|
83
70
|
"//sections/definitions | //clause[parent::sections]"
|
84
71
|
sequential_asset_names(d.xpath(ns(middle_sections)))
|
85
72
|
end
|
86
73
|
|
87
74
|
def clause_names(docxml, sect_num)
|
88
|
-
|
89
|
-
docxml.xpath(ns(q)).each_with_index do |c, i|
|
75
|
+
docxml.xpath(ns(@klass.middle_clause)).each_with_index do |c, i|
|
90
76
|
section_names(c, (i + sect_num), 1)
|
91
77
|
end
|
92
78
|
end
|
@@ -95,7 +81,7 @@ module IsoDoc::Function
|
|
95
81
|
return num if clause.nil?
|
96
82
|
num = num + 1
|
97
83
|
@anchors[clause["id"]] =
|
98
|
-
{ label: num.to_s, xref: l10n("#{@
|
84
|
+
{ label: num.to_s, xref: l10n("#{@labels["clause"]} #{num}"), level: lvl,
|
99
85
|
type: "clause" }
|
100
86
|
clause.xpath(ns(SUBCLAUSES)).
|
101
87
|
each_with_index do |c, i|
|
@@ -106,7 +92,7 @@ module IsoDoc::Function
|
|
106
92
|
|
107
93
|
def section_names1(clause, num, level)
|
108
94
|
@anchors[clause["id"]] =
|
109
|
-
{ label: num, level: level, xref: l10n("#{@
|
95
|
+
{ label: num, level: level, xref: l10n("#{@labels["clause"]} #{num}"),
|
110
96
|
type: "clause" }
|
111
97
|
clause.xpath(ns(SUBCLAUSES)).
|
112
98
|
each_with_index do |c, i|
|
@@ -115,27 +101,55 @@ module IsoDoc::Function
|
|
115
101
|
end
|
116
102
|
|
117
103
|
def annex_name_lbl(clause, num)
|
118
|
-
obl = l10n("(#{@
|
119
|
-
obl = l10n("(#{@
|
120
|
-
l10n("<b>#{@
|
104
|
+
obl = l10n("(#{@labels["inform_annex"]})")
|
105
|
+
obl = l10n("(#{@labels["norm_annex"]})") if clause["obligation"] == "normative"
|
106
|
+
l10n("<b>#{@labels["annex"]} #{num}</b><br/>#{obl}")
|
107
|
+
end
|
108
|
+
|
109
|
+
def single_annex_special_section(clause)
|
110
|
+
a = clause.xpath(ns("./references | ./terms | ./definitions"))
|
111
|
+
a.size == 1 or return nil
|
112
|
+
clause.xpath(ns("./clause | ./p | ./table | ./ol | ./ul | ./dl | "\
|
113
|
+
"./note | ./admonition | ./figure")).size == 0 or
|
114
|
+
return nil
|
115
|
+
a[0]
|
121
116
|
end
|
122
117
|
|
123
118
|
def annex_names(clause, num)
|
124
119
|
@anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
|
125
120
|
type: "clause",
|
126
|
-
xref: "#{@
|
127
|
-
|
128
|
-
annex_names1(
|
121
|
+
xref: "#{@labels["annex"]} #{num}", level: 1 }
|
122
|
+
if a = single_annex_special_section(clause)
|
123
|
+
annex_names1(a, "#{num}", 1)
|
124
|
+
else
|
125
|
+
clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
|
126
|
+
annex_names1(c, "#{num}.#{i + 1}", 2)
|
127
|
+
end
|
129
128
|
end
|
130
129
|
hierarchical_asset_names(clause, num)
|
131
130
|
end
|
132
131
|
|
133
132
|
def annex_names1(clause, num, level)
|
134
|
-
@anchors[clause["id"]] = { label: num, xref: "#{@
|
133
|
+
@anchors[clause["id"]] = { label: num, xref: "#{@labels["annex"]} #{num}",
|
135
134
|
level: level, type: "clause" }
|
136
135
|
clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
|
137
136
|
annex_names1(c, "#{num}.#{i + 1}", level + 1)
|
138
137
|
end
|
139
138
|
end
|
139
|
+
|
140
|
+
ISO_PUBLISHER_XPATH =
|
141
|
+
"./contributor[xmlns:role/@type = 'publisher']/"\
|
142
|
+
"organization[abbreviation = 'ISO' or xmlns:abbreviation = 'IEC' or "\
|
143
|
+
"xmlns:name = 'International Organization for Standardization' or "\
|
144
|
+
"xmlns:name = 'International Electrotechnical Commission']".freeze
|
145
|
+
|
146
|
+
def reference_names(ref)
|
147
|
+
isopub = ref.at(ns(ISO_PUBLISHER_XPATH))
|
148
|
+
ids = @klass.bibitem_ref_code(ref)
|
149
|
+
identifiers = @klass.render_identifier(ids)
|
150
|
+
date = ref.at(ns("./date[@type = 'published']"))
|
151
|
+
reference = @klass.docid_l10n(identifiers[0] || identifiers[1])
|
152
|
+
@anchors[ref["id"]] = { xref: reference }
|
153
|
+
end
|
140
154
|
end
|
141
155
|
end
|
data/lib/isodoc/xslfo_convert.rb
CHANGED
@@ -13,11 +13,28 @@ module IsoDoc
|
|
13
13
|
"_pdfimages"
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
16
|
+
def initialize(options)
|
17
|
+
@format = :pdf
|
18
|
+
@suffix = "pdf"
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
def pdf_stylesheet(docxml)
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def convert(input_filename, file = nil, debug = false, output_filename = nil)
|
27
|
+
file = File.read(input_filename, encoding: "utf-8") if file.nil?
|
28
|
+
docxml, filename, dir = convert_init(file, input_filename, debug)
|
29
|
+
/\.xml$/.match(input_filename) or
|
30
|
+
input_filename = Tempfile.open([filename, ".xml"], encoding: "utf-8") do |f|
|
31
|
+
f.write file
|
32
|
+
f.path
|
33
|
+
end
|
19
34
|
FileUtils.rm_rf dir
|
20
|
-
::Metanorma::Output::XslfoPdf.new.convert(
|
35
|
+
::Metanorma::Output::XslfoPdf.new.convert(input_filename,
|
36
|
+
output_filename || "#{filename}.#{@suffix}",
|
37
|
+
File.join(@libdir, pdf_stylesheet(docxml)))
|
21
38
|
end
|
22
39
|
|
23
40
|
def xref_parse(node, out)
|
data/spec/assets/i18n.yaml
CHANGED
data/spec/assets/odf.emf
ADDED
Binary file
|
data/spec/assets/odf.svg
ADDED