isodoc 1.0.29 → 1.1.3.pre.alpha2
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 +6 -12
- data/.github/workflows/ubuntu.yml +18 -20
- data/.github/workflows/windows.yml +6 -12
- data/Rakefile +3 -1
- data/isodoc.gemspec +2 -2
- data/lib/isodoc.rb +2 -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/metanorma_word.scss +0 -1
- data/lib/isodoc/base_style/nav.css +0 -0
- data/lib/isodoc/base_style/reset.css +105 -0
- data/lib/isodoc/base_style/reset.scss +3 -3
- data/lib/isodoc/base_style/typography.css +0 -0
- data/lib/isodoc/common.rb +0 -4
- data/lib/isodoc/convert.rb +121 -58
- data/lib/isodoc/function/blocks.rb +3 -3
- data/lib/isodoc/function/blocks_example_note.rb +2 -2
- data/lib/isodoc/function/inline.rb +5 -5
- data/lib/isodoc/function/references.rb +29 -34
- data/lib/isodoc/function/reqt.rb +1 -1
- data/lib/isodoc/function/section.rb +7 -11
- data/lib/isodoc/function/table.rb +1 -1
- data/lib/isodoc/function/terms.rb +2 -2
- data/lib/isodoc/function/to_word_html.rb +2 -2
- data/lib/isodoc/function/utils.rb +57 -51
- data/lib/isodoc/gem_tasks.rb +117 -0
- data/lib/isodoc/headlesshtml_convert.rb +7 -6
- data/lib/isodoc/html_convert.rb +2 -1
- data/lib/isodoc/html_function/html.rb +1 -1
- data/lib/isodoc/html_function/postprocess.rb +1 -1
- data/lib/isodoc/metadata.rb +69 -63
- data/lib/isodoc/pdf_convert.rb +8 -6
- data/lib/isodoc/presentation_xml_convert.rb +29 -0
- data/lib/isodoc/sassc_importer.rb +11 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_convert.rb +2 -1
- data/lib/isodoc/word_function/body.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +1 -0
- 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 +9 -22
- data/lib/isodoc/{function → xref}/xref_gen_seq.rb +34 -26
- data/lib/isodoc/{function → xref}/xref_sect_gen.rb +33 -23
- data/lib/isodoc/xslfo_convert.rb +16 -4
- data/spec/assets/{html.css → html.scss} +0 -0
- data/spec/isodoc/footnotes_spec.rb +2 -2
- data/spec/isodoc/postproc_spec.rb +1319 -1345
- data/spec/isodoc/presentation_xml_spec.rb +20 -0
- data/spec/isodoc/ref_spec.rb +1 -1
- data/spec/isodoc/section_spec.rb +52 -0
- metadata +40 -28
- data/lib/isodoc/function/xref_counter.rb +0 -84
@@ -49,9 +49,9 @@ time, mark, audio, video {
|
|
49
49
|
}
|
50
50
|
|
51
51
|
html, body, div, span, applet, object, iframe,
|
52
|
-
p, blockquote,
|
53
|
-
a, abbr, acronym, address, big, cite,
|
54
|
-
del, dfn, em, img, ins, q, s,
|
52
|
+
p, blockquote,
|
53
|
+
a, abbr, acronym, address, big, cite,
|
54
|
+
del, dfn, em, img, ins, q, s,
|
55
55
|
small, strike, strong, sub, sup, var,
|
56
56
|
b, u, i, center,
|
57
57
|
dl, dt, dd, ol, ul, li,
|
File without changes
|
data/lib/isodoc/common.rb
CHANGED
@@ -9,8 +9,6 @@ require_relative "./function/table"
|
|
9
9
|
require_relative "./function/terms"
|
10
10
|
require_relative "./function/to_word_html"
|
11
11
|
require_relative "./function/utils"
|
12
|
-
require_relative "./function/xref_gen"
|
13
|
-
require_relative "./function/xref_sect_gen"
|
14
12
|
require_relative "./function/reqt"
|
15
13
|
require_relative "./class_utils"
|
16
14
|
|
@@ -27,8 +25,6 @@ module IsoDoc
|
|
27
25
|
include Function::Terms
|
28
26
|
include Function::ToWordHtml
|
29
27
|
include Function::Utils
|
30
|
-
include Function::XrefGen
|
31
|
-
include Function::XrefSectGen
|
32
28
|
|
33
29
|
extend ::IsoDoc::ClassUtils
|
34
30
|
end
|
data/lib/isodoc/convert.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'isodoc/common'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'tempfile'
|
5
6
|
|
6
7
|
module IsoDoc
|
7
8
|
class Convert < ::IsoDoc::Common
|
@@ -27,15 +28,25 @@ module IsoDoc
|
|
27
28
|
# scripts_pdf: Scripts file for PDF
|
28
29
|
# datauriimage: Encode images in HTML output as data URIs
|
29
30
|
def initialize(options)
|
30
|
-
@libdir
|
31
|
-
options.merge!(default_fonts(options))
|
32
|
-
|
31
|
+
@libdir ||= File.dirname(__FILE__)
|
32
|
+
options.merge!(default_fonts(options)) do |_, old, new|
|
33
|
+
old || new
|
34
|
+
end
|
35
|
+
.merge!(default_file_locations(options)) do |_, old, new|
|
36
|
+
old || new
|
37
|
+
end
|
33
38
|
@options = options
|
34
39
|
@files_to_delete = []
|
35
40
|
@tempfile_cache = []
|
36
|
-
@htmlstylesheet_name =
|
37
|
-
|
38
|
-
|
41
|
+
@htmlstylesheet_name = precompiled_style_or_original(
|
42
|
+
options[:htmlstylesheet]
|
43
|
+
)
|
44
|
+
@wordstylesheet_name = precompiled_style_or_original(
|
45
|
+
options[:wordstylesheet]
|
46
|
+
)
|
47
|
+
@standardstylesheet_name = precompiled_style_or_original(
|
48
|
+
options[:standardstylesheet]
|
49
|
+
)
|
39
50
|
@header = options[:header]
|
40
51
|
@htmlcoverpage = options[:htmlcoverpage]
|
41
52
|
@wordcoverpage = options[:wordcoverpage]
|
@@ -48,12 +59,11 @@ module IsoDoc
|
|
48
59
|
@olstyle = options[:olstyle]
|
49
60
|
@datauriimage = options[:datauriimage]
|
50
61
|
@suppressheadingnumbers = options[:suppressheadingnumbers]
|
51
|
-
@break_up_urls_in_tables = options[:break_up_urls_in_tables] ==
|
52
|
-
@termdomain =
|
62
|
+
@break_up_urls_in_tables = options[:break_up_urls_in_tables] == 'true'
|
63
|
+
@termdomain = ''
|
53
64
|
@termexample = false
|
54
65
|
@note = false
|
55
66
|
@sourcecode = false
|
56
|
-
@anchors = {}
|
57
67
|
@footnotes = []
|
58
68
|
@comments = []
|
59
69
|
@in_footnote = false
|
@@ -62,40 +72,57 @@ module IsoDoc
|
|
62
72
|
@in_figure = false
|
63
73
|
@seen_footnote = Set.new
|
64
74
|
@c = HTMLEntities.new
|
65
|
-
@openmathdelim =
|
66
|
-
@closemathdelim =
|
67
|
-
@lang =
|
68
|
-
@script =
|
75
|
+
@openmathdelim = '`'
|
76
|
+
@closemathdelim = '`'
|
77
|
+
@lang = 'en'
|
78
|
+
@script = 'Latn'
|
69
79
|
@maxwidth = 1200
|
70
80
|
@maxheight = 800
|
71
81
|
@wordToClevels = options[:doctoclevels].to_i
|
72
|
-
@wordToClevels = 2 if @wordToClevels
|
82
|
+
@wordToClevels = 2 if @wordToClevels.zero?
|
73
83
|
@htmlToClevels = options[:htmltoclevels].to_i
|
74
|
-
@htmlToClevels = 2 if @htmlToClevels
|
75
|
-
@bookmarks_allocated = {
|
84
|
+
@htmlToClevels = 2 if @htmlToClevels.zero?
|
85
|
+
@bookmarks_allocated = { 'X' => true }
|
76
86
|
@fn_bookmarks = {}
|
77
87
|
end
|
78
88
|
|
89
|
+
# Check if already compiled version(.css) exists,
|
90
|
+
# if not, return original scss file. During release
|
91
|
+
# we compile scss into css files in order to not depend on scss
|
92
|
+
def precompiled_style_or_original(stylesheet_path)
|
93
|
+
# Already have compiled stylesheet, use it
|
94
|
+
return stylesheet_path if stylesheet_path.nil? ||
|
95
|
+
File.extname(stylesheet_path) == '.css'
|
96
|
+
|
97
|
+
basename = File.basename(stylesheet_path, '.*')
|
98
|
+
compiled_path = File.join(File.dirname(stylesheet_path),
|
99
|
+
"#{basename}.css")
|
100
|
+
return stylesheet_path unless File.file?(compiled_path)
|
101
|
+
|
102
|
+
compiled_path
|
103
|
+
end
|
104
|
+
|
79
105
|
# run this after @meta is populated
|
80
106
|
def populate_css
|
81
|
-
@htmlstylesheet = generate_css(@htmlstylesheet_name, true
|
82
|
-
@wordstylesheet = generate_css(@wordstylesheet_name, false
|
83
|
-
@standardstylesheet = generate_css(@standardstylesheet_name, false
|
107
|
+
@htmlstylesheet = generate_css(@htmlstylesheet_name, true)
|
108
|
+
@wordstylesheet = generate_css(@wordstylesheet_name, false)
|
109
|
+
@standardstylesheet = generate_css(@standardstylesheet_name, false)
|
84
110
|
end
|
85
111
|
|
86
112
|
def tmpimagedir_suffix
|
87
|
-
|
113
|
+
'_images'
|
88
114
|
end
|
89
115
|
|
90
116
|
def default_fonts(_options)
|
91
117
|
{
|
92
|
-
bodyfont:
|
93
|
-
headerfont:
|
94
|
-
monospacefont:
|
118
|
+
bodyfont: 'Arial',
|
119
|
+
headerfont: 'Arial',
|
120
|
+
monospacefont: 'Courier'
|
95
121
|
}
|
96
122
|
end
|
97
123
|
|
98
|
-
# none for this parent gem, but will be populated in child
|
124
|
+
# none for this parent gem, but will be populated in child
|
125
|
+
# gems which have access to stylesheets &c; e.g.
|
99
126
|
# {
|
100
127
|
# htmlstylesheet: html_doc_path("htmlstyle.scss"),
|
101
128
|
# htmlcoverpage: html_doc_path("html_rsd_titlepage.html"),
|
@@ -113,41 +140,62 @@ module IsoDoc
|
|
113
140
|
{}
|
114
141
|
end
|
115
142
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
143
|
+
def fonts_options
|
144
|
+
{
|
145
|
+
'bodyfont' => options[:bodyfont] || 'Arial',
|
146
|
+
'headerfont' => options[:headerfont] || 'Arial',
|
147
|
+
'monospacefont' => options[:monospacefont] || 'Courier'
|
148
|
+
}
|
149
|
+
end
|
150
|
+
|
151
|
+
def scss_fontheader
|
152
|
+
b = options[:bodyfont] || 'Arial'
|
153
|
+
h = options[:headerfont] || 'Arial'
|
154
|
+
m = options[:monospacefont] || 'Courier'
|
121
155
|
"$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
|
122
156
|
end
|
123
157
|
|
124
158
|
def html_doc_path(file)
|
125
|
-
File.join(@libdir, File.join(
|
159
|
+
File.join(@libdir, File.join('html', file))
|
126
160
|
end
|
127
161
|
|
128
|
-
def
|
129
|
-
|
130
|
-
|
162
|
+
def convert_scss(filename, stylesheet)
|
163
|
+
require 'sassc'
|
164
|
+
require 'isodoc/sassc_importer'
|
165
|
+
|
166
|
+
[File.join(Gem.loaded_specs['isodoc'].full_gem_path,
|
167
|
+
'lib', 'isodoc'),
|
168
|
+
File.dirname(filename)].each do |name|
|
169
|
+
SassC.load_paths << name
|
170
|
+
end
|
171
|
+
SassC::Engine.new(scss_fontheader + stylesheet, syntax: :scss,
|
172
|
+
importer: SasscImporter)
|
173
|
+
.render
|
174
|
+
end
|
175
|
+
|
176
|
+
def generate_css(filename, stripwordcss)
|
177
|
+
return nil if filename.nil?
|
178
|
+
|
179
|
+
stylesheet = File.read(filename, encoding: 'UTF-8')
|
131
180
|
stylesheet = populate_template(stylesheet, :word)
|
132
|
-
stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m,
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
f.write(engine.render)
|
181
|
+
stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, '\\1') if stripwordcss
|
182
|
+
if File.extname(filename) == '.scss'
|
183
|
+
stylesheet = convert_scss(filename, stylesheet)
|
184
|
+
end
|
185
|
+
Tempfile.open([File.basename(filename, '.*'), 'css'],
|
186
|
+
encoding: 'utf-8') do |f|
|
187
|
+
f.write(stylesheet)
|
140
188
|
f
|
141
189
|
end
|
142
190
|
end
|
143
191
|
|
144
192
|
def convert1(docxml, filename, dir)
|
145
|
-
|
193
|
+
@xrefs.parse docxml
|
146
194
|
noko do |xml|
|
147
|
-
xml.html **{ lang:
|
148
|
-
html.parent.add_namespace(
|
195
|
+
xml.html **{ lang: @lang.to_s } do |html|
|
196
|
+
html.parent.add_namespace('epub', 'http://www.idpf.org/2007/ops')
|
149
197
|
info docxml, nil
|
150
|
-
populate_css
|
198
|
+
populate_css
|
151
199
|
html.head { |head| define_head head, filename, dir }
|
152
200
|
make_body(html, docxml)
|
153
201
|
end
|
@@ -158,25 +206,40 @@ module IsoDoc
|
|
158
206
|
@meta = Metadata.new(lang, script, labels)
|
159
207
|
end
|
160
208
|
|
161
|
-
def
|
209
|
+
def xref_init(lang, script, klass, labels, options)
|
210
|
+
@xrefs = Xref.new(lang, script, klass, labels, options)
|
211
|
+
end
|
212
|
+
|
213
|
+
def convert_init(file, input_filename, debug)
|
162
214
|
docxml = Nokogiri::XML(file)
|
163
|
-
filename, dir = init_file(
|
164
|
-
docxml.root.default_namespace =
|
165
|
-
lang = docxml&.at(ns(
|
166
|
-
script = docxml&.at(ns(
|
215
|
+
filename, dir = init_file(input_filename, debug)
|
216
|
+
docxml.root.default_namespace = ''
|
217
|
+
lang = docxml&.at(ns('//bibdata/language'))&.text || @lang
|
218
|
+
script = docxml&.at(ns('//bibdata/script'))&.text || @script
|
167
219
|
i18n_init(lang, script)
|
168
220
|
metadata_init(lang, script, @labels)
|
221
|
+
@meta.fonts_options = fonts_options
|
222
|
+
xref_init(lang, script, self, @labels, {})
|
169
223
|
[docxml, filename, dir]
|
170
224
|
end
|
171
225
|
|
172
|
-
def convert(
|
173
|
-
|
226
|
+
def convert(input_filename,
|
227
|
+
file = nil,
|
228
|
+
debug = false,
|
229
|
+
output_filename = nil)
|
230
|
+
file = File.read(input_filename, encoding: 'utf-8') if file.nil?
|
174
231
|
@openmathdelim, @closemathdelim = extract_delims(file)
|
175
|
-
docxml, filename, dir = convert_init(file,
|
232
|
+
docxml, filename, dir = convert_init(file, input_filename, debug)
|
176
233
|
result = convert1(docxml, filename, dir)
|
177
234
|
return result if debug
|
178
|
-
|
235
|
+
output_filename ||= "#{filename}.#{@suffix}"
|
236
|
+
postprocess(result, output_filename, dir)
|
179
237
|
FileUtils.rm_rf dir
|
180
238
|
end
|
239
|
+
|
240
|
+
def middle_clause
|
241
|
+
"//clause[parent::sections][not(xmlns:title = 'Scope')]"\
|
242
|
+
'[not(descendant::terms)]'
|
243
|
+
end
|
181
244
|
end
|
182
245
|
end
|
@@ -6,7 +6,7 @@ module IsoDoc::Function
|
|
6
6
|
|
7
7
|
def figure_name_parse(node, div, name)
|
8
8
|
return if name.nil? && node.at(ns("./figure"))
|
9
|
-
lbl = anchor(node['id'], :label, false)
|
9
|
+
lbl = @xrefs.anchor(node['id'], :label, false)
|
10
10
|
lbl = nil if labelled_ancestor(node) && node.ancestors("figure").empty?
|
11
11
|
return if lbl.nil? && name.nil?
|
12
12
|
div.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
|
@@ -55,7 +55,7 @@ module IsoDoc::Function
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def sourcecode_name_parse(node, div, name)
|
58
|
-
lbl = anchor(node['id'], :label, false)
|
58
|
+
lbl = @xrefs.anchor(node['id'], :label, false)
|
59
59
|
lbl = nil if labelled_ancestor(node)
|
60
60
|
return if lbl.nil? && name.nil?
|
61
61
|
div.p **{ class: "SourceTitle", style: "text-align:center;" } do |p|
|
@@ -141,7 +141,7 @@ module IsoDoc::Function
|
|
141
141
|
out.div **attr_code(class: "formula") do |div|
|
142
142
|
div.p do |p|
|
143
143
|
parse(node.at(ns("./stem")), div)
|
144
|
-
lbl = anchor(node['id'], :label, false)
|
144
|
+
lbl = @xrefs.anchor(node['id'], :label, false)
|
145
145
|
unless lbl.nil?
|
146
146
|
insert_tab(div, 1)
|
147
147
|
div << "(#{lbl})"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module IsoDoc::Function
|
2
2
|
module Blocks
|
3
3
|
def example_label(node, div, name)
|
4
|
-
n =
|
4
|
+
n = @xrefs.get[node["id"]]
|
5
5
|
div.p **{ class: "example-title" } do |p|
|
6
6
|
lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @example_lbl :
|
7
7
|
l10n("#{@example_lbl} #{n[:label]}")
|
@@ -56,7 +56,7 @@ module IsoDoc::Function
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def note_label(node)
|
59
|
-
n =
|
59
|
+
n = @xrefs.get[node["id"]]
|
60
60
|
return @note_lbl if n.nil? || n[:label].nil? || n[:label].empty?
|
61
61
|
l10n("#{@note_lbl} #{n[:label]}")
|
62
62
|
end
|
@@ -17,17 +17,17 @@ module IsoDoc::Function
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def prefix_container(container, linkend, _target)
|
20
|
-
l10n(anchor(container, :xref) + ", " + linkend)
|
20
|
+
l10n(@xrefs.anchor(container, :xref) + ", " + linkend)
|
21
21
|
end
|
22
22
|
|
23
23
|
def anchor_linkend(node, linkend)
|
24
24
|
if node["citeas"].nil? && node["bibitemid"]
|
25
|
-
return anchor(node["bibitemid"] ,:xref) || "???"
|
25
|
+
return @xrefs.anchor(node["bibitemid"] ,:xref) || "???"
|
26
26
|
elsif node["target"] && !/.#./.match(node["target"])
|
27
|
-
linkend = anchor(node["target"], :xref)
|
28
|
-
container = anchor(node["target"], :container, false)
|
27
|
+
linkend = @xrefs.anchor(node["target"], :xref)
|
28
|
+
container = @xrefs.anchor(node["target"], :container, false)
|
29
29
|
(container && get_note_container_id(node) != container &&
|
30
|
-
@
|
30
|
+
@xrefs.get[node["target"]]) &&
|
31
31
|
linkend = prefix_container(container, linkend, node["target"])
|
32
32
|
linkend = capitalise_xref(node, linkend)
|
33
33
|
end
|
@@ -16,22 +16,24 @@ module IsoDoc::Function
|
|
16
16
|
identifiers = render_identifier(ids)
|
17
17
|
if biblio then ref_entry_code(ref, ordinal, identifiers, ids)
|
18
18
|
else
|
19
|
-
ref << "#{identifiers[0] || identifiers[1]}
|
20
|
-
ref << "#{identifiers[1]}
|
19
|
+
ref << "#{identifiers[0] || identifiers[1]}"
|
20
|
+
ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
|
21
21
|
end
|
22
|
+
ref << ", " unless biblio && !identifiers[1]
|
22
23
|
reference_format(b, ref)
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
def std_bibitem_entry(list, b, ordinal, biblio)
|
27
28
|
list.p **attr_code(iso_bibitem_entry_attrs(b, biblio)) do |ref|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
identifiers = render_identifier(bibitem_ref_code(b))
|
30
|
+
if biblio then ref_entry_code(ref, ordinal, identifiers, nil)
|
31
|
+
else
|
32
|
+
ref << "#{identifiers[0] || identifiers[1]}"
|
33
|
+
ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
|
34
|
+
end
|
33
35
|
date_note_process(b, ref)
|
34
|
-
ref << ", "
|
36
|
+
ref << ", " unless biblio && !identifiers[1]
|
35
37
|
reference_format(b, ref)
|
36
38
|
end
|
37
39
|
end
|
@@ -40,9 +42,7 @@ module IsoDoc::Function
|
|
40
42
|
# else, use both ordinal, as prefix, and t
|
41
43
|
def ref_entry_code(r, ordinal, t, id)
|
42
44
|
prefix_bracketed_ref(r, t[0] || "[#{ordinal}]")
|
43
|
-
|
44
|
-
r << "#{t[1]}, "
|
45
|
-
end
|
45
|
+
t[1] and r << "#{t[1]}"
|
46
46
|
end
|
47
47
|
|
48
48
|
def pref_ref_code(b)
|
@@ -129,12 +129,6 @@ module IsoDoc::Function
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
ISO_PUBLISHER_XPATH =
|
133
|
-
"./contributor[xmlns:role/@type = 'publisher']/"\
|
134
|
-
"organization[abbreviation = 'ISO' or xmlns:abbreviation = 'IEC' or "\
|
135
|
-
"xmlns:name = 'International Organization for Standardization' or "\
|
136
|
-
"xmlns:name = 'International Electrotechnical Commission']".freeze
|
137
|
-
|
138
132
|
def is_standard(b)
|
139
133
|
ret = false
|
140
134
|
b.xpath(ns("./docidentifier")).each do |id|
|
@@ -159,22 +153,33 @@ module IsoDoc::Function
|
|
159
153
|
end
|
160
154
|
end
|
161
155
|
|
156
|
+
def norm_ref_xpath
|
157
|
+
"//bibliography/references[@normative = 'true'] | "\
|
158
|
+
"//bibliography/clause[.//references[@normative = 'true']]"
|
159
|
+
end
|
160
|
+
|
162
161
|
def norm_ref(isoxml, out, num)
|
163
|
-
|
164
|
-
f = isoxml.at(ns(q)) or return num
|
162
|
+
f = isoxml.at(ns(norm_ref_xpath)) or return num
|
165
163
|
out.div do |div|
|
166
164
|
num = num + 1
|
167
165
|
clause_name(num, @normref_lbl, div, nil)
|
168
|
-
|
166
|
+
if f.name == "clause"
|
167
|
+
f.elements.each { |e| parse(e, div) unless e.name == "title" }
|
168
|
+
else
|
169
|
+
biblio_list(f, div, false)
|
170
|
+
end
|
169
171
|
end
|
170
172
|
num
|
171
173
|
end
|
172
174
|
|
173
|
-
|
174
|
-
"//bibliography/references
|
175
|
+
def bibliography_xpath
|
176
|
+
"//bibliography/clause[.//references]"\
|
177
|
+
"[not(.//references[@normative = 'true'])] | "\
|
178
|
+
"//bibliography/references[@normative = 'false']"
|
179
|
+
end
|
175
180
|
|
176
181
|
def bibliography(isoxml, out)
|
177
|
-
f = isoxml.at(ns(
|
182
|
+
f = isoxml.at(ns(bibliography_xpath)) || return
|
178
183
|
page_break(out)
|
179
184
|
out.div do |div|
|
180
185
|
div.h1 @bibliography_lbl, **{ class: "Section3" }
|
@@ -185,7 +190,7 @@ module IsoDoc::Function
|
|
185
190
|
def bibliography_parse(node, out)
|
186
191
|
title = node&.at(ns("./title"))&.text || ""
|
187
192
|
out.div do |div|
|
188
|
-
anchor(node['id'], :label, false) and
|
193
|
+
@xrefs.anchor(node['id'], :label, false) and
|
189
194
|
clause_parse_title(node, div, node.at(ns("./title")), out) or
|
190
195
|
div.h2 title, **{ class: "Section3" }
|
191
196
|
biblio_list(node, div, true)
|
@@ -199,16 +204,6 @@ module IsoDoc::Function
|
|
199
204
|
ref
|
200
205
|
end
|
201
206
|
|
202
|
-
def reference_names(ref)
|
203
|
-
isopub = ref.at(ns(ISO_PUBLISHER_XPATH))
|
204
|
-
ids = bibitem_ref_code(ref)
|
205
|
-
identifiers = render_identifier(ids)
|
206
|
-
date = ref.at(ns("./date[@type = 'published']"))
|
207
|
-
allparts = ref.at(ns("./extent[@type='part'][referenceFrom='all']"))
|
208
|
-
reference = docid_l10n(identifiers[0] || identifiers[1])
|
209
|
-
@anchors[ref["id"]] = { xref: reference }
|
210
|
-
end
|
211
|
-
|
212
207
|
# def ref_names(ref)
|
213
208
|
# linkend = ref.text
|
214
209
|
# linkend.gsub!(/[\[\]]/, "") unless /^\[\d+\]$/.match linkend
|