isodoc 2.1.5 → 2.2.2.2
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 +5 -5
- data/lib/isodoc/class_utils.rb +1 -4
- data/lib/isodoc/convert.rb +56 -42
- data/lib/isodoc/function/inline.rb +12 -7
- data/lib/isodoc/function/references.rb +1 -1
- data/lib/isodoc/function/reqt.rb +17 -88
- data/lib/isodoc/function/section_titles.rb +3 -3
- data/lib/isodoc/function/table.rb +1 -1
- data/lib/isodoc/function/to_word_html.rb +7 -6
- data/lib/isodoc/function/utils.rb +4 -0
- data/lib/isodoc/init.rb +20 -0
- data/lib/isodoc/presentation_function/block.rb +23 -6
- data/lib/isodoc/presentation_function/image.rb +68 -19
- data/lib/isodoc/presentation_function/refs.rb +102 -0
- data/lib/isodoc/presentation_function/section.rb +1 -80
- data/lib/isodoc/presentation_function/terms.rb +9 -13
- data/lib/isodoc/presentation_xml_convert.rb +1 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +1 -1
- data/lib/isodoc/xref/xref_counter.rb +12 -0
- data/lib/isodoc/xref/xref_gen.rb +17 -5
- data/lib/isodoc/xref/xref_gen_seq.rb +106 -81
- data/lib/isodoc/xref.rb +6 -0
- data/lib/isodoc-yaml/i18n-ar.yaml +0 -2
- data/lib/isodoc-yaml/i18n-de.yaml +0 -2
- data/lib/isodoc-yaml/i18n-en.yaml +9 -2
- data/lib/isodoc-yaml/i18n-es.yaml +0 -2
- data/lib/isodoc-yaml/i18n-fr.yaml +0 -2
- data/lib/isodoc-yaml/i18n-ru.yaml +0 -2
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +0 -2
- data/lib/relaton/render/general.rb +1 -18
- metadata +34 -26
- data/lib/isodoc/base_style/all.css +0 -227
- 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 +0 -47
- data/lib/isodoc/base_style/nav.css +0 -0
- data/lib/isodoc/base_style/reset.css +0 -125
- data/lib/isodoc/base_style/typography.css +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35faf26226ce9567b1cbe542ce0e2e5e9addaa4db63d88460a978b91e1aa7b1f
|
4
|
+
data.tar.gz: 3c6c08ee8a7b87edb3f4d17c5e1dd58e7b23081e3cce392a85404f8eafd3c280
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c1f5785099717614434d6099c2b6f843d24cb5e7de0cd2cfbfb4da5a42039bd790d90b91f270befd4fa6002f79509007024e2baf52803a5720d7f0d75433294
|
7
|
+
data.tar.gz: 05203b0d0f5092a7e0ab26659d8b8f6a7b8ed9d1a2d3a6ffa0d2cd06b94748d432c264978c32bbc0af391817af0046313782dfff74f840c8b14cfcc28992b466
|
data/isodoc.gemspec
CHANGED
@@ -34,15 +34,15 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency "asciimath"
|
35
35
|
spec.add_dependency "html2doc", "~> 1.4.1"
|
36
36
|
spec.add_dependency "htmlentities", "~> 4.3.4"
|
37
|
-
spec.add_dependency "isodoc-i18n", "~> 1.0.
|
37
|
+
spec.add_dependency "isodoc-i18n", "~> 1.0.6"
|
38
38
|
spec.add_dependency "liquid", "~> 4"
|
39
39
|
# spec.add_dependency "metanorma", ">= 1.2.0"
|
40
40
|
spec.add_dependency "emf2svg"
|
41
41
|
spec.add_dependency "mathml2asciimath"
|
42
|
-
spec.add_dependency "metanorma-utils"
|
43
|
-
|
42
|
+
spec.add_dependency "metanorma-utils", "~> 1.3.2"
|
43
|
+
spec.add_dependency "mn-requirements", "~> 0.1.2"
|
44
44
|
spec.add_dependency "relaton-cli"
|
45
|
-
spec.add_dependency "relaton-render", "
|
45
|
+
spec.add_dependency "relaton-render", "~> 0.4.0"
|
46
46
|
spec.add_dependency "roman-numerals"
|
47
47
|
spec.add_dependency "thread_safe"
|
48
48
|
spec.add_dependency "twitter_cldr", ">= 6.6.0"
|
@@ -52,7 +52,7 @@ Gem::Specification.new do |spec|
|
|
52
52
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
53
53
|
spec.add_development_dependency "guard", "~> 2.14"
|
54
54
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
55
|
-
spec.add_development_dependency "metanorma-iso"
|
55
|
+
spec.add_development_dependency "metanorma-iso", ">= 2.1.7"
|
56
56
|
spec.add_development_dependency "rake", "~> 13.0"
|
57
57
|
spec.add_development_dependency "rexml"
|
58
58
|
spec.add_development_dependency "rspec", "~> 3.6"
|
data/lib/isodoc/class_utils.rb
CHANGED
@@ -13,10 +13,7 @@ module IsoDoc
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def ns(xpath)
|
16
|
-
xpath
|
17
|
-
.gsub(%r{::([a-zA-z])}, "::xmlns:\\1")
|
18
|
-
.gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]* ?=)}, "[xmlns:\\1")
|
19
|
-
.gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]*[/\[\]])}, "[xmlns:\\1")
|
16
|
+
Metanorma::Utils::ns(xpath)
|
20
17
|
end
|
21
18
|
|
22
19
|
def liquid(doc)
|
data/lib/isodoc/convert.rb
CHANGED
@@ -5,11 +5,13 @@ require "fileutils"
|
|
5
5
|
require "tempfile"
|
6
6
|
require_relative "i18n"
|
7
7
|
require_relative "css"
|
8
|
+
require_relative "init"
|
8
9
|
require "securerandom"
|
10
|
+
require "mn-requirements"
|
9
11
|
|
10
12
|
module IsoDoc
|
11
13
|
class Convert < ::IsoDoc::Common
|
12
|
-
attr_accessor :options, :i18n, :meta, :xrefs
|
14
|
+
attr_accessor :options, :i18n, :meta, :xrefs, :reqt_models, :requirements_processor
|
13
15
|
|
14
16
|
# htmlstylesheet: Generic stylesheet for HTML
|
15
17
|
# htmlstylesheet_override: Override stylesheet for HTML
|
@@ -45,22 +47,28 @@ module IsoDoc
|
|
45
47
|
# tocrecommendations: add ToC for rcommendations
|
46
48
|
# fonts: fontist fonts to install
|
47
49
|
# fontlicenseagreement: fontist font license agreement
|
48
|
-
def initialize(options)
|
49
|
-
@
|
50
|
+
def initialize(options) # rubocop:disable Lint/MissingSuper
|
51
|
+
@options = options_preprocess(options)
|
52
|
+
init_stylesheets(@options)
|
53
|
+
init_covers(@options)
|
54
|
+
init_toc(@options)
|
55
|
+
init_fonts(@options)
|
56
|
+
init_processing
|
57
|
+
init_locations(@options)
|
58
|
+
init_i18n(@options)
|
59
|
+
init_rendering(@options)
|
60
|
+
end
|
61
|
+
|
62
|
+
def options_preprocess(options)
|
50
63
|
options.merge!(default_fonts(options)) do |_, old, new|
|
51
64
|
old || new
|
52
65
|
end.merge!(default_file_locations(options)) do |_, old, new|
|
53
66
|
old || new
|
54
67
|
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
init_stylesheets(options)
|
60
|
-
init_covers(options)
|
61
|
-
init_toc(options)
|
62
|
-
init_fonts(options)
|
63
|
-
@i18nyaml = options[:i18nyaml]
|
68
|
+
options
|
69
|
+
end
|
70
|
+
|
71
|
+
def init_rendering(options)
|
64
72
|
@ulstyle = options[:ulstyle]
|
65
73
|
@olstyle = options[:olstyle]
|
66
74
|
@datauriimage = options[:datauriimage]
|
@@ -69,6 +77,26 @@ module IsoDoc
|
|
69
77
|
@sectionsplit = options[:sectionsplit] == "true"
|
70
78
|
@suppressasciimathdup = options[:suppressasciimathdup] == "true"
|
71
79
|
@bare = options[:bare]
|
80
|
+
@aligncrosselements = options[:aligncrosselements]
|
81
|
+
end
|
82
|
+
|
83
|
+
def init_i18n(options)
|
84
|
+
@i18nyaml = options[:i18nyaml]
|
85
|
+
@lang = options[:language] || "en"
|
86
|
+
@script = options[:script] || "Latn"
|
87
|
+
end
|
88
|
+
|
89
|
+
def init_locations(options)
|
90
|
+
@libdir ||= File.dirname(__FILE__)
|
91
|
+
@baseassetpath = options[:baseassetpath]
|
92
|
+
@tmpimagedir_suffix = tmpimagedir_suffix
|
93
|
+
@tmpfilesdir_suffix = tmpfilesdir_suffix
|
94
|
+
@sourcefilename = options[:sourcefilename]
|
95
|
+
@files_to_delete = []
|
96
|
+
@tempfile_cache = []
|
97
|
+
end
|
98
|
+
|
99
|
+
def init_processing
|
72
100
|
@termdomain = ""
|
73
101
|
@termexample = false
|
74
102
|
@note = false
|
@@ -83,16 +111,10 @@ module IsoDoc
|
|
83
111
|
@c = HTMLEntities.new
|
84
112
|
@openmathdelim = "`"
|
85
113
|
@closemathdelim = "`"
|
86
|
-
@lang = options[:language] || "en"
|
87
|
-
@script = options[:script] || "Latn"
|
88
114
|
@maxwidth = 1200
|
89
115
|
@maxheight = 800
|
90
116
|
@bookmarks_allocated = { "X" => true }
|
91
117
|
@fn_bookmarks = {}
|
92
|
-
@baseassetpath = options[:baseassetpath]
|
93
|
-
@aligncrosselements = options[:aligncrosselements]
|
94
|
-
@tmpimagedir_suffix = tmpimagedir_suffix
|
95
|
-
@tmpfilesdir_suffix = tmpfilesdir_suffix
|
96
118
|
end
|
97
119
|
|
98
120
|
def init_fonts(options)
|
@@ -150,6 +172,10 @@ module IsoDoc
|
|
150
172
|
nil
|
151
173
|
end
|
152
174
|
|
175
|
+
def requirements_processor
|
176
|
+
Metanorma::Requirements
|
177
|
+
end
|
178
|
+
|
153
179
|
def convert1(docxml, filename, dir)
|
154
180
|
@xrefs.parse docxml
|
155
181
|
bibitem_lookup(docxml)
|
@@ -171,35 +197,25 @@ module IsoDoc
|
|
171
197
|
end
|
172
198
|
end
|
173
199
|
|
174
|
-
def metadata_init(lang, script, i18n)
|
175
|
-
@meta = Metadata.new(lang, script, i18n)
|
176
|
-
end
|
177
|
-
|
178
|
-
def xref_init(lang, script, _klass, i18n, options)
|
179
|
-
html = HtmlConvert.new(language: @lang, script: @script)
|
180
|
-
@xrefs = Xref.new(lang, script, html, i18n, options)
|
181
|
-
end
|
182
|
-
|
183
|
-
def i18n_init(lang, script, i18nyaml = nil)
|
184
|
-
@i18n = I18n.new(lang, script, i18nyaml: i18nyaml || @i18nyaml)
|
185
|
-
end
|
186
|
-
|
187
|
-
def l10n(expr, lang = @lang, script = @script)
|
188
|
-
@i18n.l10n(expr, lang, script)
|
189
|
-
end
|
190
|
-
|
191
200
|
def convert_init(file, input_filename, debug)
|
192
201
|
docxml = Nokogiri::XML(file) { |config| config.huge }
|
193
202
|
filename, dir = init_file(input_filename, debug)
|
194
203
|
docxml.root.default_namespace = ""
|
195
|
-
|
196
|
-
script = docxml&.at(ns("//bibdata/script"))&.text and @script = script
|
197
|
-
i18n_init(@lang, @script)
|
204
|
+
convert_i18n_init(docxml)
|
198
205
|
metadata_init(@lang, @script, @i18n)
|
199
206
|
xref_init(@lang, @script, self, @i18n, {})
|
200
207
|
[docxml, filename, dir]
|
201
208
|
end
|
202
209
|
|
210
|
+
def convert_i18n_init(docxml)
|
211
|
+
lang = docxml&.at(ns("//bibdata/language"))&.text and @lang = lang
|
212
|
+
script = docxml&.at(ns("//bibdata/script"))&.text and @script = script
|
213
|
+
i18n_init(@lang, @script)
|
214
|
+
@reqt_models = requirements_processor
|
215
|
+
.new({ default: "default", lang: lang, script: script,
|
216
|
+
labels: @i18n.get })
|
217
|
+
end
|
218
|
+
|
203
219
|
def convert(input_filename, file = nil, debug = false,
|
204
220
|
output_filename = nil)
|
205
221
|
file = File.read(input_filename, encoding: "utf-8") if file.nil?
|
@@ -219,10 +235,8 @@ module IsoDoc
|
|
219
235
|
end
|
220
236
|
|
221
237
|
def target_pdf(node)
|
222
|
-
if /#/.match?(node["target"])
|
223
|
-
|
224
|
-
else
|
225
|
-
"##{node['target']}"
|
238
|
+
if /#/.match?(node["target"]) then node["target"].sub(/#/, ".pdf#")
|
239
|
+
else "##{node['target']}"
|
226
240
|
end
|
227
241
|
end
|
228
242
|
end
|
@@ -17,7 +17,13 @@ module IsoDoc
|
|
17
17
|
def location_parse(node, out); end
|
18
18
|
|
19
19
|
def span_parse(node, out)
|
20
|
-
node
|
20
|
+
if node["style"]
|
21
|
+
out.span **{ style: node["style"] } do |s|
|
22
|
+
node.children.each { |n| parse(n, s) }
|
23
|
+
end
|
24
|
+
else
|
25
|
+
node.children.each { |n| parse(n, out) }
|
26
|
+
end
|
21
27
|
end
|
22
28
|
|
23
29
|
def callout_parse(node, out)
|
@@ -57,12 +63,11 @@ module IsoDoc
|
|
57
63
|
def eref_url(bibitemid)
|
58
64
|
return nil if @bibitems.nil? || @bibitems[bibitemid].nil?
|
59
65
|
|
60
|
-
|
61
|
-
url.text
|
62
|
-
|
63
|
-
@bibitems[bibitemid]
|
64
|
-
|
65
|
-
end
|
66
|
+
url = @bibitems[bibitemid].at(ns("./uri[@type = 'citation']")) and
|
67
|
+
return url.text
|
68
|
+
@bibitems[bibitemid]["hidden"] == "true" and
|
69
|
+
return @bibitems[bibitemid].at(ns("./uri"))&.text
|
70
|
+
"##{bibitemid}"
|
66
71
|
end
|
67
72
|
|
68
73
|
def eref_parse(node, out)
|
@@ -120,7 +120,7 @@ module IsoDoc
|
|
120
120
|
def omit_docid_prefix(prefix)
|
121
121
|
return true if prefix.nil? || prefix.empty?
|
122
122
|
|
123
|
-
%w(ISO IEC IEV ITU W3C csd metanorma repository metanorma-ordinal)
|
123
|
+
%w(ISO IEC IEV ITU W3C BIPM csd metanorma repository metanorma-ordinal)
|
124
124
|
.include? prefix
|
125
125
|
end
|
126
126
|
|
data/lib/isodoc/function/reqt.rb
CHANGED
@@ -1,121 +1,50 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module Function
|
3
3
|
module Blocks
|
4
|
-
def
|
5
|
-
|
6
|
-
end
|
7
|
-
|
8
|
-
def recommendation_name(node, out, _type)
|
9
|
-
label, title, lbl = recommendation_labels(node)
|
10
|
-
out.p **{ class: "RecommendationTitle" } do |b|
|
11
|
-
lbl&.children&.each { |n| parse(n, b) }
|
12
|
-
b << l10n(":")
|
13
|
-
if label || title
|
14
|
-
b.br
|
15
|
-
label&.children&.each { |n| parse(n, b) }
|
16
|
-
b << "#{clausedelim} " if label && title
|
17
|
-
title&.children&.each { |n| parse(n, b) }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def recommendation_attributes1(node)
|
23
|
-
out = []
|
24
|
-
oblig = node["obligation"] and
|
25
|
-
out << l10n("#{@i18n.obligation}: #{oblig}")
|
26
|
-
node.xpath(ns("./subject")).each do |subj|
|
27
|
-
out << l10n("#{@i18n.subject}: #{subj.text}")
|
28
|
-
end
|
29
|
-
node.xpath(ns("./inherit")).each do |i|
|
30
|
-
out << recommendation_attr_parse(i, @i18n.inherits)
|
31
|
-
end
|
32
|
-
node.xpath(ns("./classification")).each do |c|
|
33
|
-
line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
|
34
|
-
end
|
35
|
-
out
|
36
|
-
end
|
37
|
-
|
38
|
-
def recommendation_attr_parse(node, label)
|
39
|
-
noko do |xml|
|
40
|
-
xml << "#{label}: "
|
41
|
-
node.children.each { |n| parse(n, xml) }
|
42
|
-
end.join
|
43
|
-
end
|
4
|
+
def recommendation_name(name, out)
|
5
|
+
return if name.nil?
|
44
6
|
|
45
|
-
|
46
|
-
|
47
|
-
value = node.at(ns("./#{value}")) or return nil
|
48
|
-
"#{tag.text.capitalize}: #{value.text}"
|
49
|
-
end
|
50
|
-
|
51
|
-
def recommendation_attributes(node, out)
|
52
|
-
ret = recommendation_attributes1(node)
|
53
|
-
return if ret.empty?
|
54
|
-
|
55
|
-
out.p do |p|
|
56
|
-
p.i do |i|
|
57
|
-
i << ret.join("<br/>")
|
58
|
-
end
|
7
|
+
out.p **{ class: "RecommendationTitle" } do |p|
|
8
|
+
name.children.each { |n| parse(n, p) }
|
59
9
|
end
|
60
10
|
end
|
61
11
|
|
62
|
-
def reqt_metadata_node(node)
|
63
|
-
%w(label title subject classification tag value
|
64
|
-
inherit name).include? node.name
|
65
|
-
end
|
66
|
-
|
67
12
|
def reqt_attrs(node, klass)
|
68
13
|
attr_code(class: klass, id: node["id"], style: keep_style(node))
|
69
14
|
end
|
70
15
|
|
71
16
|
def recommendation_parse(node, out)
|
72
17
|
out.div **reqt_attrs(node, "recommend") do |t|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
18
|
+
recommendation_parse1(node, t)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def recommendation_parse1(node, out)
|
23
|
+
recommendation_name(node.at(ns("./name")), out)
|
24
|
+
node.children.each do |n|
|
25
|
+
parse(n, out) unless n.name == "name"
|
78
26
|
end
|
79
27
|
end
|
80
28
|
|
81
29
|
def requirement_parse(node, out)
|
82
30
|
out.div **reqt_attrs(node, "require") do |t|
|
83
|
-
|
84
|
-
recommendation_attributes(node, out)
|
85
|
-
node.children.each do |n|
|
86
|
-
parse(n, t) unless reqt_metadata_node(n)
|
87
|
-
end
|
31
|
+
recommendation_parse1(node, t)
|
88
32
|
end
|
89
33
|
end
|
90
34
|
|
91
35
|
def permission_parse(node, out)
|
92
36
|
out.div **reqt_attrs(node, "permission") do |t|
|
93
|
-
|
94
|
-
recommendation_attributes(node, out)
|
95
|
-
node.children.each do |n|
|
96
|
-
parse(n, t) unless reqt_metadata_node(n)
|
97
|
-
end
|
37
|
+
recommendation_parse1(node, t)
|
98
38
|
end
|
99
39
|
end
|
100
40
|
|
101
|
-
def
|
102
|
-
|
103
|
-
klass == "component" and klass = node["class"]
|
104
|
-
attr_code(class: "requirement-#{klass}",
|
105
|
-
style: keep_style(node))
|
106
|
-
end
|
107
|
-
|
108
|
-
def requirement_component_parse(node, out)
|
109
|
-
return if node["exclude"] == "true"
|
110
|
-
|
111
|
-
out.div **reqt_component_attrs(node) do |div|
|
41
|
+
def div_parse(node, out)
|
42
|
+
out.div **reqt_attrs(node, node["type"]) do |t|
|
112
43
|
node.children.each do |n|
|
113
|
-
parse(n,
|
44
|
+
parse(n, t)
|
114
45
|
end
|
115
46
|
end
|
116
47
|
end
|
117
|
-
|
118
|
-
def requirement_skip_parse(node, out); end
|
119
48
|
end
|
120
49
|
end
|
121
50
|
end
|
@@ -5,15 +5,15 @@ module IsoDoc
|
|
5
5
|
"."
|
6
6
|
end
|
7
7
|
|
8
|
-
def clausedelimspace(out)
|
8
|
+
def clausedelimspace(_node, out)
|
9
9
|
insert_tab(out, 1)
|
10
10
|
end
|
11
11
|
|
12
|
-
def inline_header_title(out,
|
12
|
+
def inline_header_title(out, node, title)
|
13
13
|
out.span **{ class: "zzMoveToFollowing" } do |s|
|
14
14
|
s.b do |b|
|
15
15
|
title&.children&.each { |c2| parse(c2, b) }
|
16
|
-
clausedelimspace(out) if /\S/.match?(title&.text)
|
16
|
+
clausedelimspace(node, out) if /\S/.match?(title&.text)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -43,7 +43,7 @@ module IsoDoc
|
|
43
43
|
width = node["width"] ? "width:#{node['width']};" : nil
|
44
44
|
attr_code(
|
45
45
|
id: node["id"],
|
46
|
-
class: "MsoISOTable",
|
46
|
+
class: node["class"] || "MsoISOTable",
|
47
47
|
style: "border-width:1px;border-spacing:0;"\
|
48
48
|
"#{width}#{keep_style(node)}",
|
49
49
|
title: node["alt"],
|
@@ -204,11 +204,12 @@ module IsoDoc
|
|
204
204
|
when "requirement" then requirement_parse(node, out)
|
205
205
|
when "recommendation" then recommendation_parse(node, out)
|
206
206
|
when "permission" then permission_parse(node, out)
|
207
|
-
when "
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
207
|
+
when "div" then div_parse(node, out)
|
208
|
+
#when "subject", "classification"
|
209
|
+
# requirement_skip_parse(node, out)
|
210
|
+
#when "inherit", "description", "specification", "measurement-target",
|
211
|
+
#"verification", "import", "component"
|
212
|
+
# requirement_component_parse(node, out)
|
212
213
|
when "index" then index_parse(node, out)
|
213
214
|
when "index-xref" then index_xref_parse(node, out)
|
214
215
|
when "termref" then termrefelem_parse(node, out)
|
@@ -218,7 +219,7 @@ module IsoDoc
|
|
218
219
|
when "feedback-statement" then feedback_parse(node, out)
|
219
220
|
when "passthrough" then passthrough_parse(node, out)
|
220
221
|
when "amend" then amend_parse(node, out)
|
221
|
-
when "tab" then clausedelimspace(out) # in Presentation XML only
|
222
|
+
when "tab" then clausedelimspace(node, out) # in Presentation XML only
|
222
223
|
when "svg" then svg_parse(node, out) # in Presentation XML only
|
223
224
|
when "add" then add_parse(node, out)
|
224
225
|
when "del" then del_parse(node, out)
|
@@ -222,6 +222,10 @@ module IsoDoc
|
|
222
222
|
application/x-msmetafile image/x-xbitmap).include? type
|
223
223
|
end
|
224
224
|
|
225
|
+
def eps?(type)
|
226
|
+
%w(application/postscript image/x-eps).include? type
|
227
|
+
end
|
228
|
+
|
225
229
|
def cleanup_entities(text, is_xml: true)
|
226
230
|
c = HTMLEntities.new
|
227
231
|
if is_xml
|
data/lib/isodoc/init.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
class Convert < ::IsoDoc::Common
|
3
|
+
def metadata_init(lang, script, i18n)
|
4
|
+
@meta = Metadata.new(lang, script, i18n)
|
5
|
+
end
|
6
|
+
|
7
|
+
def xref_init(lang, script, _klass, i18n, options)
|
8
|
+
html = HtmlConvert.new(language: @lang, script: @script)
|
9
|
+
@xrefs = Xref.new(lang, script, html, i18n, options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def i18n_init(lang, script, i18nyaml = nil)
|
13
|
+
@i18n = I18n.new(lang, script, i18nyaml: i18nyaml || @i18nyaml)
|
14
|
+
end
|
15
|
+
|
16
|
+
def l10n(expr, lang = @lang, script = @script)
|
17
|
+
@i18n.l10n(expr, lang, script)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -45,7 +45,6 @@ module IsoDoc
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
# introduce name element
|
49
48
|
def formula1(elem)
|
50
49
|
lbl = @xrefs.anchor(elem["id"], :label, false)
|
51
50
|
prefix_name(elem, "", lbl, "name")
|
@@ -73,7 +72,6 @@ module IsoDoc
|
|
73
72
|
end
|
74
73
|
end
|
75
74
|
|
76
|
-
# introduce name element
|
77
75
|
def note1(elem)
|
78
76
|
return if elem.parent.name == "bibitem" || elem["notag"] == "true"
|
79
77
|
|
@@ -116,11 +114,10 @@ module IsoDoc
|
|
116
114
|
end
|
117
115
|
end
|
118
116
|
|
119
|
-
# introduce name element
|
120
117
|
def recommendation1(elem, type)
|
121
|
-
|
122
|
-
|
123
|
-
prefix_name(elem, "", lbl, "name")
|
118
|
+
lbl = @reqt_models.model(elem["model"])
|
119
|
+
.recommendation_label(elem, type, xrefs)
|
120
|
+
prefix_name(elem, "", l10n(lbl), "name")
|
124
121
|
end
|
125
122
|
|
126
123
|
def table(docxml)
|
@@ -175,5 +172,25 @@ module IsoDoc
|
|
175
172
|
def ol1(elem)
|
176
173
|
elem["type"] ||= ol_depth(elem).to_s
|
177
174
|
end
|
175
|
+
|
176
|
+
def requirement_render_preprocessing(docxml); end
|
177
|
+
|
178
|
+
REQS = %w(requirement recommendation permission).freeze
|
179
|
+
|
180
|
+
def requirement_render(docxml)
|
181
|
+
requirement_render_preprocessing(docxml)
|
182
|
+
REQS.each do |x|
|
183
|
+
REQS.each do |y|
|
184
|
+
docxml.xpath(ns("//#{x}//#{y}")).each { |r| requirement_render1(r) }
|
185
|
+
end
|
186
|
+
end
|
187
|
+
docxml.xpath(ns("//requirement | //recommendation | //permission"))
|
188
|
+
.each { |r| requirement_render1(r) }
|
189
|
+
end
|
190
|
+
|
191
|
+
def requirement_render1(node)
|
192
|
+
node.replace(@reqt_models.model(node["model"])
|
193
|
+
.requirement_render1(node))
|
194
|
+
end
|
178
195
|
end
|
179
196
|
end
|