metanorma-standoc 3.1.5 → 3.1.7
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/lib/isodoc/html/htmlstyle.css +27 -31
- data/lib/metanorma/standoc/base.rb +9 -2
- data/lib/metanorma/standoc/cleanup.rb +14 -2
- data/lib/metanorma/standoc/cleanup_attachment.rb +71 -0
- data/lib/metanorma/standoc/cleanup_bibdata.rb +3 -3
- data/lib/metanorma/standoc/cleanup_bibitem.rb +33 -66
- data/lib/metanorma/standoc/cleanup_block.rb +1 -1
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +20 -11
- data/lib/metanorma/standoc/cleanup_terms_boilerplate.rb +5 -4
- data/lib/metanorma/standoc/converter.rb +1 -0
- data/lib/metanorma/standoc/front.rb +21 -60
- data/lib/metanorma/standoc/front_contributor.rb +3 -1
- data/lib/metanorma/standoc/front_ext.rb +50 -0
- data/lib/metanorma/standoc/init.rb +1 -0
- data/lib/metanorma/standoc/isodoc.rng +26 -19
- data/lib/metanorma/standoc/isolated_converter.rb +65 -0
- data/lib/metanorma/standoc/ref.rb +14 -13
- data/lib/metanorma/standoc/ref_queue.rb +1 -1
- data/lib/metanorma/standoc/ref_sect.rb +9 -3
- data/lib/metanorma/standoc/regex.rb +6 -3
- data/lib/metanorma/standoc/spans_to_bibitem.rb +10 -2
- data/lib/metanorma/standoc/spans_to_bibitem_preprocessing.rb +1 -1
- data/lib/metanorma/standoc/utils.rb +6 -4
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 154ca8c34101aef7d0dfb0cad7c1bf0cfafaf3df110a0fef56a7d524b17a7d5b
|
4
|
+
data.tar.gz: 7904a365e5bbaf50e159e164c5fc11e74d356f48a50de19889433f015eb9040d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d50a9d2df00a760fe948b97d28f50652c09fe313942a48d2648018a68edf4e783d62288d965e9a34225b4804bdae4bf483f4c47317fcb2188590ecf4b4495e5
|
7
|
+
data.tar.gz: 616012d1b9ceaafbfd255aed0d477e66e201affece833b21413529c7ee2172c708400bc63422f3b29d460ca1d5b787a420f111b7cbfa7ec11deb46f103da893c
|
@@ -145,16 +145,6 @@ div.document-stage-band, div.document-type-band {
|
|
145
145
|
background-color: #333333;
|
146
146
|
}
|
147
147
|
|
148
|
-
a.FootnoteRef + a.FootnoteRef::before {
|
149
|
-
content: ", ";
|
150
|
-
vertical-align: super;
|
151
|
-
}
|
152
|
-
|
153
|
-
a.TableFootnoteRef + a.TableFootnoteRef::before {
|
154
|
-
content: ", ";
|
155
|
-
vertical-align: super;
|
156
|
-
}
|
157
|
-
|
158
148
|
a.TableFootnoteRef, span.TableFootnoteRef,
|
159
149
|
a.FootnoteRef, span.FootnoteRef {
|
160
150
|
vertical-align: super;
|
@@ -477,11 +467,13 @@ body {
|
|
477
467
|
line-height: 1.4em;
|
478
468
|
color: #1d1d1d;
|
479
469
|
background-color: #ffffff;
|
480
|
-
font-weight: 400;
|
481
470
|
}
|
482
471
|
body main {
|
483
472
|
margin: 0 3em 0 6em;
|
484
473
|
}
|
474
|
+
body {
|
475
|
+
font-weight: 400;
|
476
|
+
}
|
485
477
|
body pre * {
|
486
478
|
font-family: {{bodyfont}} !important;
|
487
479
|
}
|
@@ -489,10 +481,6 @@ body pre * {
|
|
489
481
|
/*
|
490
482
|
2. Responsive navigation layout
|
491
483
|
*/
|
492
|
-
#toc, #toc > ul > :is(.h1, .h2, .h3, .h4, .h5, .h6) {
|
493
|
-
font-family: {{bodyfont}};
|
494
|
-
font-weight: 400;
|
495
|
-
}
|
496
484
|
#toc ul, #toc > ul > :is(.h1, .h2, .h3, .h4, .h5, .h6) ul {
|
497
485
|
margin: 0;
|
498
486
|
padding: 0;
|
@@ -544,6 +532,10 @@ body pre * {
|
|
544
532
|
color: black;
|
545
533
|
}
|
546
534
|
}
|
535
|
+
#toc, #toc > ul > :is(.h1, .h2, .h3, .h4, .h5, .h6) {
|
536
|
+
font-family: {{bodyfont}};
|
537
|
+
font-weight: 400;
|
538
|
+
}
|
547
539
|
@media screen and (max-width: 768px) {
|
548
540
|
#toc, #toc > ul > :is(.h1, .h2, .h3, .h4, .h5, .h6) {
|
549
541
|
padding: 0 1.5em;
|
@@ -632,12 +624,6 @@ body pre * {
|
|
632
624
|
}
|
633
625
|
}
|
634
626
|
|
635
|
-
div.figure {
|
636
|
-
line-height: 1.6em;
|
637
|
-
padding: 1.5em;
|
638
|
-
margin: 2em 0 1em 0;
|
639
|
-
overflow: auto;
|
640
|
-
}
|
641
627
|
div.figure .FigureTitle, div.figure .figure-title {
|
642
628
|
font-weight: 700;
|
643
629
|
font-size: 1em;
|
@@ -650,6 +636,12 @@ div.figure > img, div.figure > svg {
|
|
650
636
|
max-width: 100%;
|
651
637
|
height: auto;
|
652
638
|
}
|
639
|
+
div.figure {
|
640
|
+
line-height: 1.6em;
|
641
|
+
padding: 1.5em;
|
642
|
+
margin: 2em 0 1em 0;
|
643
|
+
overflow: auto;
|
644
|
+
}
|
653
645
|
|
654
646
|
/*
|
655
647
|
Document types + stages
|
@@ -969,6 +961,13 @@ p.Biblio, p.NormRef {
|
|
969
961
|
/*
|
970
962
|
3.6 Source Code + figures
|
971
963
|
*/
|
964
|
+
.figure .SourceTitle,
|
965
|
+
pre .SourceTitle,
|
966
|
+
.pseudocode .SourceTitle {
|
967
|
+
font-weight: 700;
|
968
|
+
font-size: 1em;
|
969
|
+
text-align: center;
|
970
|
+
}
|
972
971
|
.figure,
|
973
972
|
pre,
|
974
973
|
.pseudocode {
|
@@ -979,13 +978,6 @@ pre,
|
|
979
978
|
margin: 2em 0 1em 0;
|
980
979
|
overflow: auto;
|
981
980
|
}
|
982
|
-
.figure .SourceTitle,
|
983
|
-
pre .SourceTitle,
|
984
|
-
.pseudocode .SourceTitle {
|
985
|
-
font-weight: 700;
|
986
|
-
font-size: 1em;
|
987
|
-
text-align: center;
|
988
|
-
}
|
989
981
|
|
990
982
|
pre {
|
991
983
|
font-family: {{monospacefont}};
|
@@ -1032,12 +1024,14 @@ pre {
|
|
1032
1024
|
padding: 1.2em;
|
1033
1025
|
margin: 2em 0 1em 0;
|
1034
1026
|
text-align: left;
|
1035
|
-
color: #424242;
|
1036
|
-
padding-left: 2.7em;
|
1037
1027
|
}
|
1038
1028
|
.example p {
|
1039
1029
|
margin: 0;
|
1040
1030
|
}
|
1031
|
+
.example {
|
1032
|
+
color: #424242;
|
1033
|
+
padding-left: 2.7em;
|
1034
|
+
}
|
1041
1035
|
.example .example-title {
|
1042
1036
|
font-weight: 700;
|
1043
1037
|
text-transform: uppercase;
|
@@ -1318,7 +1312,6 @@ To top button
|
|
1318
1312
|
cursor: pointer;
|
1319
1313
|
padding: 10px 15px 10px 15px;
|
1320
1314
|
border-radius: 4px;
|
1321
|
-
text-transform: uppercase;
|
1322
1315
|
}
|
1323
1316
|
#myBtn:hover {
|
1324
1317
|
opacity: 1;
|
@@ -1328,6 +1321,9 @@ To top button
|
|
1328
1321
|
display: none;
|
1329
1322
|
}
|
1330
1323
|
}
|
1324
|
+
#myBtn {
|
1325
|
+
text-transform: uppercase;
|
1326
|
+
}
|
1331
1327
|
#myBtn a.anchorjs-link:hover {
|
1332
1328
|
background: none;
|
1333
1329
|
color: #485094;
|
@@ -9,6 +9,7 @@ require "metanorma-utils"
|
|
9
9
|
require_relative "render"
|
10
10
|
require_relative "localbib"
|
11
11
|
require_relative "init"
|
12
|
+
require_relative "isolated_converter"
|
12
13
|
require "mn-requirements"
|
13
14
|
|
14
15
|
module Asciidoctor
|
@@ -20,6 +21,8 @@ end
|
|
20
21
|
module Metanorma
|
21
22
|
module Standoc
|
22
23
|
module Base
|
24
|
+
include IsolatedConverter
|
25
|
+
|
23
26
|
# XML_ROOT_TAG = "standard-document".freeze
|
24
27
|
# XML_NAMESPACE = "https://www.metanorma.org/ns/standoc".freeze
|
25
28
|
FONTS_MANIFEST = "fonts-manifest".freeze
|
@@ -107,10 +110,14 @@ module Metanorma
|
|
107
110
|
result = makexml1(node)
|
108
111
|
ret1 = cleanup(Nokogiri::XML(insert_xml_cr(result)))
|
109
112
|
ret1.root.add_namespace(nil, xml_namespace)
|
110
|
-
validate(ret1) unless @novalid
|
113
|
+
validate(ret1) unless @novalid || in_isolated_conversion?
|
111
114
|
ret1
|
112
115
|
end
|
113
116
|
|
117
|
+
def in_isolated_conversion?
|
118
|
+
!@isolated_conversion_stack.empty?
|
119
|
+
end
|
120
|
+
|
114
121
|
def draft?
|
115
122
|
@draft
|
116
123
|
end
|
@@ -139,7 +146,7 @@ module Metanorma
|
|
139
146
|
%w(presentation semantic).each do |t|
|
140
147
|
/^#{t}-metadata-/.match?(k) or next
|
141
148
|
k = k.sub(/^#{t}-metadata-/, "")
|
142
|
-
|
149
|
+
csv_split(v.gsub("&#", "&#"), ",", encode: false)&.each do |c|
|
143
150
|
ret << "<#{t}-metadata><#{k}>#{c}</#{k}></#{t}-metadata>"
|
144
151
|
end
|
145
152
|
end
|
@@ -83,7 +83,9 @@ module Metanorma
|
|
83
83
|
ext_contributor_cleanup(xmldoc) # feeds: bibdata_cleanup
|
84
84
|
ext_dochistory_cleanup(xmldoc) # feeds: bibdata_cleanup
|
85
85
|
bibdata_cleanup(xmldoc) # feeds: boilerplate_cleanup
|
86
|
-
boilerplate_cleanup(xmldoc) # feeds: xref_cleanup for new <<>>
|
86
|
+
boilerplate_cleanup(xmldoc) # feeds: xref_cleanup for new <<>>
|
87
|
+
# introduced, pres_metadata_cleanup
|
88
|
+
pres_metadata_cleanup(xmldoc)
|
87
89
|
xref_cleanup(xmldoc)
|
88
90
|
svgmap_cleanup(xmldoc) # feeds: img_cleanup
|
89
91
|
review_cleanup(xmldoc)
|
@@ -132,7 +134,7 @@ module Metanorma
|
|
132
134
|
verbal-definition non-verbal-representation}.freeze
|
133
135
|
|
134
136
|
# it seems Nokogiri::XML is treating the content of <script> as cdata,
|
135
|
-
# because of its use in HTML. Bad
|
137
|
+
# because of its use in HTML. Bad Nokogiri. Undoing that, since we use
|
136
138
|
# script as a normal tag
|
137
139
|
def script_cleanup(xmldoc)
|
138
140
|
xmldoc.xpath("//script").each { |x| x.content = x.to_str }
|
@@ -209,6 +211,16 @@ module Metanorma
|
|
209
211
|
ins = add_misc_container(xmldoc)
|
210
212
|
ins << @metadata_attrs
|
211
213
|
end
|
214
|
+
|
215
|
+
def pres_metadata_cleanup(xmldoc)
|
216
|
+
@isodoc ||= isodoc(@lang, @script, @locale)
|
217
|
+
isodoc_bibdata_parse(xmldoc)
|
218
|
+
xmldoc.xpath("//presentation-metadata/* | //semantic-metadata/*")
|
219
|
+
.each do |x|
|
220
|
+
/\{\{|\{%/.match?(x) or next
|
221
|
+
x.children = @isodoc.populate_template(to_xml(x.children), nil)
|
222
|
+
end
|
223
|
+
end
|
212
224
|
end
|
213
225
|
end
|
214
226
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module Standoc
|
3
|
+
module Cleanup
|
4
|
+
def attachment_cleanup(xmldoc)
|
5
|
+
xmldoc.xpath("//bibitem[uri/@type = 'attachment']").each do |b|
|
6
|
+
b["hidden"] = "true"
|
7
|
+
b.at("./docidentifier[@type = 'title']")&.remove
|
8
|
+
u = b.at("./uri[@type = 'attachment']")
|
9
|
+
c = b.at("./uri[@type = 'citation']") ||
|
10
|
+
u.after("<uri type='citation'/>")
|
11
|
+
uri = attachment_uri(u.text, b)
|
12
|
+
u.children = uri
|
13
|
+
c.children = uri
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def attachment_uri(path, bib)
|
18
|
+
init_attachments
|
19
|
+
path = File.join(@localdir, path)
|
20
|
+
valid_attachment?(path, bib) or return ""
|
21
|
+
@datauriattachment or return attachment_location(path)
|
22
|
+
save_attachment(path, bib)
|
23
|
+
end
|
24
|
+
|
25
|
+
def save_attachment(path, bib)
|
26
|
+
init_attachments
|
27
|
+
f = File.basename(path)
|
28
|
+
File.exist?(File.join(@attachmentsdir, f)) and
|
29
|
+
f += "_#{UUIDTools::UUID.random_create}"
|
30
|
+
out_fld = File.join(@attachmentsdir, f)
|
31
|
+
FileUtils.cp(path, out_fld)
|
32
|
+
datauri_attachment(out_fld, bib.document)
|
33
|
+
end
|
34
|
+
|
35
|
+
def attachment_location(path)
|
36
|
+
f = path
|
37
|
+
@datauriattachment and
|
38
|
+
f = File.join(@attachmentsdir, File.basename(path))
|
39
|
+
Pathname.new(File.expand_path(f))
|
40
|
+
.relative_path_from(Pathname.new(File.expand_path(@output_dir))).to_s
|
41
|
+
end
|
42
|
+
|
43
|
+
def datauri_attachment(path, doc)
|
44
|
+
@datauriattachment or return
|
45
|
+
m = add_misc_container(doc)
|
46
|
+
f = attachment_location(path)
|
47
|
+
e = (m << "<attachment name='#{f}'/>").last_element_child
|
48
|
+
Vectory::Utils::datauri(path, @output_dir).scan(/.{1,60}/)
|
49
|
+
.each { |dd| e << "#{dd}\n" }
|
50
|
+
f
|
51
|
+
end
|
52
|
+
|
53
|
+
def valid_attachment?(path, bib)
|
54
|
+
File.exist?(path) and return true
|
55
|
+
p = Pathname.new(path).cleanpath
|
56
|
+
@log.add("Bibliography", bib, "Attachment #{p} does not exist",
|
57
|
+
severity: 0)
|
58
|
+
false
|
59
|
+
end
|
60
|
+
|
61
|
+
def init_attachments
|
62
|
+
@datauriattachment or return
|
63
|
+
@attachmentsdir and return
|
64
|
+
@attachmentsfld = "_#{@filename}_attachments"
|
65
|
+
@attachmentsdir = File.join(@output_dir, @attachmentsfld)
|
66
|
+
FileUtils.rm_rf(@attachmentsdir)
|
67
|
+
FileUtils.mkdir_p(@attachmentsdir)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -119,9 +119,9 @@ module Metanorma
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def hdr2bibitem(hdr)
|
122
|
-
xml =
|
123
|
-
|
124
|
-
|
122
|
+
xml = isolated_asciidoctor_convert(hdr[:text],
|
123
|
+
backend: hdr2bibitem_type(hdr),
|
124
|
+
header_footer: true)
|
125
125
|
b = Nokogiri::XML(xml).at("//xmlns:bibdata")
|
126
126
|
b.name = "bibitem"
|
127
127
|
b.delete("type")
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "cleanup_attachment"
|
2
|
+
|
1
3
|
module Metanorma
|
2
4
|
module Standoc
|
3
5
|
module Cleanup
|
@@ -145,71 +147,6 @@ module Metanorma
|
|
145
147
|
end
|
146
148
|
end
|
147
149
|
|
148
|
-
def attachment_cleanup(xmldoc)
|
149
|
-
xmldoc.xpath("//bibitem[uri/@type = 'attachment']").each do |b|
|
150
|
-
b["hidden"] = "true"
|
151
|
-
u = b.at("./uri[@type = 'attachment']")
|
152
|
-
c = b.at("./uri[@type = 'citation']") ||
|
153
|
-
u.after("<uri type='citation'/>")
|
154
|
-
uri = attachment_uri(u.text, b)
|
155
|
-
u.children = uri
|
156
|
-
c.children = uri
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
def attachment_uri(path, bib)
|
161
|
-
init_attachments
|
162
|
-
path = File.join(@localdir, path)
|
163
|
-
valid_attachment?(path, bib) or return ""
|
164
|
-
@datauriattachment or return attachment_location(path)
|
165
|
-
save_attachment(path, bib)
|
166
|
-
end
|
167
|
-
|
168
|
-
def save_attachment(path, bib)
|
169
|
-
init_attachments
|
170
|
-
f = File.basename(path)
|
171
|
-
File.exist?(File.join(@attachmentsdir, f)) and
|
172
|
-
f += "_#{UUIDTools::UUID.random_create}"
|
173
|
-
out_fld = File.join(@attachmentsdir, f)
|
174
|
-
FileUtils.cp(path, out_fld)
|
175
|
-
datauri_attachment(out_fld, bib.document)
|
176
|
-
end
|
177
|
-
|
178
|
-
def attachment_location(path)
|
179
|
-
f = path
|
180
|
-
@datauriattachment and
|
181
|
-
f = File.join(@attachmentsdir, File.basename(path))
|
182
|
-
Pathname.new(File.expand_path(f))
|
183
|
-
.relative_path_from(Pathname.new(File.expand_path(@output_dir))).to_s
|
184
|
-
end
|
185
|
-
|
186
|
-
def datauri_attachment(path, doc)
|
187
|
-
@datauriattachment or return
|
188
|
-
m = add_misc_container(doc)
|
189
|
-
f = attachment_location(path)
|
190
|
-
e = (m << "<attachment name='#{f}'/>").last_element_child
|
191
|
-
Vectory::Utils::datauri(path, @output_dir).scan(/.{1,60}/)
|
192
|
-
.each { |dd| e << "#{dd}\n" }
|
193
|
-
f
|
194
|
-
end
|
195
|
-
|
196
|
-
def valid_attachment?(path, bib)
|
197
|
-
File.exist?(path) and return true
|
198
|
-
p = Pathname.new(path).cleanpath
|
199
|
-
@log.add("Bibliography", bib, "Attachment #{p} does not exist",
|
200
|
-
severity: 0)
|
201
|
-
false
|
202
|
-
end
|
203
|
-
|
204
|
-
def init_attachments
|
205
|
-
@datauriattachment or return
|
206
|
-
@attachmentsdir and return
|
207
|
-
@attachmentsfld = "_#{@filename}_attachments"
|
208
|
-
@attachmentsdir = File.join(@output_dir, @attachmentsfld)
|
209
|
-
FileUtils.rm_rf(@attachmentsdir)
|
210
|
-
FileUtils.mkdir_p(@attachmentsdir)
|
211
|
-
end
|
212
|
-
|
213
150
|
# remove dupes if both same ID and same docid, in case dupes introduced
|
214
151
|
# through termbases
|
215
152
|
def remove_dup_bibtem_id(xmldoc)
|
@@ -229,12 +166,42 @@ module Metanorma
|
|
229
166
|
end
|
230
167
|
end
|
231
168
|
|
169
|
+
def remove_empty_docid(xmldoc)
|
170
|
+
xmldoc.xpath("//bibitem/docidentifier[normalize-space(.)='']")
|
171
|
+
.each(&:remove)
|
172
|
+
end
|
173
|
+
|
174
|
+
def empty_docid_to_title(xmldoc)
|
175
|
+
xmldoc.xpath("//references/bibitem").each do |b|
|
176
|
+
b.at("./docidentifier[not(@type = 'metanorma' or @type = 'DOI' or " \
|
177
|
+
"@type = 'metanorma-ordinal')]") and next
|
178
|
+
empty_docid_to_title?(b) or next
|
179
|
+
ins = b.at("./title[last()]") || b.at("./formattedref")
|
180
|
+
id = bibitem_title_to_id(b) or return
|
181
|
+
ins.next = <<~XML
|
182
|
+
<docidentifier type='title' primary='true'>#{id}</docidentifier>
|
183
|
+
XML
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def bibitem_title_to_id(bibitem)
|
188
|
+
t = bibitem.at("./title") || bibitem.at("./formattedref") or return
|
189
|
+
t.text
|
190
|
+
end
|
191
|
+
|
192
|
+
# normative references only, biblio uses ordinal code instead
|
193
|
+
def empty_docid_to_title?(bibitem)
|
194
|
+
bibitem.parent["normative"] == "true"
|
195
|
+
end
|
196
|
+
|
232
197
|
def bibitem_cleanup(xmldoc)
|
233
198
|
bibitem_nested_id(xmldoc) # feeds remove_dup_bibtem_id
|
234
|
-
remove_dup_bibtem_id(xmldoc)
|
235
199
|
ref_dl_cleanup(xmldoc)
|
236
200
|
formattedref_spans(xmldoc)
|
237
201
|
fetch_local_bibitem(xmldoc)
|
202
|
+
remove_empty_docid(xmldoc)
|
203
|
+
empty_docid_to_title(xmldoc)
|
204
|
+
remove_dup_bibtem_id(xmldoc)
|
238
205
|
attachment_cleanup(xmldoc)
|
239
206
|
end
|
240
207
|
end
|
@@ -163,7 +163,7 @@ module Metanorma
|
|
163
163
|
.each_slice(4).map.with_object([]) do |a, acc|
|
164
164
|
acc << safe_noko(a[0], node.document)
|
165
165
|
a.size == 4 or next
|
166
|
-
acc <<
|
166
|
+
acc << isolated_asciidoctor_convert(
|
167
167
|
a[2], doctype: :inline, backend: backend&.to_sym || :standoc
|
168
168
|
)
|
169
169
|
end.join
|
@@ -3,7 +3,7 @@ require_relative "cleanup_terms_boilerplate"
|
|
3
3
|
module Metanorma
|
4
4
|
module Standoc
|
5
5
|
module Cleanup
|
6
|
-
def norm_ref_preface(ref)
|
6
|
+
def norm_ref_preface(ref, isodoc)
|
7
7
|
ins = norm_ref_boilerplate_insert_location(ref)
|
8
8
|
ins2 = norm_ref_process_boilerplate_note(ref)
|
9
9
|
ins2 == :populated and return
|
@@ -12,7 +12,7 @@ module Metanorma
|
|
12
12
|
%w(references bibitem).include? e.name
|
13
13
|
end
|
14
14
|
pref = refs.empty? ? @i18n.norm_empty_pref : @i18n.norm_with_refs_pref
|
15
|
-
ins.next = boilerplate_snippet_convert(pref)
|
15
|
+
ins.next = boilerplate_snippet_convert(pref, isodoc)
|
16
16
|
end
|
17
17
|
|
18
18
|
def norm_ref_process_boilerplate_note(ref)
|
@@ -40,18 +40,27 @@ module Metanorma
|
|
40
40
|
"//bibliography/references[@normative = 'true'][not(@hidden)] | " \
|
41
41
|
"//bibliography/clause[.//references[@normative = 'true']]".freeze
|
42
42
|
|
43
|
+
def dup_with_namespace(elem)
|
44
|
+
ret = elem.dup
|
45
|
+
ret.add_namespace(nil, xml_namespace)
|
46
|
+
ret
|
47
|
+
end
|
48
|
+
|
43
49
|
def boilerplate_isodoc(xmldoc)
|
44
50
|
# prevent infinite recursion of asciidoc boilerplate processing
|
45
51
|
# in termdef_boilerplate_insert and initial_boilerplate
|
46
52
|
xmldoc.at("//metanorma-extension/semantic-metadata/" \
|
47
53
|
"headless[text() = 'true']") and return nil
|
48
|
-
x = xmldoc.dup
|
49
|
-
x.root.add_namespace(nil, xml_namespace)
|
50
|
-
xml = Nokogiri::XML(x.to_xml)
|
51
54
|
@isodoc ||= isodoc(@lang, @script, @locale)
|
55
|
+
isodoc_bibdata_parse(xmldoc)
|
56
|
+
@isodoc
|
57
|
+
end
|
58
|
+
|
59
|
+
def isodoc_bibdata_parse(xmldoc)
|
52
60
|
# initialise @isodoc.xrefs, for @isodoc.xrefs.info
|
61
|
+
x = dup_with_namespace(xmldoc.root)
|
62
|
+
xml = Nokogiri::XML(x.to_xml)
|
53
63
|
@isodoc.bibdata(xml) # do i18n
|
54
|
-
@isodoc
|
55
64
|
end
|
56
65
|
|
57
66
|
def unwrap_boilerplate_clauses(xmldoc, xpath)
|
@@ -71,7 +80,7 @@ module Metanorma
|
|
71
80
|
termdef_boilerplate_insert(xmldoc, isodoc)
|
72
81
|
unwrap_boilerplate_clauses(xmldoc, self.class::TERM_CLAUSE)
|
73
82
|
if f = xmldoc.at(self.class::NORM_REF)
|
74
|
-
norm_ref_preface(f)
|
83
|
+
norm_ref_preface(f, isodoc)
|
75
84
|
unwrap_boilerplate_clauses(f, ".")
|
76
85
|
end
|
77
86
|
initial_boilerplate(xmldoc, isodoc)
|
@@ -210,16 +219,16 @@ module Metanorma
|
|
210
219
|
/\.adoc(\.liquid)?$/.match?(file) or return ret
|
211
220
|
|
212
221
|
# Split content into macro and non-macro parts
|
213
|
-
parts = ret.split(/(#{ADOC_MACRO_PATTERN})/)
|
222
|
+
parts = ret.split(/(#{ADOC_MACRO_PATTERN})/o)
|
214
223
|
|
215
224
|
parts.map.with_index do |part, index|
|
216
|
-
if index.odd? &&
|
225
|
+
if index.odd? && valid_macro?(part)
|
217
226
|
# This is a macro - leave unchanged
|
218
227
|
part
|
219
228
|
else
|
220
229
|
# Not a macro - wrap {{ }} patterns
|
221
230
|
part.gsub(/(?<!\{)(\{\{[^{}]+\}\})(?!\})/,
|
222
|
-
|
231
|
+
"pass-format:metanorma[++\\1++]")
|
223
232
|
end
|
224
233
|
end.join
|
225
234
|
end
|
@@ -240,7 +249,7 @@ module Metanorma
|
|
240
249
|
|
241
250
|
private
|
242
251
|
|
243
|
-
def
|
252
|
+
def valid_macro?(text)
|
244
253
|
# Simple validation - does it look like a macro?
|
245
254
|
text.match?(/^\S+:[^\[]*\[.*\]$/)
|
246
255
|
end
|
@@ -11,19 +11,20 @@ module Metanorma
|
|
11
11
|
e.gsub(/%(?=\p{P}|\p{Z}|$)/, sources || "??")
|
12
12
|
end
|
13
13
|
|
14
|
-
def boilerplate_snippet_convert(adoc)
|
15
|
-
|
14
|
+
def boilerplate_snippet_convert(adoc, isodoc)
|
15
|
+
b = isodoc.populate_template(adoc, nil)
|
16
|
+
ret = boilerplate_xml_cleanup(adoc2xml(b, backend.to_sym))
|
16
17
|
@i18n.l10n(ret.children.to_xml, @lang, @script)
|
17
18
|
end
|
18
19
|
|
19
20
|
def term_defs_boilerplate(div, source, term, _preface, isodoc)
|
20
21
|
verify_term_defs_source(source)
|
21
22
|
a = @i18n.term_def_boilerplate and
|
22
|
-
div.next = boilerplate_snippet_convert(a)
|
23
|
+
div.next = boilerplate_snippet_convert(a, isodoc)
|
23
24
|
a = if source.empty? && term.nil? then @i18n.no_terms_boilerplate
|
24
25
|
else term_defs_boilerplate_cont(source, term, isodoc)
|
25
26
|
end
|
26
|
-
a and div.next = boilerplate_snippet_convert(a)
|
27
|
+
a and div.next = boilerplate_snippet_convert(a, isodoc)
|
27
28
|
end
|
28
29
|
|
29
30
|
def verify_term_defs_source(source)
|
@@ -35,6 +35,7 @@ module Metanorma
|
|
35
35
|
block_macro Metanorma::Plugin::Lutaml::LutamlKlassTableBlockMacro
|
36
36
|
block_macro Metanorma::Plugin::Lutaml::LutamlEnumTableBlockMacro
|
37
37
|
block Metanorma::Plugin::Plantuml::BlockProcessor
|
38
|
+
block_macro Metanorma::Plugin::Plantuml::ImageBlockMacroProcessor
|
38
39
|
preprocessor Metanorma::Standoc::EmbedIncludeProcessor
|
39
40
|
preprocessor Metanorma::Standoc::LinkProtectPreprocessor
|
40
41
|
preprocessor Metanorma::Standoc::PassProtectPreprocessor
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "date"
|
2
2
|
require "pathname"
|
3
3
|
require_relative "./front_contributor"
|
4
|
+
require_relative "./front_ext"
|
4
5
|
require "isoics"
|
5
6
|
|
6
7
|
module Metanorma
|
@@ -53,17 +54,6 @@ module Metanorma
|
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
56
|
-
def metadata_ics(node, xml)
|
57
|
-
ics = node.attr("library-ics")
|
58
|
-
ics&.split(/,\s*/)&.each do |i|
|
59
|
-
xml.ics do |elem|
|
60
|
-
elem.code i
|
61
|
-
icsdata = Isoics.fetch i
|
62
|
-
elem.text_ icsdata.description
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
57
|
def metadata_source(node, xml)
|
68
58
|
node.attr("uri") && xml.uri(node.attr("uri"))
|
69
59
|
%w(xml html pdf doc relaton).each do |t|
|
@@ -183,66 +173,37 @@ module Metanorma
|
|
183
173
|
end
|
184
174
|
end
|
185
175
|
|
186
|
-
def metadata_ext(node, ext)
|
187
|
-
metadata_doctype(node, ext)
|
188
|
-
metadata_subdoctype(node, ext)
|
189
|
-
metadata_flavor(node, ext)
|
190
|
-
metadata_ics(node, ext)
|
191
|
-
structured_id(node, ext)
|
192
|
-
metadata_coverpage_images(node, ext)
|
193
|
-
end
|
194
|
-
|
195
|
-
def structured_id(node, xml); end
|
196
|
-
|
197
|
-
def metadata_doctype(node, xml)
|
198
|
-
xml.doctype doctype(node)
|
199
|
-
end
|
200
|
-
|
201
|
-
def metadata_subdoctype(node, xml)
|
202
|
-
s = node.attr("docsubtype") and xml.subdoctype s
|
203
|
-
end
|
204
|
-
|
205
|
-
def metadata_flavor(_node, ext)
|
206
|
-
ext.flavor processor.new.asciidoctor_backend
|
207
|
-
end
|
208
|
-
|
209
176
|
def metadata_note(node, xml); end
|
210
177
|
|
211
178
|
def metadata_series(node, xml); end
|
212
179
|
|
213
180
|
def title(node, xml)
|
214
|
-
|
215
|
-
|
216
|
-
end
|
217
|
-
|
218
|
-
def title_english(node, xml)
|
219
|
-
["en"].each do |lang|
|
220
|
-
at = { language: lang, format: "text/plain" }
|
221
|
-
xml.title **attr_code(at) do |t|
|
222
|
-
title = Metanorma::Utils::asciidoc_sub(
|
223
|
-
node.attr("title") || node.attr("title-en") || node.attr("doctitle"),
|
224
|
-
)
|
225
|
-
t << title
|
226
|
-
end
|
227
|
-
end
|
181
|
+
title_main(node, xml)
|
182
|
+
title_other(node, xml)
|
228
183
|
end
|
229
184
|
|
230
|
-
|
185
|
+
# English plain title: :title: or implicit, typed as main
|
186
|
+
def title_main(node, xml)
|
187
|
+
title = node.attr("title") || node.attr("doctitle")
|
188
|
+
node.attr("title-en") and return
|
189
|
+
add_title_xml(xml, title, "en", "main")
|
190
|
+
end
|
191
|
+
|
192
|
+
def title_other(node, xml)
|
231
193
|
node.attributes.each do |k, v|
|
232
|
-
/^title-(?<
|
233
|
-
|
234
|
-
|
194
|
+
/^title-(?<remainder>.+)$/ =~ k or next
|
195
|
+
type, language = remainder.split("-", 2)
|
196
|
+
if language.nil?
|
197
|
+
language = type
|
198
|
+
type = "main"
|
199
|
+
end
|
200
|
+
add_title_xml(xml, v, language, type)
|
235
201
|
end
|
236
202
|
end
|
237
203
|
|
238
|
-
def
|
239
|
-
|
240
|
-
|
241
|
-
if a = node.attr(n)
|
242
|
-
xml.send n do |c|
|
243
|
-
a.split(",").each { |x| c.image src: x }
|
244
|
-
end
|
245
|
-
end
|
204
|
+
def add_title_xml(xml, content, language, type)
|
205
|
+
xml.title **attr_code(language: language, type: type) do |t|
|
206
|
+
t << Metanorma::Utils::asciidoc_sub(content)
|
246
207
|
end
|
247
208
|
end
|
248
209
|
end
|
@@ -7,7 +7,9 @@ module Metanorma
|
|
7
7
|
def metadata_author(node, xml)
|
8
8
|
org_author(node, xml)
|
9
9
|
personal_author(node, xml)
|
10
|
-
|
10
|
+
corporate_author = node.attr("corporate-author") ||
|
11
|
+
node.attr("publisher") || default_publisher
|
12
|
+
committee_contributors(node, xml, corporate_author, {})
|
11
13
|
end
|
12
14
|
|
13
15
|
def org_author(node, xml)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module Standoc
|
3
|
+
module Front
|
4
|
+
def metadata_ics(node, xml)
|
5
|
+
ics = node.attr("library-ics")
|
6
|
+
ics&.split(/,\s*/)&.each do |i|
|
7
|
+
xml.ics do |elem|
|
8
|
+
elem.code i
|
9
|
+
icsdata = Isoics.fetch i
|
10
|
+
elem.text_ icsdata.description
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def metadata_ext(node, ext)
|
16
|
+
metadata_doctype(node, ext)
|
17
|
+
metadata_subdoctype(node, ext)
|
18
|
+
metadata_flavor(node, ext)
|
19
|
+
metadata_ics(node, ext)
|
20
|
+
structured_id(node, ext)
|
21
|
+
metadata_coverpage_images(node, ext)
|
22
|
+
end
|
23
|
+
|
24
|
+
def structured_id(node, xml); end
|
25
|
+
|
26
|
+
def metadata_doctype(node, xml)
|
27
|
+
xml.doctype doctype(node)
|
28
|
+
end
|
29
|
+
|
30
|
+
def metadata_subdoctype(node, xml)
|
31
|
+
s = node.attr("docsubtype") and xml.subdoctype s
|
32
|
+
end
|
33
|
+
|
34
|
+
def metadata_flavor(_node, ext)
|
35
|
+
ext.flavor processor.new.asciidoctor_backend
|
36
|
+
end
|
37
|
+
|
38
|
+
def metadata_coverpage_images(node, xml)
|
39
|
+
%w(coverpage-image innercoverpage-image tocside-image
|
40
|
+
backpage-image).each do |n|
|
41
|
+
if a = node.attr(n)
|
42
|
+
xml.send n do |c|
|
43
|
+
a.split(",").each { |x| c.image src: x }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -49,6 +49,7 @@ module Metanorma
|
|
49
49
|
@localdir = Metanorma::Utils::localdir(node)
|
50
50
|
@xrefstyle = node.attr("xrefstyle")
|
51
51
|
@novalid = node.attr("novalid")
|
52
|
+
@isolated_conversion_stack = []
|
52
53
|
@smartquotes = node.attr("smartquotes") != "false"
|
53
54
|
@sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
|
54
55
|
@sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
3
|
-
<!-- VERSION v2.1.
|
3
|
+
<!-- VERSION v2.1.3 -->
|
4
4
|
|
5
5
|
<!--
|
6
6
|
ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
|
@@ -455,14 +455,7 @@ normative or informative references, some split references into sections organiz
|
|
455
455
|
</ref>
|
456
456
|
</zeroOrMore>
|
457
457
|
<zeroOrMore>
|
458
|
-
<ref name="
|
459
|
-
<a:documentation>Bibliographic item cited in the document</a:documentation>
|
460
|
-
</ref>
|
461
|
-
<zeroOrMore>
|
462
|
-
<ref name="note">
|
463
|
-
<a:documentation>Annotation of the bibliographic item</a:documentation>
|
464
|
-
</ref>
|
465
|
-
</zeroOrMore>
|
458
|
+
<ref name="ReferenceEntry"/>
|
466
459
|
</zeroOrMore>
|
467
460
|
<zeroOrMore>
|
468
461
|
<ref name="references">
|
@@ -604,18 +597,21 @@ gives an explicit page orientation</a:documentation>
|
|
604
597
|
</element>
|
605
598
|
</optional>
|
606
599
|
</define>
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
<attribute name="hiddenref">
|
613
|
-
<a:documentation>If true, number the footnote as normal, but suppress display of the footnote reference in the document body.
|
600
|
+
<define name="FnAttributes">
|
601
|
+
<ref name="RequiredId"/>
|
602
|
+
<optional>
|
603
|
+
<attribute name="hiddenref">
|
604
|
+
<a:documentation>If true, number the footnote as normal, but suppress display of the footnote reference in the document body.
|
614
605
|
This is done if the footnote reference is already presented in some other form, e.g. within a figure image.</a:documentation>
|
615
|
-
|
606
|
+
<data type="boolean"/>
|
607
|
+
</attribute>
|
608
|
+
</optional>
|
609
|
+
<attribute name="reference">
|
610
|
+
<a:documentation>The number of the footnote, used to identify it visually</a:documentation>
|
616
611
|
</attribute>
|
617
|
-
</
|
618
|
-
</
|
612
|
+
</define>
|
613
|
+
</include>
|
614
|
+
<!-- end overrides -->
|
619
615
|
<define name="TdAttributes" combine="interleave">
|
620
616
|
<ref name="RequiredId"/>
|
621
617
|
<optional>
|
@@ -853,6 +849,17 @@ titlecase, or lowercase</a:documentation>
|
|
853
849
|
<value>informative</value>
|
854
850
|
</choice>
|
855
851
|
</define>
|
852
|
+
<define name="ReferenceEntry">
|
853
|
+
<a:documentation>Entry in bibliography</a:documentation>
|
854
|
+
<ref name="doc_bibitem">
|
855
|
+
<a:documentation>Bibliographic item cited in the document</a:documentation>
|
856
|
+
</ref>
|
857
|
+
<zeroOrMore>
|
858
|
+
<ref name="note">
|
859
|
+
<a:documentation>Annotation of the bibliographic item</a:documentation>
|
860
|
+
</ref>
|
861
|
+
</zeroOrMore>
|
862
|
+
</define>
|
856
863
|
<define name="doc_bibitem">
|
857
864
|
<a:documentation>Standardisation document representation of bibliographic entry</a:documentation>
|
858
865
|
<element name="bibitem">
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module Standoc
|
3
|
+
module IsolatedConverter
|
4
|
+
# Create an isolated Asciidoctor conversion that doesn't interfere with
|
5
|
+
# the current converter's instance variables
|
6
|
+
def isolated_asciidoctor_convert(content, options = {})
|
7
|
+
# Track that we're in an isolated conversion (for nested calls)
|
8
|
+
@isolated_conversion_stack << true
|
9
|
+
|
10
|
+
begin
|
11
|
+
# Ensure we get a completely fresh Document and conversion context
|
12
|
+
# Each call to Asciidoctor.convert creates a new Document with its own converter
|
13
|
+
# This naturally isolates the conversion from the current instance variables
|
14
|
+
|
15
|
+
# Save critical options that should be preserved from the current context
|
16
|
+
preserved_options = extract_preserved_options(options)
|
17
|
+
|
18
|
+
# Merge with isolated options to ensure clean state and skip validation
|
19
|
+
isolated_options = preserved_options.merge(options).merge(
|
20
|
+
attributes: (preserved_options[:attributes] || {}).merge(
|
21
|
+
'novalid' => '' # Force no validation for isolated documents
|
22
|
+
)
|
23
|
+
)
|
24
|
+
|
25
|
+
# Perform the isolated conversion
|
26
|
+
Asciidoctor.convert(content, isolated_options)
|
27
|
+
ensure
|
28
|
+
# Always pop from stack, even if conversion fails
|
29
|
+
@isolated_conversion_stack.pop
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# Extract options that should be preserved from the current conversion context
|
36
|
+
def extract_preserved_options(user_options)
|
37
|
+
options = {}
|
38
|
+
|
39
|
+
# Preserve safe mode to maintain security context
|
40
|
+
options[:safe] = user_options[:safe] if user_options.key?(:safe)
|
41
|
+
|
42
|
+
# Preserve local directory context if not explicitly overridden
|
43
|
+
options[:base_dir] = @localdir if @localdir && !user_options.key?(:base_dir)
|
44
|
+
|
45
|
+
# Preserve attributes that are safe to share
|
46
|
+
if user_options[:attributes].nil? && respond_to?(:safe_shared_attributes)
|
47
|
+
options[:attributes] = safe_shared_attributes
|
48
|
+
end
|
49
|
+
|
50
|
+
options
|
51
|
+
end
|
52
|
+
|
53
|
+
# Define attributes that are safe to share between converter instances
|
54
|
+
def safe_shared_attributes
|
55
|
+
# Only include read-only or configuration attributes
|
56
|
+
# Avoid any attributes that could cause state pollution
|
57
|
+
{
|
58
|
+
'source-highlighter' => 'html-pipeline', # Use simple highlighter
|
59
|
+
'nofooter' => '',
|
60
|
+
'no-header-footer' => ''
|
61
|
+
}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -27,7 +27,7 @@ module Metanorma
|
|
27
27
|
def isorefmatchescode(match, _item)
|
28
28
|
code = analyse_ref_code(match[:code])
|
29
29
|
yr = norm_year(match[:year])
|
30
|
-
{ code: match[:code], year: yr, match:,
|
30
|
+
{ code: match[:code], year: yr, match:, fn: match[:fn],
|
31
31
|
title: match[:text], usrlbl: match[:usrlbl] || code[:usrlabel],
|
32
32
|
analyse_code: code, lang: @lang || :all }
|
33
33
|
end
|
@@ -58,6 +58,14 @@ module Metanorma
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
def ref_fn(match, xml)
|
62
|
+
if match.names.include?("fn") && match[:fn]
|
63
|
+
xml.note(**plaintxt.merge(type: "Unpublished-Status")) do |p|
|
64
|
+
p << match[:fn].to_s
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
61
69
|
def isorefmatches2_1(xml, match, code)
|
62
70
|
xml.bibitem **attr_code(ref_attributes(match)) do |t|
|
63
71
|
isorefrender1(t, match, code, "--")
|
@@ -65,11 +73,7 @@ module Metanorma
|
|
65
73
|
d.on "--"
|
66
74
|
end
|
67
75
|
iso_publisher(t, match[:code])
|
68
|
-
|
69
|
-
t.note(**plaintxt.merge(type: "Unpublished-Status")) do |p|
|
70
|
-
p << match[:fn].to_s
|
71
|
-
end
|
72
|
-
end
|
76
|
+
ref_fn(match, t)
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
@@ -97,11 +101,7 @@ module Metanorma
|
|
97
101
|
isorefrender1(t, match, code, year, " (all parts)")
|
98
102
|
conditional_date(t, match, year == "--")
|
99
103
|
iso_publisher(t, match[:code])
|
100
|
-
|
101
|
-
t.note(**plaintxt.merge(type: "Unpublished-Status")) do |p|
|
102
|
-
p << match[:fn].to_s
|
103
|
-
end
|
104
|
-
end
|
104
|
+
ref_fn(match, t)
|
105
105
|
t.extent type: "part" do |e|
|
106
106
|
e.referenceFrom "all"
|
107
107
|
end
|
@@ -137,6 +137,7 @@ module Metanorma
|
|
137
137
|
/^\d+$|^\(.+\)$/.match?(code[:id]) or
|
138
138
|
docnumber(t, code[:id]&.sub(/[:-](19|20)[0-9][0-9]$/, ""))
|
139
139
|
conditional_date(t, yr_match || match, false)
|
140
|
+
ref_fn(match, t)
|
140
141
|
end
|
141
142
|
end
|
142
143
|
|
@@ -165,11 +166,11 @@ module Metanorma
|
|
165
166
|
def refitem1code(_item, match)
|
166
167
|
code = analyse_ref_code(match[:code])
|
167
168
|
((code[:id] && code[:numeric]) || code[:nofetch]) and
|
168
|
-
return { code: nil, match:, analyse_code: code,
|
169
|
+
return { code: nil, match:, analyse_code: code, fn: match[:fn],
|
169
170
|
hidden: code[:hidden] }
|
170
171
|
{ code: code[:id], analyse_code: code, localfile: code[:localfile],
|
171
172
|
year: (m = refitem1yr(code[:id])) ? m[:year] : nil,
|
172
|
-
title: match[:text], match:, hidden: code[:hidden],
|
173
|
+
title: match[:text], match:, hidden: code[:hidden], fn: match[:fn],
|
173
174
|
usrlbl: match[:usrlbl] || code[:usrlabel], lang: @lang || :all }
|
174
175
|
end
|
175
176
|
|
@@ -195,7 +195,7 @@ module Metanorma
|
|
195
195
|
def smart_render_xml(xml, code, opts)
|
196
196
|
xml.respond_to? :to_xml or return nil
|
197
197
|
xml = Nokogiri::XML(xml.to_xml(lang: opts[:lang]))
|
198
|
-
emend_biblio(xml, code, opts
|
198
|
+
emend_biblio(xml, code, opts)
|
199
199
|
xml.xpath("//date").each { |d| Metanorma::Utils::endash_date(d) }
|
200
200
|
xml.traverse do |n|
|
201
201
|
n.text? and n.replace(Metanorma::Utils::smartformat(n.text))
|
@@ -53,10 +53,11 @@ module Metanorma
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def emend_biblio(xml, code,
|
56
|
+
def emend_biblio(xml, code, opts)
|
57
57
|
emend_biblio_id(xml, code)
|
58
|
-
emend_biblio_title(xml, code, title)
|
59
|
-
emend_biblio_usrlbl(xml, usrlbl)
|
58
|
+
emend_biblio_title(xml, code, opts[:title])
|
59
|
+
emend_biblio_usrlbl(xml, opts[:usrlbl])
|
60
|
+
emend_biblio_fn(xml, opts[:fn])
|
60
61
|
end
|
61
62
|
|
62
63
|
def emend_biblio_id(xml, code)
|
@@ -86,6 +87,11 @@ module Metanorma
|
|
86
87
|
xml.at("/bibitem/docidentifier").next =
|
87
88
|
"<docidentifier type='metanorma'>#{mn_code(usrlbl)}</docidentifier>"
|
88
89
|
end
|
90
|
+
|
91
|
+
def emend_biblio_fn(xml, fnote)
|
92
|
+
fnote or return
|
93
|
+
xml.root << "<note type='Unpublished-Status'><p>#{fnote}</p></note>"
|
94
|
+
end
|
89
95
|
end
|
90
96
|
end
|
91
97
|
end
|
@@ -53,7 +53,8 @@ module Metanorma
|
|
53
53
|
ISO_REF =
|
54
54
|
%r{^<ref\sid="(?<anchor>[^"]+)">
|
55
55
|
\[(?<usrlbl>\(.+\))?(?<code>(?:ISO|IEC)[^0-9]*\s[0-9-]+|IEV)
|
56
|
-
(?::(?<year>[0-9][0-9-]+))?\]</ref>,?\s*
|
56
|
+
(?::(?<year>[0-9][0-9-]+))?\]</ref>,?\s*
|
57
|
+
(?:<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>)?\s*(?<text>.*)$}xm
|
57
58
|
|
58
59
|
ISO_REF_NO_YEAR =
|
59
60
|
%r{^<ref\sid="(?<anchor>[^"]+)">
|
@@ -70,10 +71,12 @@ module Metanorma
|
|
70
71
|
|
71
72
|
# These regexes allow () inside usrlbl but not inside code
|
72
73
|
NON_ISO_REF = %r{^<ref\sid="(?<anchor>[^"]+)">
|
73
|
-
\[(?<usrlbl>\(.+\))?(?<code
|
74
|
+
\[(?<usrlbl>\(.+\))?(?<code>.+)\]</ref>,?\s*
|
75
|
+
(?:<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>)?(?<text>.*)$}xm
|
74
76
|
|
75
77
|
NON_ISO_REF1 = %r{^<ref\sid="(?<anchor>[^"]+)">
|
76
|
-
(?<usrlbl>\(.+\))?(?<code
|
78
|
+
(?<usrlbl>\(.+\))?(?<code>.+)</ref>,?\s*
|
79
|
+
(?:<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>\s*)?(?<text>.*)$}xm
|
77
80
|
end
|
78
81
|
end
|
79
82
|
end
|
@@ -16,11 +16,19 @@ module Metanorma
|
|
16
16
|
@spans[:docid] = override_docids(ids[:docid], @spans[:docid])
|
17
17
|
end
|
18
18
|
|
19
|
+
# override old values with new values if type is the same
|
20
|
+
# comparison is case-insensitive
|
21
|
+
# if types differ in case, use the old value's type, not the new
|
19
22
|
def override_docids(old, new)
|
20
23
|
ret = new
|
21
|
-
keys = new.map { |a| a[:type] }
|
24
|
+
keys = new.map { |a| a[:type]&.upcase }
|
22
25
|
old.each do |e|
|
23
|
-
keys.include?(e[:type])
|
26
|
+
if keys.include?(e[:type]&.upcase)
|
27
|
+
ret.each do |a|
|
28
|
+
a[:type]&.upcase == e[:type]&.upcase and a[:type] = e[:type]
|
29
|
+
end
|
30
|
+
else ret << e
|
31
|
+
end
|
24
32
|
end
|
25
33
|
ret
|
26
34
|
end
|
@@ -119,7 +119,7 @@ module Metanorma
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def spans_preprocess_new_contrib?(span, contrib)
|
122
|
-
contrib.empty? ||
|
122
|
+
contrib.empty? || contrib[-1][:entity] == "organization" ||
|
123
123
|
(span[:key] == "surname" && contrib[-1][:surname]) ||
|
124
124
|
contrib[-1][:role] != (span[:type] || "author")
|
125
125
|
end
|
@@ -43,9 +43,11 @@ module Metanorma
|
|
43
43
|
%(id = "_#{UUIDTools::UUID.random_create}")
|
44
44
|
end
|
45
45
|
|
46
|
-
def csv_split(text, delim = ";")
|
47
|
-
Metanorma::Utils::csv_split(@c.decode(text), delim)
|
48
|
-
|
46
|
+
def csv_split(text, delim = ";", encode: true)
|
47
|
+
ret = Metanorma::Utils::csv_split(@c.decode(text), delim)
|
48
|
+
encode and
|
49
|
+
ret.map! { |x| @c.encode(x, :basic, :hexadecimal) }
|
50
|
+
ret
|
49
51
|
end
|
50
52
|
|
51
53
|
# quoted strings: key="va,lue",
|
@@ -153,7 +155,7 @@ module Metanorma
|
|
153
155
|
|
154
156
|
#{text}
|
155
157
|
ADOC
|
156
|
-
c =
|
158
|
+
c = isolated_asciidoctor_convert(doc, backend: flavour, header_footer: true)
|
157
159
|
ret = Nokogiri::XML(c).at("//xmlns:sections")
|
158
160
|
separate_numbering_footnotes(ret)
|
159
161
|
end
|
data/metanorma-standoc.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
33
33
|
spec.add_dependency "crass", "~> 1.0.0"
|
34
34
|
spec.add_dependency "iev", "~> 0.3.5"
|
35
|
-
spec.add_dependency "isodoc", "~> 3.
|
35
|
+
spec.add_dependency "isodoc", "~> 3.3.0"
|
36
36
|
spec.add_dependency "metanorma", ">= 1.6.0"
|
37
37
|
spec.add_dependency "metanorma-plugin-glossarist", "~> 0.2.3"
|
38
38
|
spec.add_dependency "metanorma-plugin-lutaml", "~> 0.7.31"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-standoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-09-
|
11
|
+
date: 2025-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 3.
|
75
|
+
version: 3.3.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 3.
|
82
|
+
version: 3.3.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: metanorma
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -501,6 +501,7 @@ files:
|
|
501
501
|
- lib/metanorma/standoc/cleanup.rb
|
502
502
|
- lib/metanorma/standoc/cleanup_amend.rb
|
503
503
|
- lib/metanorma/standoc/cleanup_asciibib.rb
|
504
|
+
- lib/metanorma/standoc/cleanup_attachment.rb
|
504
505
|
- lib/metanorma/standoc/cleanup_bibdata.rb
|
505
506
|
- lib/metanorma/standoc/cleanup_bibitem.rb
|
506
507
|
- lib/metanorma/standoc/cleanup_block.rb
|
@@ -528,11 +529,13 @@ files:
|
|
528
529
|
- lib/metanorma/standoc/front.rb
|
529
530
|
- lib/metanorma/standoc/front_committee.rb
|
530
531
|
- lib/metanorma/standoc/front_contributor.rb
|
532
|
+
- lib/metanorma/standoc/front_ext.rb
|
531
533
|
- lib/metanorma/standoc/front_organisation.rb
|
532
534
|
- lib/metanorma/standoc/init.rb
|
533
535
|
- lib/metanorma/standoc/inline.rb
|
534
536
|
- lib/metanorma/standoc/isodoc-compile.rng
|
535
537
|
- lib/metanorma/standoc/isodoc.rng
|
538
|
+
- lib/metanorma/standoc/isolated_converter.rb
|
536
539
|
- lib/metanorma/standoc/lists.rb
|
537
540
|
- lib/metanorma/standoc/localbib.rb
|
538
541
|
- lib/metanorma/standoc/macros.rb
|