metanorma-standoc 1.3.18 → 1.3.19
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/asciidoctor/standoc/cleanup_boilerplate.rb +4 -3
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +3 -1
- data/lib/asciidoctor/standoc/cleanup_ref.rb +3 -2
- data/lib/asciidoctor/standoc/cleanup_section.rb +23 -11
- data/lib/asciidoctor/standoc/section.rb +20 -0
- data/lib/asciidoctor/standoc/utils.rb +1 -2
- data/lib/metanorma/standoc/version.rb +1 -1
- data/spec/asciidoctor-standoc/cleanup_spec.rb +8 -0
- data/spec/asciidoctor-standoc/refs_spec.rb +13 -0
- data/spec/asciidoctor-standoc/section_spec.rb +44 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8ed2615aea35bf1ce9472e6b55f99bffd6f918cefb1bd88e4758d5091577d31
|
4
|
+
data.tar.gz: bf4d2b5b381b834127f46a25705fb577705d3b72e55553a0d3de55239029feb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96a49389924a2a96eac3a31d6eb75925e4f9da49fd9030cc40fc17bab7bceac68b24e29359e8e25bf5240da827e35d90194758ba9263277c1c165c7e1862e01c
|
7
|
+
data.tar.gz: 0e1bb4980154384666bec21167709b1363acc2c5a466421f94ca63185fe47f894a79ab20567916ef32abecf0fefce9fc676daa4443cbb73459516c2743fd6206
|
@@ -64,10 +64,11 @@ module Asciidoctor
|
|
64
64
|
|
65
65
|
def boilerplate_cleanup(xmldoc)
|
66
66
|
isodoc = boilerplate_isodoc(xmldoc)
|
67
|
-
|
67
|
+
xmldoc.xpath(self.class::TERM_CLAUSE).each do |f|
|
68
68
|
term_defs_boilerplate(f.at("./title"),
|
69
69
|
xmldoc.xpath(".//termdocsource"),
|
70
70
|
f.at(".//term"), f.at(".//p"), isodoc)
|
71
|
+
end
|
71
72
|
f = xmldoc.at(self.class::NORM_REF) and
|
72
73
|
norm_ref_preface(f)
|
73
74
|
initial_boilerplate(xmldoc, isodoc)
|
@@ -91,14 +92,14 @@ module Asciidoctor
|
|
91
92
|
end
|
92
93
|
|
93
94
|
def boilerplate_file(xmldoc)
|
94
|
-
|
95
|
+
File.join(@libdir, "boilerplate.xml")
|
95
96
|
end
|
96
97
|
|
97
98
|
def boilerplate(xml, conv)
|
98
99
|
file = boilerplate_file(xml)
|
99
100
|
file = File.join(@localdir, @boilerplateauthority) if @boilerplateauthority
|
100
101
|
!file.nil? and File.exists?(file) or return
|
101
|
-
|
102
|
+
conv.populate_template((File.read(file, encoding: "UTF-8")), nil)
|
102
103
|
end
|
103
104
|
|
104
105
|
def bibdata_cleanup(xmldoc)
|
@@ -14,13 +14,15 @@ module Asciidoctor
|
|
14
14
|
c.gsub(/ id="[^"]+"/, "")
|
15
15
|
end
|
16
16
|
|
17
|
-
# include footnotes inside figure
|
17
|
+
# include footnotes inside figure if they are the only content
|
18
|
+
# of the paras following
|
18
19
|
def figure_footnote_cleanup(xmldoc)
|
19
20
|
nomatches = false
|
20
21
|
until nomatches
|
21
22
|
q = "//figure/following-sibling::*[1][self::p and *[1][self::fn]]"
|
22
23
|
nomatches = true
|
23
24
|
xmldoc.xpath(q).each do |s|
|
25
|
+
next if s.children.map { |c| c.text? && /[[:alpha:]]/.match(c.text) }.any?
|
24
26
|
s.previous_element << s.first_element_child.remove
|
25
27
|
s.remove
|
26
28
|
nomatches = false
|
@@ -67,7 +67,7 @@ module Asciidoctor
|
|
67
67
|
|
68
68
|
def omit_docid_prefix(prefix)
|
69
69
|
return true if prefix.nil? || prefix.empty?
|
70
|
-
%(ISO IEC IEV ITU).include? prefix
|
70
|
+
%(ISO IEC IEV ITU metanorma).include? prefix
|
71
71
|
end
|
72
72
|
|
73
73
|
def format_ref(ref, type, isopub)
|
@@ -85,7 +85,8 @@ module Asciidoctor
|
|
85
85
|
def reference_names(xmldoc)
|
86
86
|
xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
|
87
87
|
isopub = ref.at(ISO_PUBLISHER_XPATH)
|
88
|
-
docid = ref.at("./docidentifier[
|
88
|
+
docid = ref.at("./docidentifier[@type = 'metanorma']") ||
|
89
|
+
ref.at("./docidentifier[not(@type = 'DOI')]") or next
|
89
90
|
reference = format_ref(docid.text, docid["type"], isopub)
|
90
91
|
@anchors[ref["id"]] = { xref: reference }
|
91
92
|
end
|
@@ -9,20 +9,29 @@ require "mathml2asciimath"
|
|
9
9
|
module Asciidoctor
|
10
10
|
module Standoc
|
11
11
|
module Cleanup
|
12
|
-
|
13
|
-
if x.at("//foreword | //introduction"
|
12
|
+
def make_preface(x, s)
|
13
|
+
if x.at("//foreword | //introduction | //acknowledgements | "\
|
14
|
+
"//clause[@preface]")
|
14
15
|
preface = s.add_previous_sibling("<preface/>").first
|
15
|
-
|
16
|
-
preface.add_child
|
17
|
-
|
18
|
-
preface.add_child
|
16
|
+
f = x.at("//foreword") and preface.add_child f.remove
|
17
|
+
f = x.at("//introduction") and preface.add_child f.remove
|
18
|
+
move_clauses_into_preface(x, preface)
|
19
|
+
f = x.at("//acknowledgements") and preface.add_child f.remove
|
19
20
|
end
|
20
21
|
make_abstract(x, s)
|
21
22
|
end
|
22
23
|
|
24
|
+
def move_clauses_into_preface(x, preface)
|
25
|
+
x.xpath("//clause[@preface]").each do |c|
|
26
|
+
c.delete("preface")
|
27
|
+
preface.add_child c.remove
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
23
31
|
def make_abstract(x, s)
|
24
32
|
if x.at("//abstract[not(ancestor::bibitem)]")
|
25
|
-
preface = s.at("//preface") ||
|
33
|
+
preface = s.at("//preface") ||
|
34
|
+
s.add_previous_sibling("<preface/>").first
|
26
35
|
abstract = x.at("//abstract[not(ancestor::bibitem)]").remove
|
27
36
|
preface.prepend_child abstract.remove
|
28
37
|
bibabstract = bibabstract_location(x)
|
@@ -39,9 +48,10 @@ module Asciidoctor
|
|
39
48
|
x.at("//bibdata/contributor[not(following-sibling::contributor)]") ||
|
40
49
|
x.at("//bibdata/date[not(following-sibling::date)]") ||
|
41
50
|
x.at("//docnumber") ||
|
42
|
-
x.at("//bibdata/docidentifier
|
43
|
-
|
44
|
-
|
51
|
+
x.at("//bibdata/docidentifier"\
|
52
|
+
"[not(following-sibling::docidentifier)]") ||
|
53
|
+
x.at("//bibdata/uri[not(following-sibling::uri)]") ||
|
54
|
+
x.at("//bibdata/title[not(following-sibling::title)]")
|
45
55
|
end
|
46
56
|
|
47
57
|
def make_bibliography(x, s)
|
@@ -93,7 +103,9 @@ module Asciidoctor
|
|
93
103
|
def obligations_cleanup_info(x)
|
94
104
|
(s = x.at("//foreword")) && s["obligation"] = "informative"
|
95
105
|
(s = x.at("//introduction")) && s["obligation"] = "informative"
|
106
|
+
(s = x.at("//acknowledgements")) && s["obligation"] = "informative"
|
96
107
|
x.xpath("//references").each { |r| r["obligation"] = "informative" }
|
108
|
+
x.xpath("//preface//clause").each { |r| r["obligation"] = "informative" }
|
97
109
|
end
|
98
110
|
|
99
111
|
def obligations_cleanup_norm(x)
|
@@ -109,7 +121,7 @@ module Asciidoctor
|
|
109
121
|
r["obligation"] = "normative" unless r["obligation"]
|
110
122
|
end
|
111
123
|
x.xpath(Utils::SUBCLAUSE_XPATH).each do |r|
|
112
|
-
|
124
|
+
o = r&.at("./ancestor::*/@obligation")&.text and r["obligation"] = o
|
113
125
|
end
|
114
126
|
end
|
115
127
|
|
@@ -61,6 +61,7 @@ module Asciidoctor
|
|
61
61
|
noko do |xml|
|
62
62
|
case sectiontype(node)
|
63
63
|
when "introduction" then introduction_parse(a, xml, node)
|
64
|
+
when "foreword" then foreword_parse(a, xml, node)
|
64
65
|
when "normative references" then norm_ref_parse(a, xml, node)
|
65
66
|
when "terms and definitions"
|
66
67
|
@term_def = true
|
@@ -68,6 +69,8 @@ module Asciidoctor
|
|
68
69
|
@term_def = false
|
69
70
|
when "symbols and abbreviated terms"
|
70
71
|
symbols_parse(a, xml, node)
|
72
|
+
when "acknowledgements"
|
73
|
+
acknowledgements_parse(a, xml, node)
|
71
74
|
when "bibliography" then bibliography_parse(a, xml, node)
|
72
75
|
else
|
73
76
|
if @term_def then term_def_subclause_parse(a, xml, node)
|
@@ -115,6 +118,7 @@ module Asciidoctor
|
|
115
118
|
def clause_parse(attrs, xml, node)
|
116
119
|
attrs["inline-header".to_sym] = node.option? "inline-header"
|
117
120
|
attrs[:bibitem] = true if node.option? "bibitem"
|
121
|
+
attrs[:preface] = true if node.role == "preface" || node.attr("style") == "preface"
|
118
122
|
attrs[:level] = node.attr("level")
|
119
123
|
set_obligation(attrs, node)
|
120
124
|
xml.send "clause", **attr_code(attrs) do |xml_section|
|
@@ -228,6 +232,22 @@ module Asciidoctor
|
|
228
232
|
xml_section << content
|
229
233
|
end
|
230
234
|
end
|
235
|
+
|
236
|
+
def foreword_parse(attrs, xml, node)
|
237
|
+
xml.foreword **attr_code(attrs) do |xml_section|
|
238
|
+
xml_section.title { |t| t << node.title }
|
239
|
+
content = node.content
|
240
|
+
xml_section << content
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def acknowledgements_parse(attrs, xml, node)
|
245
|
+
xml.acknowledgements **attr_code(attrs) do |xml_section|
|
246
|
+
xml_section.title { |t| t << node.title || "Acknowledgements" }
|
247
|
+
content = node.content
|
248
|
+
xml_section << content
|
249
|
+
end
|
250
|
+
end
|
231
251
|
end
|
232
252
|
end
|
233
253
|
end
|
@@ -694,6 +694,8 @@ RSpec.describe Asciidoctor::Standoc do
|
|
694
694
|
footnote:[This is a footnote to a figure]
|
695
695
|
|
696
696
|
footnote:[This is another footnote to a figure]
|
697
|
+
|
698
|
+
A footnote:[This is a third footnote]
|
697
699
|
INPUT
|
698
700
|
#{BLANK_HDR}
|
699
701
|
<sections><figure id="_">
|
@@ -703,6 +705,12 @@ RSpec.describe Asciidoctor::Standoc do
|
|
703
705
|
</fn><fn reference="b">
|
704
706
|
<p id="_">This is another footnote to a figure</p>
|
705
707
|
</fn></figure>
|
708
|
+
<p id='_'>
|
709
|
+
A
|
710
|
+
<fn reference='1'>
|
711
|
+
<p id='_'>This is a third footnote</p>
|
712
|
+
</fn>
|
713
|
+
</p>
|
706
714
|
|
707
715
|
</sections>
|
708
716
|
|
@@ -99,6 +99,10 @@ RSpec.describe Asciidoctor::Standoc do
|
|
99
99
|
mock_isobib_get_123_no_docid_lbl
|
100
100
|
input = <<~"INPUT"
|
101
101
|
#{ISOBIB_BLANK_HDR}
|
102
|
+
|
103
|
+
<<iso123>>
|
104
|
+
<<iso124>>
|
105
|
+
|
102
106
|
[bibliography]
|
103
107
|
== Normative References
|
104
108
|
|
@@ -107,6 +111,15 @@ RSpec.describe Asciidoctor::Standoc do
|
|
107
111
|
INPUT
|
108
112
|
expect(xmlpp(strip_guid(Asciidoctor.convert(input, backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
|
109
113
|
#{BLANK_HDR}
|
114
|
+
<preface>
|
115
|
+
<foreword obligation='informative'>
|
116
|
+
<title>Foreword</title>
|
117
|
+
<p id='_'>
|
118
|
+
<eref type='inline' bibitemid='iso123' citeas='ISO 123'/>
|
119
|
+
<eref type='inline' bibitemid='iso124' citeas='[1]'/>
|
120
|
+
</p>
|
121
|
+
</foreword>
|
122
|
+
</preface>
|
110
123
|
<sections>
|
111
124
|
</sections><bibliography><references id="_" obligation="informative"><title>Normative References</title>
|
112
125
|
#{NORM_REF_BOILERPLATE}
|
@@ -17,6 +17,11 @@ RSpec.describe Asciidoctor::Standoc do
|
|
17
17
|
|
18
18
|
=== Introduction Subsection
|
19
19
|
|
20
|
+
== Acknowledgements
|
21
|
+
|
22
|
+
[.preface]
|
23
|
+
== Dedication
|
24
|
+
|
20
25
|
== Scope
|
21
26
|
|
22
27
|
Text
|
@@ -86,7 +91,14 @@ RSpec.describe Asciidoctor::Standoc do
|
|
86
91
|
<clause id="_" inline-header="false" obligation="informative">
|
87
92
|
<title>Introduction Subsection</title>
|
88
93
|
</clause>
|
89
|
-
</introduction
|
94
|
+
</introduction>
|
95
|
+
<clause id='_' inline-header='false' obligation='informative'>
|
96
|
+
<title>Dedication</title>
|
97
|
+
</clause>
|
98
|
+
<acknowledgements id='_' obligation='informative'>
|
99
|
+
<title>Acknowledgements</title>
|
100
|
+
</acknowledgements>
|
101
|
+
</preface><sections>
|
90
102
|
|
91
103
|
|
92
104
|
<clause id="_" inline-header="false" obligation="normative">
|
@@ -102,7 +114,9 @@ RSpec.describe Asciidoctor::Standoc do
|
|
102
114
|
<preferred>Term1</preferred>
|
103
115
|
</term>
|
104
116
|
</terms>
|
105
|
-
<clause id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title
|
117
|
+
<clause id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title>
|
118
|
+
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
119
|
+
<clause id="_" inline-header="false" obligation="normative">
|
106
120
|
<title>Introduction</title>
|
107
121
|
<clause id="_" inline-header="false" obligation="normative">
|
108
122
|
<title>Intro 1</title>
|
@@ -169,7 +183,8 @@ RSpec.describe Asciidoctor::Standoc do
|
|
169
183
|
it "processes sections with language and script attributes" do
|
170
184
|
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
171
185
|
#{ASCIIDOC_BLANK_HDR}
|
172
|
-
|
186
|
+
[language=en,script=Latn]
|
187
|
+
== Foreword
|
173
188
|
|
174
189
|
Text
|
175
190
|
|
@@ -184,6 +199,13 @@ RSpec.describe Asciidoctor::Standoc do
|
|
184
199
|
[language=en,script=Latn]
|
185
200
|
=== Introduction Subsection
|
186
201
|
|
202
|
+
[language=en,script=Latn]
|
203
|
+
== Acknowledgements
|
204
|
+
|
205
|
+
[.preface]
|
206
|
+
[language=en,script=Latn]
|
207
|
+
== Dedication
|
208
|
+
|
187
209
|
[language=en,script=Latn]
|
188
210
|
== Scope
|
189
211
|
|
@@ -266,7 +288,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
266
288
|
#{BLANK_HDR.sub(/<status>/, "<abstract> <p>Text</p> </abstract><status>")}
|
267
289
|
<preface><abstract id="_" language="en" script="Latn">
|
268
290
|
<p id="_">Text</p>
|
269
|
-
</abstract><foreword obligation=
|
291
|
+
</abstract><foreword id='_' language='en' script='Latn' obligation='informative'>
|
270
292
|
<title>Foreword</title>
|
271
293
|
<p id="_">Text</p>
|
272
294
|
</foreword><introduction id="_" language="en" script="Latn" obligation="informative">
|
@@ -274,7 +296,14 @@ RSpec.describe Asciidoctor::Standoc do
|
|
274
296
|
<clause id="_" language="en" script="Latn" inline-header="false" obligation="informative">
|
275
297
|
<title>Introduction Subsection</title>
|
276
298
|
</clause>
|
277
|
-
</introduction
|
299
|
+
</introduction>
|
300
|
+
<clause id='_' language='en' script='Latn' inline-header='false' obligation='informative'>
|
301
|
+
<title>Dedication</title>
|
302
|
+
</clause>
|
303
|
+
<acknowledgements id='_' language='en' script='Latn' obligation='informative'>
|
304
|
+
<title>Acknowledgements</title>
|
305
|
+
</acknowledgements>
|
306
|
+
</preface><sections>
|
278
307
|
|
279
308
|
|
280
309
|
<clause id="_" language="en" script="Latn" inline-header="false" obligation="normative">
|
@@ -290,7 +319,9 @@ RSpec.describe Asciidoctor::Standoc do
|
|
290
319
|
<preferred>Term1</preferred>
|
291
320
|
</term>
|
292
321
|
</terms>
|
293
|
-
<clause id="_" language="en" script="Latn" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title
|
322
|
+
<clause id="_" language="en" script="Latn" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title>
|
323
|
+
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
324
|
+
<clause id="_" language="en" script="Latn" inline-header="false" obligation="normative">
|
294
325
|
<title>Introduction</title>
|
295
326
|
<clause id="_" inline-header="false" obligation="normative">
|
296
327
|
<title>Intro 1</title>
|
@@ -371,6 +402,9 @@ RSpec.describe Asciidoctor::Standoc do
|
|
371
402
|
|
372
403
|
=== Introduction Subsection
|
373
404
|
|
405
|
+
[heading=acknowledgements]
|
406
|
+
== Ευχαριστίες
|
407
|
+
|
374
408
|
[heading=normative references]
|
375
409
|
== Κανονιστικές Παραπομπές
|
376
410
|
|
@@ -423,6 +457,9 @@ RSpec.describe Asciidoctor::Standoc do
|
|
423
457
|
<title>Introduction Subsection</title>
|
424
458
|
</clause>
|
425
459
|
</introduction>
|
460
|
+
<acknowledgements id='_' obligation='informative'>
|
461
|
+
<title>Ευχαριστίες</title>
|
462
|
+
</acknowledgements>
|
426
463
|
</preface>
|
427
464
|
<sections>
|
428
465
|
<terms id='_' obligation='normative'>
|
@@ -434,6 +471,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
434
471
|
</terms>
|
435
472
|
<clause id='_' obligation='normative'>
|
436
473
|
<title>Terms and definitions</title>
|
474
|
+
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
437
475
|
<terms id='_' obligation='normative'>
|
438
476
|
<title>Normal Terms</title>
|
439
477
|
<term id='_'>
|
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: 1.3.
|
4
|
+
version: 1.3.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|