isodoc 1.1.3.pre.alpha → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/isodoc.gemspec +1 -1
- data/lib/isodoc-yaml/i18n-en.yaml +4 -1
- data/lib/isodoc-yaml/i18n-fr.yaml +4 -1
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +4 -1
- data/lib/isodoc.rb +1 -0
- data/lib/isodoc/base_style/all.css +207 -0
- data/lib/isodoc/base_style/blocks.css +0 -0
- data/lib/isodoc/base_style/coverpage.css +0 -0
- data/lib/isodoc/base_style/defaults.css +0 -0
- data/lib/isodoc/base_style/metanorma_word.css +34 -0
- data/lib/isodoc/base_style/nav.css +0 -0
- data/lib/isodoc/base_style/reset.css +105 -0
- data/lib/isodoc/base_style/typography.css +0 -0
- data/lib/isodoc/common.rb +0 -2
- data/lib/isodoc/convert.rb +49 -44
- data/lib/isodoc/function/blocks.rb +10 -22
- data/lib/isodoc/function/blocks_example_note.rb +14 -15
- data/lib/isodoc/function/cleanup.rb +5 -4
- data/lib/isodoc/function/inline.rb +6 -76
- data/lib/isodoc/function/references.rb +10 -9
- data/lib/isodoc/function/reqt.rb +12 -11
- data/lib/isodoc/function/section.rb +39 -54
- data/lib/isodoc/function/table.rb +1 -6
- data/lib/isodoc/function/terms.rb +13 -6
- data/lib/isodoc/function/to_word_html.rb +1 -0
- data/lib/isodoc/function/utils.rb +4 -3
- data/lib/isodoc/gem_tasks.rb +33 -10
- data/lib/isodoc/html_function/html.rb +0 -1
- data/lib/isodoc/{function/i18n.rb → i18n.rb} +37 -36
- data/lib/isodoc/metadata.rb +4 -3
- data/lib/isodoc/metadata_date.rb +1 -1
- data/lib/isodoc/presentation_function/block.rb +138 -0
- data/lib/isodoc/presentation_function/inline.rb +131 -0
- data/lib/isodoc/presentation_function/section.rb +46 -0
- data/lib/isodoc/presentation_xml_convert.rb +38 -5
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +12 -8
- data/lib/isodoc/word_function/inline.rb +3 -1
- data/lib/isodoc/xref.rb +5 -3
- data/lib/isodoc/xref/xref_sect_gen.rb +3 -3
- data/spec/assets/i18n.yaml +12 -1
- data/spec/isodoc/blocks_spec.rb +1101 -147
- data/spec/isodoc/cleanup_spec.rb +2 -2
- data/spec/isodoc/footnotes_spec.rb +2 -2
- data/spec/isodoc/i18n_spec.rb +679 -110
- data/spec/isodoc/inline_spec.rb +323 -142
- data/spec/isodoc/lists_spec.rb +2 -2
- data/spec/isodoc/postproc_spec.rb +1311 -1333
- data/spec/isodoc/ref_spec.rb +181 -3
- data/spec/isodoc/section_spec.rb +508 -680
- data/spec/isodoc/table_spec.rb +155 -4
- data/spec/isodoc/terms_spec.rb +111 -79
- data/spec/isodoc/xref_spec.rb +1569 -1186
- metadata +19 -8
data/lib/isodoc/function/reqt.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module IsoDoc::Function
|
2
2
|
module Blocks
|
3
3
|
def recommendation_labels(node)
|
4
|
-
[node.at(ns("./label")), node.at(ns("./title")),
|
5
|
-
@xrefs.anchor(node['id'], :label, false)]
|
4
|
+
[node.at(ns("./label")), node.at(ns("./title")), node.at(ns("./name"))]
|
6
5
|
end
|
7
6
|
|
8
|
-
def recommendation_name(node, out,
|
7
|
+
def recommendation_name(node, out, _type)
|
9
8
|
label, title, lbl = recommendation_labels(node)
|
10
9
|
out.p **{ class: "RecommendationTitle" } do |b|
|
11
|
-
|
10
|
+
lbl and lbl.children.each { |n| parse(n, b) }
|
11
|
+
b << l10n(":")
|
12
12
|
if label || title
|
13
13
|
b.br
|
14
14
|
label and label.children.each { |n| parse(n,b) }
|
@@ -21,11 +21,11 @@ module IsoDoc::Function
|
|
21
21
|
def recommendation_attributes1(node)
|
22
22
|
out = []
|
23
23
|
oblig = node["obligation"] and
|
24
|
-
out << l10n("#{@
|
24
|
+
out << l10n("#{@i18n.obligation}: #{oblig}")
|
25
25
|
subj = node&.at(ns("./subject"))&.text and
|
26
|
-
out << l10n("#{@
|
26
|
+
out << l10n("#{@i18n.subject}: #{subj}")
|
27
27
|
node.xpath(ns("./inherit")).each do |i|
|
28
|
-
out << recommendation_attr_parse(i, @
|
28
|
+
out << recommendation_attr_parse(i, @i18n.inherits)
|
29
29
|
end
|
30
30
|
node.xpath(ns("./classification")).each do |c|
|
31
31
|
line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
|
@@ -57,7 +57,8 @@ module IsoDoc::Function
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def reqt_metadata_node(n)
|
60
|
-
%w(label title subject classification tag value
|
60
|
+
%w(label title subject classification tag value
|
61
|
+
inherit name).include? n.name
|
61
62
|
end
|
62
63
|
|
63
64
|
def reqt_attrs(node, klass)
|
@@ -66,7 +67,7 @@ module IsoDoc::Function
|
|
66
67
|
|
67
68
|
def recommendation_parse(node, out)
|
68
69
|
out.div **reqt_attrs(node, "recommend") do |t|
|
69
|
-
recommendation_name(node, t, @
|
70
|
+
recommendation_name(node, t, @i18n.recommendation)
|
70
71
|
recommendation_attributes(node, out)
|
71
72
|
node.children.each do |n|
|
72
73
|
parse(n, t) unless reqt_metadata_node(n)
|
@@ -76,7 +77,7 @@ module IsoDoc::Function
|
|
76
77
|
|
77
78
|
def requirement_parse(node, out)
|
78
79
|
out.div **reqt_attrs(node, "require") do |t|
|
79
|
-
recommendation_name(node, t, @
|
80
|
+
recommendation_name(node, t, @i18n.requirement)
|
80
81
|
recommendation_attributes(node, out)
|
81
82
|
node.children.each do |n|
|
82
83
|
parse(n, t) unless reqt_metadata_node(n)
|
@@ -86,7 +87,7 @@ module IsoDoc::Function
|
|
86
87
|
|
87
88
|
def permission_parse(node, out)
|
88
89
|
out.div **reqt_attrs(node, "permission") do |t|
|
89
|
-
recommendation_name(node, t, @
|
90
|
+
recommendation_name(node, t, @i18n.permission)
|
90
91
|
recommendation_attributes(node, out)
|
91
92
|
node.children.each do |n|
|
92
93
|
parse(n, t) unless reqt_metadata_node(n)
|
@@ -8,36 +8,37 @@ module IsoDoc::Function
|
|
8
8
|
insert_tab(out, 1)
|
9
9
|
end
|
10
10
|
|
11
|
-
def inline_header_title(out, node,
|
11
|
+
def inline_header_title(out, node, title)
|
12
12
|
out.span **{ class: "zzMoveToFollowing" } do |s|
|
13
13
|
s.b do |b|
|
14
|
-
|
15
|
-
|
16
|
-
clausedelimspace(out)
|
17
|
-
end
|
18
|
-
c1&.children&.each { |c2| parse(c2, b) }
|
19
|
-
clausedelimspace(out) if /\S/.match(c1&.text)
|
14
|
+
title&.children&.each { |c2| parse(c2, b) }
|
15
|
+
clausedelimspace(out) if /\S/.match(title&.text)
|
20
16
|
end
|
21
17
|
end
|
22
18
|
end
|
23
19
|
|
24
20
|
# used for subclauses
|
25
|
-
def clause_parse_title(node, div,
|
21
|
+
def clause_parse_title(node, div, title, out, header_class = {})
|
22
|
+
return if title.nil?
|
26
23
|
if node["inline-header"] == "true"
|
27
|
-
inline_header_title(out, node,
|
24
|
+
inline_header_title(out, node, title)
|
28
25
|
else
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
depth = (title && title["depth"]) ? title["depth"] :
|
27
|
+
node.ancestors("clause, annex, terms, references, definitions, "\
|
28
|
+
"acknowledgements, introduction, foreword").size + 1
|
29
|
+
div.send "h#{depth}", **attr_code(header_class) do |h|
|
30
|
+
title&.children&.each { |c2| parse(c2, h) }
|
34
31
|
end
|
35
32
|
end
|
36
33
|
end
|
37
34
|
|
35
|
+
def clause_attrs(node)
|
36
|
+
{ id: node["id"] }
|
37
|
+
end
|
38
|
+
|
38
39
|
# used for subclauses
|
39
40
|
def clause_parse(node, out)
|
40
|
-
out.div **attr_code(
|
41
|
+
out.div **attr_code(clause_attrs(node)) do |div|
|
41
42
|
clause_parse_title(node, div, node.at(ns("./title")), out)
|
42
43
|
node.children.reject { |c1| c1.name == "title" }.each do |c1|
|
43
44
|
parse(c1, div)
|
@@ -45,13 +46,9 @@ module IsoDoc::Function
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
|
-
def clause_name(
|
49
|
+
def clause_name(_num, title, div, header_class)
|
49
50
|
header_class = {} if header_class.nil?
|
50
51
|
div.h1 **attr_code(header_class) do |h1|
|
51
|
-
if num && !@suppressheadingnumbers
|
52
|
-
h1 << "#{num}#{clausedelim}"
|
53
|
-
clausedelimspace(h1)
|
54
|
-
end
|
55
52
|
title.is_a?(String) ? h1 << title :
|
56
53
|
title&.children&.each { |c2| parse(c2, h1) }
|
57
54
|
end
|
@@ -60,9 +57,8 @@ module IsoDoc::Function
|
|
60
57
|
|
61
58
|
def clause(isoxml, out)
|
62
59
|
isoxml.xpath(ns(middle_clause)).each do |c|
|
63
|
-
out.div **attr_code(
|
64
|
-
clause_name(
|
65
|
-
c&.at(ns("./title")), s, nil)
|
60
|
+
out.div **attr_code(clause_attrs(c)) do |s|
|
61
|
+
clause_name(nil, c&.at(ns("./title")), s, nil)
|
66
62
|
c.elements.reject { |c1| c1.name == "title" }.each do |c1|
|
67
63
|
parse(c1, s)
|
68
64
|
end
|
@@ -71,19 +67,20 @@ module IsoDoc::Function
|
|
71
67
|
end
|
72
68
|
|
73
69
|
def annex_name(annex, name, div)
|
70
|
+
return if name.nil?
|
74
71
|
div.h1 **{ class: "Annex" } do |t|
|
75
|
-
|
76
|
-
t.b do |b|
|
77
|
-
name&.children&.each { |c2| parse(c2, b) }
|
78
|
-
end
|
72
|
+
name.children.each { |c2| parse(c2, t) }
|
79
73
|
end
|
80
74
|
end
|
81
75
|
|
76
|
+
def annex_attrs(node)
|
77
|
+
{ id: node["id"], class: "Section3" }
|
78
|
+
end
|
79
|
+
|
82
80
|
def annex(isoxml, out)
|
83
81
|
isoxml.xpath(ns("//annex")).each do |c|
|
84
82
|
page_break(out)
|
85
|
-
out.div **attr_code(
|
86
|
-
annex_name(c, nil, s) unless c.at(ns("./title"))
|
83
|
+
out.div **attr_code(annex_attrs(c)) do |s|
|
87
84
|
c.elements.each do |c1|
|
88
85
|
if c1.name == "title" then annex_name(c, c1, s)
|
89
86
|
else
|
@@ -95,10 +92,10 @@ module IsoDoc::Function
|
|
95
92
|
end
|
96
93
|
|
97
94
|
def scope(isoxml, out, num)
|
98
|
-
f = isoxml.at(ns("//clause[
|
95
|
+
f = isoxml.at(ns("//clause[@type = 'scope']")) or return num
|
99
96
|
out.div **attr_code(id: f["id"]) do |div|
|
100
97
|
num = num + 1
|
101
|
-
clause_name(num,
|
98
|
+
clause_name(num, f&.at(ns("./title")), div, nil)
|
102
99
|
f.elements.each do |e|
|
103
100
|
parse(e, div) unless e.name == "title"
|
104
101
|
end
|
@@ -109,26 +106,11 @@ module IsoDoc::Function
|
|
109
106
|
TERM_CLAUSE = "//sections/terms | "\
|
110
107
|
"//sections/clause[descendant::terms]".freeze
|
111
108
|
|
112
|
-
def term_def_title(title)
|
113
|
-
case title&.text
|
114
|
-
when "Terms, definitions, symbols and abbreviated terms"
|
115
|
-
@labels["termsdefsymbolsabbrev"]
|
116
|
-
when "Terms, definitions and symbols"
|
117
|
-
@labels["termsdefsymbols"]
|
118
|
-
when "Terms, definitions and abbreviated terms"
|
119
|
-
@labels["termsdefabbrev"]
|
120
|
-
when "Terms and definitions"
|
121
|
-
@labels["termsdef"]
|
122
|
-
else
|
123
|
-
title
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
109
|
def terms_defs(isoxml, out, num)
|
128
110
|
f = isoxml.at(ns(TERM_CLAUSE)) or return num
|
129
111
|
out.div **attr_code(id: f["id"]) do |div|
|
130
112
|
num = num + 1
|
131
|
-
clause_name(num,
|
113
|
+
clause_name(num, f&.at(ns("./title")), div, nil)
|
132
114
|
f.elements.each do |e|
|
133
115
|
parse(e, div) unless %w{title source}.include? e.name
|
134
116
|
end
|
@@ -145,7 +127,7 @@ module IsoDoc::Function
|
|
145
127
|
f = isoxml.at(ns("//sections/definitions")) or return num
|
146
128
|
out.div **attr_code(id: f["id"], class: "Symbols") do |div|
|
147
129
|
num = num + 1
|
148
|
-
clause_name(num, f&.at(ns("./title")) || @
|
130
|
+
clause_name(num, f&.at(ns("./title")) || @i18n.symbols, div, nil)
|
149
131
|
f.elements.each do |e|
|
150
132
|
parse(e, div) unless e.name == "title"
|
151
133
|
end
|
@@ -156,7 +138,7 @@ module IsoDoc::Function
|
|
156
138
|
# subclause
|
157
139
|
def symbols_parse(isoxml, out)
|
158
140
|
isoxml.at(ns("./title")) or
|
159
|
-
isoxml.children.first.previous = "<title>#{@
|
141
|
+
isoxml.children.first.previous = "<title>#{@i18n.symbols}</title>"
|
160
142
|
clause_parse(isoxml, out)
|
161
143
|
end
|
162
144
|
|
@@ -165,7 +147,7 @@ module IsoDoc::Function
|
|
165
147
|
title_attr = { class: "IntroTitle" }
|
166
148
|
page_break(out)
|
167
149
|
out.div **{ class: "Section3", id: f["id"] } do |div|
|
168
|
-
clause_name(nil,
|
150
|
+
clause_name(nil, f.at(ns("./title")), div, { class: "IntroTitle" })
|
169
151
|
f.elements.each do |e|
|
170
152
|
parse(e, div) unless e.name == "title"
|
171
153
|
end
|
@@ -176,7 +158,9 @@ module IsoDoc::Function
|
|
176
158
|
f = isoxml.at(ns("//foreword")) || return
|
177
159
|
page_break(out)
|
178
160
|
out.div **attr_code(id: f["id"]) do |s|
|
179
|
-
|
161
|
+
clause_name(nil, f.at(ns("./title")) || @i18n.foreword, s,
|
162
|
+
{ class: "ForewordTitle" })
|
163
|
+
#s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @i18n.foreword }
|
180
164
|
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
181
165
|
end
|
182
166
|
end
|
@@ -197,15 +181,16 @@ module IsoDoc::Function
|
|
197
181
|
f = isoxml.at(ns("//preface/abstract")) || return
|
198
182
|
page_break(out)
|
199
183
|
out.div **attr_code(id: f["id"]) do |s|
|
200
|
-
|
184
|
+
clause_name(nil, f.at(ns("./title")), s, { class: "AbstractTitle" })
|
185
|
+
#s.h1(**{ class: "AbstractTitle" }) { |h1| h1 << @i18n.abstract }
|
201
186
|
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
202
187
|
end
|
203
188
|
end
|
204
189
|
|
205
190
|
def preface(isoxml, out)
|
206
191
|
title_attr = { class: "IntroTitle" }
|
207
|
-
isoxml.xpath(ns("//preface/clause | //preface/
|
208
|
-
"//preface/
|
192
|
+
isoxml.xpath(ns("//preface/clause | //preface/references | "\
|
193
|
+
"//preface/definitions | //preface/terms")).each do |f|
|
209
194
|
page_break(out)
|
210
195
|
out.div **{ class: "Section3", id: f["id"] } do |div|
|
211
196
|
clause_name(nil, f&.at(ns("./title")), div, title_attr)
|
@@ -2,13 +2,8 @@ module IsoDoc::Function
|
|
2
2
|
module Table
|
3
3
|
|
4
4
|
def table_title_parse(node, out)
|
5
|
-
name = node.at(ns("./name"))
|
6
|
-
lbl = @xrefs.anchor(node['id'], :label, false)
|
7
|
-
lbl = nil if labelled_ancestor(node)
|
8
|
-
return if name.nil? && lbl.nil?
|
5
|
+
name = node.at(ns("./name")) or return
|
9
6
|
out.p **{ class: "TableTitle", style: "text-align:center;" } do |p|
|
10
|
-
lbl.nil? or p << l10n("#{@table_lbl} #{lbl}")
|
11
|
-
name and !lbl.nil? and p << l10n(" — ")
|
12
7
|
name and name.children.each { |n| parse(n, p) }
|
13
8
|
end
|
14
9
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module IsoDoc::Function
|
2
2
|
module Terms
|
3
|
-
|
4
3
|
def definition_parse(node, out)
|
5
4
|
node.children.each { |n| parse(n, out) }
|
6
5
|
end
|
@@ -13,7 +12,7 @@ module IsoDoc::Function
|
|
13
12
|
|
14
13
|
def deprecated_term_parse(node, out)
|
15
14
|
out.p **{ class: "DeprecatedTerms", style:"text-align:left;" } do |p|
|
16
|
-
p << l10n("#{@
|
15
|
+
p << l10n("#{@i18n.deprecated}: ")
|
17
16
|
node.children.each { |c| parse(c, p) }
|
18
17
|
end
|
19
18
|
end
|
@@ -39,12 +38,19 @@ module IsoDoc::Function
|
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
41
|
+
def termnote_delim
|
42
|
+
l10n(": ")
|
43
|
+
end
|
44
|
+
|
42
45
|
def termnote_parse(node, out)
|
46
|
+
name = node&.at(ns("./name"))&.remove
|
43
47
|
out.div **note_attrs(node) do |div|
|
44
|
-
first = node.first_element_child
|
45
48
|
div.p do |p|
|
46
|
-
|
47
|
-
|
49
|
+
if name
|
50
|
+
name.children.each { |n| parse(n, p) }
|
51
|
+
p << termnote_delim
|
52
|
+
end
|
53
|
+
para_then_remainder(node.first_element_child, node, p, div)
|
48
54
|
end
|
49
55
|
end
|
50
56
|
end
|
@@ -58,8 +64,9 @@ module IsoDoc::Function
|
|
58
64
|
end
|
59
65
|
|
60
66
|
def termdef_parse(node, out)
|
67
|
+
name = node&.at(ns("./name"))&.remove
|
61
68
|
out.p **{ class: "TermNum", id: node["id"] } do |p|
|
62
|
-
p
|
69
|
+
name&.children&.each { |n| parse(n, p) }
|
63
70
|
end
|
64
71
|
set_termdomain("")
|
65
72
|
node.children.each { |n| parse(n, out) }
|
@@ -220,6 +220,7 @@ module IsoDoc::Function
|
|
220
220
|
when "feedback-statement" then feedback_parse(node, out)
|
221
221
|
when "passthrough" then passthrough_parse(node, out)
|
222
222
|
when "variant" then variant_parse(node, out)
|
223
|
+
when "tab" then clausedelimspace(out) # in Presentation XML only
|
223
224
|
else
|
224
225
|
error_parse(node, out)
|
225
226
|
end
|
@@ -11,7 +11,8 @@ module IsoDoc::Function
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def insert_tab(out, n)
|
14
|
-
|
14
|
+
tab = %w(Hans Hant).include?(@script) ? " " : " "
|
15
|
+
[1..n].each { out << tab }
|
15
16
|
end
|
16
17
|
|
17
18
|
# add namespaces for Word fragments
|
@@ -99,8 +100,8 @@ module IsoDoc::Function
|
|
99
100
|
return '' if array.nil? || array.empty?
|
100
101
|
if array.length == 1 then array[0]
|
101
102
|
else
|
102
|
-
|
103
|
-
|
103
|
+
@i18n.l10n("#{array[0..-2].join(', ')} "\
|
104
|
+
"#{@i18n.and} #{array.last}",
|
104
105
|
@lang, @script)
|
105
106
|
end
|
106
107
|
end
|
data/lib/isodoc/gem_tasks.rb
CHANGED
@@ -16,8 +16,7 @@ module IsoDoc
|
|
16
16
|
puts(current_task)
|
17
17
|
compile_scss_task(current_task)
|
18
18
|
rescue StandardError => e
|
19
|
-
|
20
|
-
puts("skiping #{current_task}")
|
19
|
+
notify_borken_compilation(e, current_task)
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
@@ -34,20 +33,38 @@ module IsoDoc
|
|
34
33
|
process_css_files(scss_files) do |file_name|
|
35
34
|
uncomment_out_liquid(File.read(file_name, encoding: 'UTF-8'))
|
36
35
|
end
|
37
|
-
|
38
|
-
sh "git add #{css_file}"
|
39
|
-
end
|
40
|
-
puts('Built scss!')
|
36
|
+
git_cache_compiled_files && puts('Built scss!')
|
41
37
|
end
|
42
38
|
|
43
39
|
Rake::Task['build'].enhance [:build_scss] do
|
44
|
-
|
45
|
-
sh "git rm --cached #{css_file}"
|
46
|
-
end
|
40
|
+
git_rm_compiled_files
|
47
41
|
Rake::Task[:clean].invoke
|
48
42
|
end
|
49
43
|
end
|
50
44
|
|
45
|
+
def notify_borken_compilation(error, current_task)
|
46
|
+
puts("Cannot compile #{current_task} because of #{error.message}")
|
47
|
+
puts('continue anyway[y|n]?')
|
48
|
+
answer = STDIN.gets.strip
|
49
|
+
if %w[y yes].include?(answer.strip.downcase)
|
50
|
+
puts("Cannot compile #{current_task} because of #{error.message}")
|
51
|
+
else
|
52
|
+
exit(0)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def git_cache_compiled_files
|
57
|
+
CLEAN.each do |css_file|
|
58
|
+
sh "git add #{css_file}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def git_rm_compiled_files
|
63
|
+
CLEAN.each do |css_file|
|
64
|
+
sh "git rm --cached #{css_file}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
51
68
|
def process_css_files(scss_files)
|
52
69
|
scss_files.each do |file_name|
|
53
70
|
result = yield(file_name)
|
@@ -85,7 +102,13 @@ module IsoDoc
|
|
85
102
|
|
86
103
|
def compile_scss(filename)
|
87
104
|
require 'sassc'
|
88
|
-
|
105
|
+
|
106
|
+
isodoc_path = if Gem.loaded_specs['isodoc']
|
107
|
+
File.join(Gem.loaded_specs['isodoc'].full_gem_path, 'lib', 'isodoc')
|
108
|
+
else
|
109
|
+
File.join('lib', 'isodoc')
|
110
|
+
end
|
111
|
+
[isodoc_path,
|
89
112
|
File.dirname(filename)].each do |name|
|
90
113
|
SassC.load_paths << name
|
91
114
|
end
|
@@ -1,29 +1,49 @@
|
|
1
1
|
require "yaml"
|
2
2
|
|
3
3
|
# TODO: Cleanup and generalize
|
4
|
-
module IsoDoc
|
5
|
-
|
6
|
-
def load_yaml(lang, script)
|
7
|
-
|
8
|
-
|
4
|
+
module IsoDoc
|
5
|
+
class I18n
|
6
|
+
def load_yaml(lang, script, i18nyaml = nil)
|
7
|
+
ret = load_yaml1(lang, script)
|
8
|
+
return ret.merge(YAML.load_file(i18nyaml)) if i18nyaml
|
9
|
+
ret
|
10
|
+
end
|
11
|
+
|
12
|
+
def load_yaml1(lang, script)
|
13
|
+
if lang == "en"
|
9
14
|
YAML.load_file(File.join(File.dirname(__FILE__),
|
10
|
-
"
|
15
|
+
"../isodoc-yaml/i18n-en.yaml"))
|
11
16
|
elsif lang == "fr"
|
12
17
|
YAML.load_file(File.join(File.dirname(__FILE__),
|
13
|
-
"
|
18
|
+
"../isodoc-yaml/i18n-fr.yaml"))
|
14
19
|
elsif lang == "zh" && script == "Hans"
|
15
20
|
YAML.load_file(File.join(File.dirname(__FILE__),
|
16
|
-
"
|
21
|
+
"../isodoc-yaml/i18n-zh-Hans.yaml"))
|
17
22
|
else
|
18
23
|
YAML.load_file(File.join(File.dirname(__FILE__),
|
19
|
-
"
|
24
|
+
"../isodoc-yaml/i18n-en.yaml"))
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
|
-
def
|
28
|
+
def get
|
29
|
+
@labels
|
30
|
+
end
|
31
|
+
|
32
|
+
def set(x, y)
|
33
|
+
@labels[x] = y
|
34
|
+
end
|
35
|
+
|
36
|
+
def initialize(lang, script, i18nyaml = nil)
|
24
37
|
@lang = lang
|
25
38
|
@script = script
|
26
|
-
y = load_yaml(lang, script)
|
39
|
+
y = load_yaml(lang, script, i18nyaml)
|
40
|
+
@labels = y
|
41
|
+
@labels["language"] = @lang
|
42
|
+
@labels["script"] = @script
|
43
|
+
@labels.each do |k, v|
|
44
|
+
self.class.send(:define_method, k.downcase) { v }
|
45
|
+
end
|
46
|
+
=begin
|
27
47
|
@term_def_boilerplate = y["term_def_boilerplate"]
|
28
48
|
@scope_lbl = y["scope"]
|
29
49
|
@symbols_lbl = y["symbols"]
|
@@ -71,30 +91,11 @@ module IsoDoc::Function
|
|
71
91
|
@requirement_lbl = y["requirement"]
|
72
92
|
@locality = y["locality"]
|
73
93
|
@admonition = y["admonition"]
|
74
|
-
|
75
|
-
@labels["language"] = @lang
|
76
|
-
@labels["script"] = @script
|
94
|
+
=end
|
77
95
|
end
|
78
96
|
|
79
|
-
|
80
|
-
|
81
|
-
ret = "#{delim} 第#{from.text}" if from
|
82
|
-
ret += "–#{to}" if to
|
83
|
-
loc = (@locality[type] || type.sub(/^locality:/, "").capitalize )
|
84
|
-
ret += " #{loc}"
|
85
|
-
ret
|
86
|
-
end
|
87
|
-
|
88
|
-
# TODO: move to localization file
|
89
|
-
def eref_localities1(target, type, from, to, delim, lang = "en")
|
90
|
-
return "" if type == "anchor"
|
91
|
-
return l10n(eref_localities1_zh(target, type, from, to, delim)) if lang == "zh"
|
92
|
-
ret = delim
|
93
|
-
loc = @locality[type] || type.sub(/^locality:/, "").capitalize
|
94
|
-
ret += " #{loc}"
|
95
|
-
ret += " #{from.text}" if from
|
96
|
-
ret += "–#{to.text}" if to
|
97
|
-
l10n(ret)
|
97
|
+
def self.l10n(x, lang = @lang, script = @script)
|
98
|
+
l10n(x, lang, script)
|
98
99
|
end
|
99
100
|
|
100
101
|
# TODO: move to localization file
|
@@ -106,8 +107,8 @@ module IsoDoc::Function
|
|
106
107
|
xml.traverse do |n|
|
107
108
|
next unless n.text?
|
108
109
|
n.replace(n.text.gsub(/ /, "").gsub(/:/, ":").gsub(/,/, "、").
|
109
|
-
|
110
|
-
|
110
|
+
gsub(/\(/, "(").gsub(/\)/, ")").
|
111
|
+
gsub(/\[/, "【").gsub(/\]/, "】"))
|
111
112
|
end
|
112
113
|
xml.to_xml.gsub(/<b>/, "").gsub("</b>", "").gsub(/<\?[^>]+>/, "")
|
113
114
|
else
|
@@ -115,7 +116,7 @@ module IsoDoc::Function
|
|
115
116
|
end
|
116
117
|
end
|
117
118
|
|
118
|
-
module_function :l10n
|
119
|
+
#module_function :l10n
|
119
120
|
|
120
121
|
end
|
121
122
|
end
|