metanorma-nist 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +22 -0
- data/lib/asciidoctor/nist/biblio.rng +13 -3
- data/lib/asciidoctor/nist/front.rb +1 -0
- data/lib/asciidoctor/nist/front_id.rb +73 -23
- data/lib/asciidoctor/nist/isodoc.rng +17 -1
- data/lib/isodoc/nist/base_convert.rb +43 -61
- data/lib/isodoc/nist/html/nist.scss +1 -1
- data/lib/isodoc/nist/html/nist_cswp.scss +1 -1
- data/lib/isodoc/nist/html_convert.rb +29 -60
- data/lib/isodoc/nist/metadata.rb +0 -6
- data/lib/isodoc/nist/nist.cswp.xsl +181 -51
- data/lib/isodoc/nist/nist.sp.xsl +181 -51
- data/lib/isodoc/nist/refs.rb +38 -0
- data/lib/isodoc/nist/section.rb +55 -0
- data/lib/isodoc/nist/word_convert.rb +2 -38
- data/lib/metanorma/nist/version.rb +1 -1
- data/metanorma-nist.gemspec +2 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6120113a1a25fe7c901041b783738db95eec32d26fa63c3265a65e46a8da9352
|
4
|
+
data.tar.gz: 1b239f36b6030165b2c5558e1fc16f3fb5cd382639086fdad6d7137ee3df3bbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca4c404c621a96f42795694bb73b993bb397d2ed2bbb37a995d5af1e153934eb6f1e9d1a094c5969294fdf1889d28070365a407d62d9d4ec84f56eedcbff5ac3
|
7
|
+
data.tar.gz: 30d92c0a8e10d5e1ad630f7894b844b9ff7a092a2eb567a034a176bafd91643f6f38aef9ed5f219a3d7953b705bb5f65d5902e7657a990d22c263d06981d00c8
|
data/README.adoc
CHANGED
@@ -223,6 +223,10 @@ Used to indicate the date of errata releases.
|
|
223
223
|
The date at which a draft is circulated. Displayed on the cover page of drafts.
|
224
224
|
MANDATORY FOR DRAFTS.
|
225
225
|
|
226
|
+
`:language:`::
|
227
|
+
Two-letter code (ISO 639-1) of the language the document is written in. Defaults to `en`.
|
228
|
+
If multiple languages are used in the document, comma-delimited; e.g. `en,fr`.
|
229
|
+
|
226
230
|
=== NIST-specific attributes
|
227
231
|
|
228
232
|
The following document attributes are specific to this document class:
|
@@ -239,11 +243,29 @@ Added to authority statement as document contact. Use line breaks (in Asciidocto
|
|
239
243
|
`:revision:`:: The document revision; e.g. `1` (Revision 1). Will be stored in Metanorma XML
|
240
244
|
under the `<edition>` tag, with the prefix `Revision `.
|
241
245
|
|
246
|
+
`:version:`:: The document version, when titled as version. Will be stored in Metanorma XML
|
247
|
+
under the `<edition>` tag, with the prefix `Version `.
|
248
|
+
|
242
249
|
`:volume:`::
|
243
250
|
The number of the volume of a standard. Is ignored if a precomposed
|
244
251
|
document identifier (`:docidentifier:`) is supplied.
|
245
252
|
Is prefixed with "Volume" or "Vol." in display.
|
246
253
|
|
254
|
+
`:part:`::
|
255
|
+
The part number of a standard. Is only used to generate machine readable NIST identifier (nist-mr).
|
256
|
+
|
257
|
+
`:section:`::
|
258
|
+
The section number of a standard. Is only used to generate machine readable NIST identifier (nist-mr).
|
259
|
+
|
260
|
+
`:supplement:`::
|
261
|
+
The supplement number of a standard. Is only used to generate machine readable NIST identifier (nist-mr).
|
262
|
+
|
263
|
+
`:index:`::
|
264
|
+
The index number of a standard. Is only used to generate machine readable NIST identifier (nist-mr).
|
265
|
+
|
266
|
+
`:update:`::
|
267
|
+
The update number of a standard. Is only used to generate machine readable NIST identifier (nist-mr).
|
268
|
+
|
247
269
|
`:title-main:`:: The title of the document.
|
248
270
|
`:title-sub:`:: The subtitle of the document.
|
249
271
|
|
@@ -661,9 +661,9 @@
|
|
661
661
|
<optional>
|
662
662
|
<ref name="status"/>
|
663
663
|
</optional>
|
664
|
-
<
|
664
|
+
<zeroOrMore>
|
665
665
|
<ref name="copyright"/>
|
666
|
-
</
|
666
|
+
</zeroOrMore>
|
667
667
|
<zeroOrMore>
|
668
668
|
<ref name="docrelation"/>
|
669
669
|
</zeroOrMore>
|
@@ -1021,7 +1021,17 @@
|
|
1021
1021
|
<optional>
|
1022
1022
|
<ref name="to"/>
|
1023
1023
|
</optional>
|
1024
|
-
<
|
1024
|
+
<oneOrMore>
|
1025
|
+
<ref name="owner"/>
|
1026
|
+
</oneOrMore>
|
1027
|
+
<optional>
|
1028
|
+
<ref name="copyright_scope"/>
|
1029
|
+
</optional>
|
1030
|
+
</element>
|
1031
|
+
</define>
|
1032
|
+
<define name="copyright_scope">
|
1033
|
+
<element name="scope">
|
1034
|
+
<text/>
|
1025
1035
|
</element>
|
1026
1036
|
</define>
|
1027
1037
|
<define name="from">
|
@@ -20,6 +20,7 @@ module Asciidoctor
|
|
20
20
|
def metadata_version(node, xml)
|
21
21
|
xml.edition node.attr("edition") if node.attr("edition")
|
22
22
|
xml.edition "Revision #{node.attr("revision")}" if node.attr("revision")
|
23
|
+
xml.edition "Version #{node.attr("version")}" if node.attr("version")
|
23
24
|
xml.version do |v|
|
24
25
|
v.revision_date node.attr("revdate") if node.attr("revdate")
|
25
26
|
v.draft node.attr("draft") if node.attr("draft")
|
@@ -1,17 +1,16 @@
|
|
1
|
+
require "iso-639"
|
2
|
+
|
1
3
|
module Asciidoctor
|
2
4
|
module NIST
|
3
5
|
class Converter < Standoc::Converter
|
4
6
|
def metadata_id(node, xml)
|
5
7
|
did = node.attr("docidentifier")
|
6
8
|
dn = node.attr("docnumber")
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
metadata_id_compose(node, xml, dn)
|
13
|
-
end
|
14
|
-
xml.docnumber node.attr("docnumber")
|
9
|
+
@series == "nist-cswp" && !node.attr("docnumber") and
|
10
|
+
dn = Iso690Render.MMMddyyyy(node.attr("issued-date"))
|
11
|
+
metadata_id_compose(node, xml, dn, did)
|
12
|
+
xml.docnumber node.attr("docnumber") ||
|
13
|
+
did&.sub(/^[^0-9]*/, "")&.sub(/[ -].*$/, "")
|
15
14
|
end
|
16
15
|
|
17
16
|
def unabbreviate(did)
|
@@ -21,26 +20,42 @@ module Asciidoctor
|
|
21
20
|
end
|
22
21
|
|
23
22
|
def id_args(node, dn0)
|
23
|
+
return nil unless dn0
|
24
24
|
{
|
25
25
|
id: dn0,
|
26
26
|
series: node.attr("series"),
|
27
|
+
edition: node.attr("edition"),
|
28
|
+
version: node.attr("version"),
|
27
29
|
revision: node.attr("revision"),
|
30
|
+
update: node.attr("update"),
|
31
|
+
year: (node.attr("copyright-year") || node.attr("updated-date") ||
|
32
|
+
node.attr("revdate") || node.attr("circulated-date") ||
|
33
|
+
Date.today.year.to_s).sub(/^(....).*$/, "\\1"),
|
28
34
|
vol: node.attr("volume"),
|
35
|
+
part: node.attr("part") || node.attr("part-number"),
|
36
|
+
section: node.attr("section") || node.attr("section-number"),
|
37
|
+
supplement: node.attr("supplement") || node.attr("supplement-number"),
|
38
|
+
index: node.attr("index") || node.attr("index-number"),
|
29
39
|
stage: node.attr("status") || node.attr("docstage"),
|
30
40
|
iter: node.attr("iteration"),
|
41
|
+
language: node.attr("language") || "en",
|
31
42
|
date: /^draft/.match(node.attr("status") || node.attr("docstage")) ?
|
32
43
|
(node.attr("circulated-date") || node.attr("revdate")) :
|
33
44
|
node.attr("updated-date")
|
34
45
|
}
|
35
46
|
end
|
36
47
|
|
37
|
-
def metadata_id_compose(node, xml, dn0)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
48
|
+
def metadata_id_compose(node, xml, dn0, did)
|
49
|
+
if did
|
50
|
+
xml.docidentifier did, **attr_code(type: "NIST")
|
51
|
+
xml.docidentifier unabbreviate(did), **attr_code(type: "nist-long")
|
52
|
+
else
|
53
|
+
args = id_args(node, dn0) || return
|
54
|
+
xml.docidentifier add_id_parts(args, false), **attr_code(type: "NIST")
|
55
|
+
xml.docidentifier add_id_parts(args, true),
|
56
|
+
**attr_code(type: "nist-long")
|
57
|
+
xml.docidentifier add_id_parts_mr(args), **attr_code(type: "nist-mr")
|
58
|
+
end
|
44
59
|
end
|
45
60
|
|
46
61
|
def MMMddyyyy(isodate)
|
@@ -48,26 +63,61 @@ module Asciidoctor
|
|
48
63
|
Date.parse(isodate).strftime("%B %d, %Y")
|
49
64
|
end
|
50
65
|
|
66
|
+
def status_abbr(stage, iter)
|
67
|
+
IsoDoc::NIST::Metadata.new(nil, nil, {}).status_abbr(stage, iter)
|
68
|
+
end
|
69
|
+
|
51
70
|
def add_id_parts(args, long)
|
52
|
-
vol_delim = " Volume "
|
53
|
-
ed_delim = " Revision "
|
54
71
|
args[:series] and series_name = long ?
|
55
72
|
SERIES.dig(args[:series].to_sym) :
|
56
73
|
SERIES_ABBR.dig(args[:series].to_sym)
|
57
74
|
dn = (series_name || "NIST #{args[:series]}") + " " + args[:id]
|
58
|
-
dn += "#{
|
75
|
+
dn += " Volume #{args[:vol]}" if args[:vol]
|
59
76
|
dn += "," if args[:vol] && args[:revision]
|
60
|
-
dn += "#{
|
61
|
-
|
62
|
-
dn += " (#{stage})"
|
77
|
+
dn += " Revision #{args[:revision]}" if args[:revision]
|
78
|
+
dn += "/Upd #{args[:update]}:#{args[:year]}" if args[:update]
|
79
|
+
stage = status_abbr(args[:stage], args[:iter]) and dn += " (#{stage})"
|
63
80
|
dn += " (#{MMMddyyyy(args[:date])})" if args[:date]
|
64
81
|
dn
|
65
82
|
end
|
66
83
|
|
84
|
+
def id_parts_mr(args)
|
85
|
+
part = []
|
86
|
+
part << "v-#{args[:vol]}" if args[:vol]
|
87
|
+
part << "pt-#{args[:part]}" if args[:part]
|
88
|
+
part << "sec-#{args[:section]}" if args[:section]
|
89
|
+
part << "sup-#{args[:supplement]}" if args[:supplement]
|
90
|
+
part << "indx-#{args[:index]}" if args[:index]
|
91
|
+
part
|
92
|
+
end
|
93
|
+
|
94
|
+
def id_editions_mr(args)
|
95
|
+
part = []
|
96
|
+
part << "e-#{args[:edition]}" if args[:edition]
|
97
|
+
part << "r-#{args[:revision]}" if args[:revision]
|
98
|
+
part << "ver-#{args[:version]}" if args[:version]
|
99
|
+
part
|
100
|
+
end
|
101
|
+
|
102
|
+
def id_lang_mr(args)
|
103
|
+
ret = args[:language].split(/,\s*/).map do |l|
|
104
|
+
ISO_639.find(l).alpha3
|
105
|
+
end.join(",")
|
106
|
+
end
|
107
|
+
|
67
108
|
def add_id_parts_mr(args)
|
109
|
+
ret = ["NIST"]
|
68
110
|
args[:series] and
|
69
|
-
|
70
|
-
|
111
|
+
ret << SERIES_ABBR&.dig(args[:series].to_sym)&.sub(/^NIST /, "")
|
112
|
+
stage = status_abbr(args[:stage], nil) || ""
|
113
|
+
stage += "[-#{args[:iter]}]" if args[:iter]
|
114
|
+
ret << stage unless stage.empty?
|
115
|
+
ret << args[:id]
|
116
|
+
ret += id_parts_mr(args)
|
117
|
+
ret += id_editions_mr(args)
|
118
|
+
ret << id_lang_mr(args)
|
119
|
+
args[:update] and ret << "upd-#{args[:update]}:#{args[:year]}"
|
120
|
+
ret.join(".")
|
71
121
|
end
|
72
122
|
end
|
73
123
|
end
|
@@ -53,6 +53,14 @@
|
|
53
53
|
<optional>
|
54
54
|
<attribute name="alt"/>
|
55
55
|
</optional>
|
56
|
+
<optional>
|
57
|
+
<attribute name="case">
|
58
|
+
<choice>
|
59
|
+
<value>capital</value>
|
60
|
+
<value>lowercase</value>
|
61
|
+
</choice>
|
62
|
+
</attribute>
|
63
|
+
</optional>
|
56
64
|
<text/>
|
57
65
|
</element>
|
58
66
|
</define>
|
@@ -902,7 +910,15 @@
|
|
902
910
|
<attribute name="id">
|
903
911
|
<data type="ID"/>
|
904
912
|
</attribute>
|
905
|
-
<
|
913
|
+
<oneOrMore>
|
914
|
+
<choice>
|
915
|
+
<ref name="paragraph"/>
|
916
|
+
<ref name="ul"/>
|
917
|
+
<ref name="ol"/>
|
918
|
+
<ref name="dl"/>
|
919
|
+
<ref name="formula"/>
|
920
|
+
</choice>
|
921
|
+
</oneOrMore>
|
906
922
|
</element>
|
907
923
|
</define>
|
908
924
|
<define name="termexample">
|
@@ -2,20 +2,12 @@ require "isodoc"
|
|
2
2
|
require_relative "metadata"
|
3
3
|
require_relative "xrefs"
|
4
4
|
require_relative "refs"
|
5
|
+
require_relative "section"
|
5
6
|
require "fileutils"
|
6
7
|
|
7
8
|
module IsoDoc
|
8
9
|
module NIST
|
9
10
|
module BaseConvert
|
10
|
-
def abstract(isoxml, out)
|
11
|
-
f = isoxml.at(ns("//preface/abstract")) || return
|
12
|
-
#page_break(out)
|
13
|
-
out.div **attr_code(id: f["id"]) do |s|
|
14
|
-
clause_name(nil, @abstract_lbl, s, class: "AbstractTitle")
|
15
|
-
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
11
|
def keywords(_docxml, out)
|
20
12
|
kw = @meta.get[:keywords]
|
21
13
|
kw.empty? and return
|
@@ -25,27 +17,8 @@ module IsoDoc
|
|
25
17
|
end
|
26
18
|
end
|
27
19
|
|
28
|
-
FRONT_CLAUSE = "//*[parent::preface][not(local-name() = 'abstract' or
|
29
|
-
|
30
|
-
# All "[preface]" sections should have class "IntroTitle" to prevent
|
31
|
-
# page breaks
|
32
|
-
# But for the Exec Summary
|
33
|
-
def preface(isoxml, out)
|
34
|
-
isoxml.xpath(ns(FRONT_CLAUSE)).each do |c|
|
35
|
-
next if skip_render(c, isoxml)
|
36
|
-
title = c&.at(ns("./title"))
|
37
|
-
patent = ["Call for Patent Claims", "Patent Disclosure Notice"].include? title&.text
|
38
|
-
out.div **attr_code(id: c["id"]) do |s|
|
39
|
-
page_break(s) if patent
|
40
|
-
clause_name(anchor(c['id'], :label), title, s,
|
41
|
-
class: (c.name == "executivesummary") ? "NormalTitle" :
|
42
|
-
"IntroTitle")
|
43
|
-
c.elements.reject { |c1| c1.name == "title" }.each do |c1|
|
44
|
-
parse(c1, s)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
20
|
+
FRONT_CLAUSE = "//*[parent::preface][not(local-name() = 'abstract' or "\
|
21
|
+
"local-name() = 'foreword')]".freeze
|
49
22
|
|
50
23
|
def skip_render(c, isoxml)
|
51
24
|
return false unless c.name == "reviewernote"
|
@@ -157,13 +130,13 @@ module IsoDoc
|
|
157
130
|
"//terms[parent::sections]".freeze
|
158
131
|
|
159
132
|
def middle(isoxml, out)
|
133
|
+
middle_admonitions(isoxml, out)
|
160
134
|
clause isoxml, out
|
161
135
|
bibliography isoxml, out
|
162
136
|
annex isoxml, out
|
163
137
|
end
|
164
138
|
|
165
139
|
def info(isoxml, out)
|
166
|
-
@meta.keywords isoxml, out
|
167
140
|
@meta.series isoxml, out
|
168
141
|
@meta.commentperiod isoxml, out
|
169
142
|
@meta.note isoxml, out
|
@@ -176,13 +149,15 @@ module IsoDoc
|
|
176
149
|
end
|
177
150
|
|
178
151
|
def get_linkend(node)
|
179
|
-
link = anchor_linkend(node, docid_l10n(node["target"] ||
|
180
|
-
|
181
|
-
|
152
|
+
link = anchor_linkend(node, docid_l10n(node["target"] ||
|
153
|
+
wrap_brackets(node['citeas'])))
|
154
|
+
link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
|
155
|
+
link)
|
156
|
+
contents = node.children.select do |c|
|
157
|
+
!%w{locality localityStack}.include? c.name
|
158
|
+
end
|
182
159
|
return link if contents.nil? || contents.empty?
|
183
160
|
Nokogiri::XML::NodeSet.new(node.document, contents).to_xml
|
184
|
-
# so not <origin bibitemid="ISO7301" citeas="ISO 7301">
|
185
|
-
# <locality type="section"><reference>3.1</reference></locality></origin>
|
186
161
|
end
|
187
162
|
|
188
163
|
def load_yaml(lang, script)
|
@@ -205,38 +180,45 @@ module IsoDoc
|
|
205
180
|
end
|
206
181
|
end
|
207
182
|
|
208
|
-
def
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
183
|
+
def termref_parse(node, out)
|
184
|
+
end
|
185
|
+
|
186
|
+
def term_cleanup(docxml)
|
187
|
+
docxml.xpath("//table[@class = 'terms_dl']").each do |d|
|
188
|
+
prev = d.previous_element
|
189
|
+
next unless prev && prev.name == "table" &&
|
190
|
+
prev["class"] == "terms_dl"
|
191
|
+
d.children.each { |n| prev.add_child(n.remove) }
|
192
|
+
d.remove
|
217
193
|
end
|
194
|
+
docxml
|
218
195
|
end
|
219
196
|
|
220
|
-
def
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
197
|
+
def term_and_termref_parse(node, dt)
|
198
|
+
pref = node.at(ns("./preferred"))
|
199
|
+
source = node.xpath(ns("./termsource"))
|
200
|
+
pref.children.each { |n| parse(n, dt) }
|
201
|
+
return if source.empty?
|
202
|
+
dt << "<br/>"
|
203
|
+
source.each_with_index do |s, i|
|
204
|
+
i > 0 and dt << "; "
|
205
|
+
s.elements.each { |n| parse(n, dt) }
|
206
|
+
end
|
228
207
|
end
|
229
208
|
|
230
|
-
def
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
s.h1(**{ class: "ForewordTitle" }) do |h1|
|
235
|
-
title and title.children.each { |e| parse(e, h1) }
|
236
|
-
end
|
237
|
-
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
209
|
+
def term_rest_parse(node, dd)
|
210
|
+
set_termdomain("")
|
211
|
+
node.children.each do |n|
|
212
|
+
parse(n, dd) unless %w(preferred termsource).include?(n.name)
|
238
213
|
end
|
239
214
|
end
|
215
|
+
|
216
|
+
def modification_parse(node, out)
|
217
|
+
out << @modified_lbl
|
218
|
+
node.at(ns("./p[text()[normalize-space() != '']]")) and
|
219
|
+
out << " — "
|
220
|
+
node.at(ns("./p")).children.each { |n| parse(n, out) }
|
221
|
+
end
|
240
222
|
end
|
241
223
|
end
|
242
224
|
end
|
@@ -693,7 +693,7 @@ div.Admonition {
|
|
693
693
|
mso-ansi-language:EN-AU;
|
694
694
|
}
|
695
695
|
|
696
|
-
div
|
696
|
+
div.Admonition p {
|
697
697
|
margin-top:6.0pt;margin-right:0cm;
|
698
698
|
margin-bottom:6.0pt;margin-left:0cm;text-align:left;mso-pagination:widow-orphan;
|
699
699
|
mso-hyphenate:auto;background:#dddddd;mso-layout-grid-align:auto;mso-vertical-align-alt:
|
@@ -643,7 +643,7 @@ div.Admonition {
|
|
643
643
|
mso-ansi-language:EN-AU;
|
644
644
|
}
|
645
645
|
|
646
|
-
div
|
646
|
+
div.Admonition p {
|
647
647
|
margin-top:6.0pt;margin-right:0cm;
|
648
648
|
margin-bottom:6.0pt;margin-left:0cm;text-align:left;mso-pagination:widow-orphan;
|
649
649
|
mso-hyphenate:auto;background:#dddddd;mso-layout-grid-align:auto;mso-vertical-align-alt:
|
@@ -20,9 +20,11 @@ module IsoDoc
|
|
20
20
|
|
21
21
|
def default_fonts(options)
|
22
22
|
{
|
23
|
-
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' :
|
24
|
-
|
25
|
-
|
23
|
+
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' :
|
24
|
+
'"Libre Baskerville",serif'),
|
25
|
+
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
|
26
|
+
'"Libre Baskerville",serif'),
|
27
|
+
monospacefont: '"Space Mono",monospace'
|
26
28
|
}
|
27
29
|
end
|
28
30
|
|
@@ -48,28 +50,34 @@ module IsoDoc
|
|
48
50
|
end
|
49
51
|
|
50
52
|
def toclevel
|
51
|
-
ret = toclevel_classes.map
|
52
|
-
|
53
|
+
ret = toclevel_classes.map do |l|
|
54
|
+
"#{l}:not(:empty):not(.TermNum):not(.noTOC):not(.AbstractTitle):"\
|
55
|
+
"not(.IntroTitle):not(.ForewordTitle)"
|
56
|
+
end
|
57
|
+
<<~HEAD.freeze
|
53
58
|
function toclevel() { return "#{ret.join(',')}";}
|
54
|
-
|
55
|
-
|
59
|
+
HEAD
|
60
|
+
end
|
56
61
|
|
57
62
|
def html_toc(docxml)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
idx = docxml.at("//div[@id = 'toc']") or return docxml
|
64
|
+
toc = "<ul>"
|
65
|
+
path = toclevel_classes.map do |l|
|
66
|
+
"//main//#{l}[not(@class = 'TermNum')][not(@class = 'noTOC')]"\
|
67
|
+
"[not(text())][not(@class = 'AbstractTitle')]"\
|
68
|
+
"[not(@class = 'IntroTitle')][not(@class = 'ForewordTitle')]"
|
69
|
+
end
|
70
|
+
docxml.xpath(path.join(" | ")).each_with_index do |h, tocidx|
|
71
|
+
h["id"] ||= "toc#{tocidx}"
|
72
|
+
toc += html_toc_entry(h.name, h)
|
73
|
+
end
|
74
|
+
idx.children = "#{toc}</ul>"
|
75
|
+
docxml
|
66
76
|
end
|
67
|
-
idx.children = "#{toc}</ul>"
|
68
|
-
docxml
|
69
|
-
end
|
70
77
|
|
71
78
|
def make_body(xml, docxml)
|
72
|
-
body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72",
|
79
|
+
body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72",
|
80
|
+
"xml:lang": "EN-US", class: "container" }
|
73
81
|
xml.body **body_attr do |body|
|
74
82
|
make_body1(body, docxml)
|
75
83
|
make_body2(body, docxml)
|
@@ -117,56 +125,17 @@ module IsoDoc
|
|
117
125
|
end
|
118
126
|
end
|
119
127
|
|
120
|
-
def bibliography(isoxml, out)
|
121
|
-
f = isoxml.at(ns("//bibliography/clause | //bibliography/references")) || return
|
122
|
-
page_break(out)
|
123
|
-
isoxml.xpath(ns("//bibliography/clause | //bibliography/references")).each do |f|
|
124
|
-
out.div do |div|
|
125
|
-
div.h1 **{ class: "Section3" } do |h1|
|
126
|
-
if @bibliographycount == 1 then h1 << "References"
|
127
|
-
else
|
128
|
-
f&.at(ns("./title"))&.children.each { |n| parse(n, h1) }
|
129
|
-
end
|
130
|
-
end
|
131
|
-
biblio_list(f, div, false)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def keywords(_docxml, out)
|
137
|
-
kw = @meta.get[:keywords]
|
138
|
-
kw.empty? and return
|
139
|
-
out.div **{ class: "Section3" } do |div|
|
140
|
-
out.div do |div|
|
141
|
-
clause_name(nil, "Keywords", div, class: "IntroTitle")
|
142
|
-
div.p kw.sort.join("; ")
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
128
|
def termdef_parse(node, out)
|
148
|
-
pref = node.at(ns("./preferred"))
|
149
129
|
out.dl **{ class: "terms_dl" } do |dl|
|
150
130
|
dl.dt do |dt|
|
151
|
-
|
131
|
+
term_and_termref_parse(node, dt)
|
152
132
|
end
|
153
|
-
set_termdomain("")
|
154
133
|
dl.dd do |dd|
|
155
|
-
node
|
134
|
+
term_rest_parse(node, dd)
|
156
135
|
end
|
157
136
|
end
|
158
137
|
end
|
159
138
|
|
160
|
-
def term_cleanup(docxml)
|
161
|
-
docxml.xpath("//table[@class = 'terms_dl']").each do |d|
|
162
|
-
prev = d.previous_element
|
163
|
-
next unless prev and prev.name == "table" and prev["class"] == "terms_dl"
|
164
|
-
d.children.each { |n| prev.add_child(n.remove) }
|
165
|
-
d.remove
|
166
|
-
end
|
167
|
-
docxml
|
168
|
-
end
|
169
|
-
|
170
139
|
include BaseConvert
|
171
140
|
end
|
172
141
|
end
|