metanorma-standoc 1.10.7 → 1.10.8
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/README.adoc +19 -23
- data/lib/asciidoctor/standoc/base.rb +2 -0
- data/lib/asciidoctor/standoc/basicdoc.rng +21 -4
- data/lib/asciidoctor/standoc/blocks.rb +23 -23
- data/lib/asciidoctor/standoc/blocks_notes.rb +17 -22
- data/lib/asciidoctor/standoc/cleanup_image.rb +6 -7
- data/lib/asciidoctor/standoc/cleanup_inline.rb +25 -0
- data/lib/asciidoctor/standoc/cleanup_ref.rb +5 -0
- data/lib/asciidoctor/standoc/isodoc.rng +192 -50
- data/lib/asciidoctor/standoc/lists.rb +15 -15
- data/lib/asciidoctor/standoc/macros_terms.rb +6 -3
- data/lib/asciidoctor/standoc/reqt.rng +23 -2
- data/lib/asciidoctor/standoc/validate.rb +23 -14
- data/lib/asciidoctor/standoc/validate_section.rb +5 -2
- data/lib/metanorma/standoc/version.rb +1 -1
- data/spec/asciidoctor/blocks_spec.rb +28 -28
- data/spec/asciidoctor/cleanup_spec.rb +83 -90
- data/spec/asciidoctor/lists_spec.rb +6 -6
- data/spec/asciidoctor/macros_spec.rb +1 -1
- data/spec/asciidoctor/refs_spec.rb +2 -2
- data/spec/asciidoctor/validate_spec.rb +28 -0
- data/spec/spec_helper.rb +5 -7
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +41 -41
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +10 -10
- data/spec/vcr_cassettes/isobib_get_123.yml +11 -11
- data/spec/vcr_cassettes/isobib_get_123_1.yml +21 -21
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +29 -29
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +11 -11
- data/spec/vcr_cassettes/isobib_get_124.yml +10 -10
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +64 -44
- 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: 2cc836755aed6cfff989fdcbc9cf8123ccfda29418247d93fdd75ba71660cee7
|
|
4
|
+
data.tar.gz: d1c051429283a6e4153a6a3453b839786561c0975c2acda0586cb0ca787ae26a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e17a3351bf46679b587a82498d5f58d97e43743bd2e6906c929aa8dcbb8ca29fdd6e38acb82252375b40e5fff520f7d6a001b023c9c79681ad61fea949c0799
|
|
7
|
+
data.tar.gz: 01dd1e74b7990b44c526616611155067c0725b0b0bcaeebe9d728c341d26acdab64c2c5be7519b22b94fd641015aec504c333c3b3da8cf6067c19999c20ab0ff
|
data/README.adoc
CHANGED
|
@@ -10,26 +10,24 @@ Gem for serialising the https://github.com/metanorma/metanorma-model-standoc[Met
|
|
|
10
10
|
|
|
11
11
|
== Functionality
|
|
12
12
|
|
|
13
|
-
This gem processes Metanorma
|
|
14
|
-
|
|
15
|
-
to each standards class is refined in the gem specific to that standards class
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
This gem processes Metanorma AsciiDoc input into the Metanorma document model.
|
|
14
|
+
This gem provides underlying generic functionality; behaviour specific
|
|
15
|
+
to each standards class is refined in the gem specific to that standards class
|
|
16
|
+
(e.g. https://github.com/metanorma/metanorma-iso[Metanorma ISO]).
|
|
17
|
+
|
|
18
|
+
The following outputs are generated:
|
|
19
|
+
|
|
20
|
+
* Metanorma semantic XML
|
|
21
|
+
* Metanorma presentation XML
|
|
22
|
+
|
|
23
|
+
These Metanorma XML representations are processed downstream by the `isodoc` gem
|
|
24
|
+
to generate other end deliverables, depending on each standards class.
|
|
24
25
|
|
|
25
26
|
The following input formats are supported:
|
|
26
27
|
|
|
27
|
-
*
|
|
28
|
+
* Metanorma AsciiDoc
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
https://github.com/metanorma/metanorma-iso/blob/master/docs/guidance.adoc[Guidance for authoring].
|
|
31
|
-
https://github.com/metanorma/metanorma-iso/blob/master/docs/quickstart.adoc[Quickstart guide]
|
|
32
|
-
gives a summary overview.
|
|
30
|
+
See the https://www.metanorma.org[Metanorma website] for more information.
|
|
33
31
|
|
|
34
32
|
NOTE: http://asciimath.org[AsciiMathML] is used for mathematical formatting.
|
|
35
33
|
The gem uses the https://github.com/asciidoctor/asciimath[Ruby AsciiMath parser],
|
|
@@ -39,21 +37,19 @@ expressions.
|
|
|
39
37
|
|
|
40
38
|
=== Installation
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
See the https://www.metanorma.org[Metanorma website] for instructions.
|
|
41
|
+
|
|
42
|
+
In the terminal:
|
|
45
43
|
|
|
46
44
|
[source,console]
|
|
47
45
|
----
|
|
48
|
-
$ bash <(curl -s https://raw.githubusercontent.com/metanorma/metanorma-macos-setup/master/metanorma-setup)
|
|
49
46
|
$ gem install metanorma-standoc
|
|
50
47
|
$ gem install metanorma-cli
|
|
51
48
|
----
|
|
52
49
|
|
|
53
|
-
|
|
50
|
+
`metanorma-cli` is the command-line interface for the Metanorma suite
|
|
54
51
|
(incorporating the `metanorma` executable seen above).
|
|
55
52
|
|
|
56
53
|
== Documentation
|
|
57
54
|
|
|
58
|
-
See
|
|
59
|
-
|
|
55
|
+
See the https://www.metanorma.org[Metanorma website] for details.
|
|
@@ -46,6 +46,7 @@ module Asciidoctor
|
|
|
46
46
|
bare: node.attr("bare"),
|
|
47
47
|
sectionsplit: node.attr("sectionsplit"),
|
|
48
48
|
baseassetpath: node.attr("base-asset-path"),
|
|
49
|
+
aligncrosselements: node.attr("align-cross-elements"),
|
|
49
50
|
}
|
|
50
51
|
end
|
|
51
52
|
|
|
@@ -81,6 +82,7 @@ module Asciidoctor
|
|
|
81
82
|
suppressasciimathdup: node.attr("suppress-asciimath-dup"),
|
|
82
83
|
bare: node.attr("bare"),
|
|
83
84
|
baseassetpath: node.attr("base-asset-path"),
|
|
85
|
+
aligncrosselements: node.attr("align-cross-elements"),
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
if font_manifest_file = node.attr("mn2pdf-font-manifest-file")
|
|
@@ -624,6 +624,9 @@
|
|
|
624
624
|
<choice>
|
|
625
625
|
<ref name="PureTextElement"/>
|
|
626
626
|
<ref name="stem"/>
|
|
627
|
+
<ref name="eref"/>
|
|
628
|
+
<ref name="xref"/>
|
|
629
|
+
<ref name="hyperlink"/>
|
|
627
630
|
</choice>
|
|
628
631
|
</zeroOrMore>
|
|
629
632
|
</element>
|
|
@@ -634,6 +637,9 @@
|
|
|
634
637
|
<choice>
|
|
635
638
|
<ref name="PureTextElement"/>
|
|
636
639
|
<ref name="stem"/>
|
|
640
|
+
<ref name="eref"/>
|
|
641
|
+
<ref name="xref"/>
|
|
642
|
+
<ref name="hyperlink"/>
|
|
637
643
|
</choice>
|
|
638
644
|
</zeroOrMore>
|
|
639
645
|
</element>
|
|
@@ -641,7 +647,12 @@
|
|
|
641
647
|
<define name="tt">
|
|
642
648
|
<element name="tt">
|
|
643
649
|
<zeroOrMore>
|
|
644
|
-
<
|
|
650
|
+
<choice>
|
|
651
|
+
<ref name="PureTextElement"/>
|
|
652
|
+
<ref name="eref"/>
|
|
653
|
+
<ref name="xref"/>
|
|
654
|
+
<ref name="hyperlink"/>
|
|
655
|
+
</choice>
|
|
645
656
|
</zeroOrMore>
|
|
646
657
|
</element>
|
|
647
658
|
</define>
|
|
@@ -822,7 +833,9 @@
|
|
|
822
833
|
<attribute name="alt"/>
|
|
823
834
|
</optional>
|
|
824
835
|
<ref name="CitationType"/>
|
|
825
|
-
<
|
|
836
|
+
<oneOrMore>
|
|
837
|
+
<ref name="PureTextElement"/>
|
|
838
|
+
</oneOrMore>
|
|
826
839
|
</define>
|
|
827
840
|
<define name="hyperlink">
|
|
828
841
|
<element name="link">
|
|
@@ -835,7 +848,9 @@
|
|
|
835
848
|
<optional>
|
|
836
849
|
<attribute name="alt"/>
|
|
837
850
|
</optional>
|
|
838
|
-
<
|
|
851
|
+
<oneOrMore>
|
|
852
|
+
<ref name="PureTextElement"/>
|
|
853
|
+
</oneOrMore>
|
|
839
854
|
</element>
|
|
840
855
|
</define>
|
|
841
856
|
<define name="xref">
|
|
@@ -849,7 +864,9 @@
|
|
|
849
864
|
<optional>
|
|
850
865
|
<attribute name="alt"/>
|
|
851
866
|
</optional>
|
|
852
|
-
<
|
|
867
|
+
<oneOrMore>
|
|
868
|
+
<ref name="PureTextElement"/>
|
|
869
|
+
</oneOrMore>
|
|
853
870
|
</element>
|
|
854
871
|
</define>
|
|
855
872
|
<define name="fn">
|
|
@@ -6,14 +6,17 @@ module Asciidoctor
|
|
|
6
6
|
module Standoc
|
|
7
7
|
module Blocks
|
|
8
8
|
def id_attr(node = nil)
|
|
9
|
-
{ id: Metanorma::Utils::anchor_or_uuid(node)
|
|
9
|
+
{ id: Metanorma::Utils::anchor_or_uuid(node),
|
|
10
|
+
tag: node&.attr("tag"),
|
|
11
|
+
"multilingual-rendering": node&.attr("multilingual-rendering") }
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
def id_unnum_attrs(node)
|
|
13
|
-
attr_code(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
attr_code(id_attr(node).merge(
|
|
16
|
+
unnumbered: node.option?("unnumbered") ? "true" : nil,
|
|
17
|
+
number: node.attr("number"),
|
|
18
|
+
subsequence: node.attr("subsequence"),
|
|
19
|
+
))
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
def formula_attrs(node)
|
|
@@ -43,10 +46,9 @@ module Asciidoctor
|
|
|
43
46
|
|
|
44
47
|
def form(node)
|
|
45
48
|
noko do |xml|
|
|
46
|
-
xml.form **attr_code(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
) do |f|
|
|
49
|
+
xml.form **attr_code(id_attr(node)
|
|
50
|
+
.merge(class: node.attr("class"),
|
|
51
|
+
name: node.attr("name"), action: node.attr("action"))) do |f|
|
|
50
52
|
f << node.content
|
|
51
53
|
end
|
|
52
54
|
end
|
|
@@ -78,7 +80,7 @@ module Asciidoctor
|
|
|
78
80
|
|
|
79
81
|
def term_example(node)
|
|
80
82
|
noko do |xml|
|
|
81
|
-
xml.termexample **id_attr(node) do |ex|
|
|
83
|
+
xml.termexample **attr_code(id_attr(node)) do |ex|
|
|
82
84
|
wrap_in_para(node, ex)
|
|
83
85
|
end
|
|
84
86
|
end.join("\n")
|
|
@@ -100,10 +102,11 @@ module Asciidoctor
|
|
|
100
102
|
end
|
|
101
103
|
|
|
102
104
|
def svgmap_attrs(node)
|
|
103
|
-
attr_code(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
attr_code(id_attr(node)
|
|
106
|
+
.merge(id: node.id,
|
|
107
|
+
unnumbered: node.option?("unnumbered") ? "true" : nil,
|
|
108
|
+
number: node.attr("number"),
|
|
109
|
+
subsequence: node.attr("subsequence"))
|
|
107
110
|
.merge(keep_attrs(node)))
|
|
108
111
|
end
|
|
109
112
|
|
|
@@ -162,11 +165,10 @@ module Asciidoctor
|
|
|
162
165
|
end
|
|
163
166
|
|
|
164
167
|
def para_attrs(node)
|
|
165
|
-
attr_code(keep_attrs(node)
|
|
168
|
+
attr_code(id_attr(node).merge(keep_attrs(node)
|
|
166
169
|
.merge(align: node.attr("align"),
|
|
167
170
|
variant_title: node.role == "variant-title" ? true : nil,
|
|
168
|
-
type: node.attr("type")
|
|
169
|
-
id: Metanorma::Utils::anchor_or_uuid(node)))
|
|
171
|
+
type: node.attr("type"))))
|
|
170
172
|
end
|
|
171
173
|
|
|
172
174
|
def paragraph(node)
|
|
@@ -180,9 +182,8 @@ module Asciidoctor
|
|
|
180
182
|
end
|
|
181
183
|
|
|
182
184
|
def quote_attrs(node)
|
|
183
|
-
attr_code(keep_attrs(node)
|
|
184
|
-
.merge(align: node.attr("align")
|
|
185
|
-
id: Metanorma::Utils::anchor_or_uuid(node)))
|
|
185
|
+
attr_code(id_attr(node).merge(keep_attrs(node))
|
|
186
|
+
.merge(align: node.attr("align")))
|
|
186
187
|
end
|
|
187
188
|
|
|
188
189
|
def quote_attribution(node, out)
|
|
@@ -206,12 +207,11 @@ module Asciidoctor
|
|
|
206
207
|
end
|
|
207
208
|
|
|
208
209
|
def listing_attrs(node)
|
|
209
|
-
attr_code(keep_attrs(node)
|
|
210
|
+
attr_code(id_attr(node).merge(keep_attrs(node)
|
|
210
211
|
.merge(lang: node.attr("language"),
|
|
211
|
-
id: Metanorma::Utils::anchor_or_uuid(node),
|
|
212
212
|
unnumbered: node.option?("unnumbered") ? "true" : nil,
|
|
213
213
|
number: node.attr("number"),
|
|
214
|
-
filename: node.attr("filename")))
|
|
214
|
+
filename: node.attr("filename"))))
|
|
215
215
|
end
|
|
216
216
|
|
|
217
217
|
# NOTE: html escaping is performed by Nokogiri
|
|
@@ -2,24 +2,21 @@ module Asciidoctor
|
|
|
2
2
|
module Standoc
|
|
3
3
|
module Blocks
|
|
4
4
|
def termnote_attrs(node)
|
|
5
|
-
attr_code(
|
|
6
|
-
|
|
5
|
+
attr_code(id_attr(node).merge(keep_attrs(node)
|
|
6
|
+
.merge(
|
|
7
7
|
unnumbered: node.attr("unnumbered"),
|
|
8
8
|
number: node.attr("number"),
|
|
9
9
|
subsequence: node.attr("subsequence"),
|
|
10
|
-
"keep-
|
|
11
|
-
|
|
12
|
-
"keep-separate": node.attr("keep-separate")
|
|
13
|
-
)
|
|
14
|
-
)
|
|
10
|
+
"keep-separate": node.attr("keep-separate"),
|
|
11
|
+
)))
|
|
15
12
|
end
|
|
16
13
|
|
|
17
14
|
def note_attrs(node)
|
|
18
15
|
attr_code(
|
|
19
16
|
termnote_attrs(node).merge(
|
|
20
17
|
type: node.attr("type"),
|
|
21
|
-
beforeclauses: node.attr("beforeclauses") == "true" ? "true" : nil
|
|
22
|
-
)
|
|
18
|
+
beforeclauses: node.attr("beforeclauses") == "true" ? "true" : nil,
|
|
19
|
+
),
|
|
23
20
|
)
|
|
24
21
|
end
|
|
25
22
|
|
|
@@ -27,8 +24,8 @@ module Asciidoctor
|
|
|
27
24
|
todo_attrs(node).merge(
|
|
28
25
|
attr_code(
|
|
29
26
|
from: node.attr("from"),
|
|
30
|
-
to: node.attr("to") || node.attr("from")
|
|
31
|
-
)
|
|
27
|
+
to: node.attr("to") || node.attr("from"),
|
|
28
|
+
),
|
|
32
29
|
)
|
|
33
30
|
end
|
|
34
31
|
|
|
@@ -45,11 +42,10 @@ module Asciidoctor
|
|
|
45
42
|
def todo_attrs(node)
|
|
46
43
|
date = node.attr("date") || Date.today.iso8601.gsub(/\+.*$/, "")
|
|
47
44
|
date += "T00:00:00Z" unless /T/.match? date
|
|
48
|
-
attr_code(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)
|
|
45
|
+
attr_code(id_attr(node)
|
|
46
|
+
.merge(reviewer: node.attr("reviewer") || node.attr("source") ||
|
|
47
|
+
"(Unknown)",
|
|
48
|
+
date: date))
|
|
53
49
|
end
|
|
54
50
|
|
|
55
51
|
def todo(node)
|
|
@@ -81,12 +77,11 @@ module Asciidoctor
|
|
|
81
77
|
a = node.attr("type") and ["danger", "safety precautions"].each do |t|
|
|
82
78
|
name = t if a.casecmp(t).zero?
|
|
83
79
|
end
|
|
84
|
-
attr_code(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
beforeclauses: node.attr("beforeclauses") == "true" ? "true" : nil
|
|
88
|
-
)
|
|
89
|
-
)
|
|
80
|
+
attr_code(keep_attrs(node).merge(id_attr(node)
|
|
81
|
+
.merge(
|
|
82
|
+
type: name,
|
|
83
|
+
beforeclauses: node.attr("beforeclauses") == "true" ? "true" : nil,
|
|
84
|
+
)))
|
|
90
85
|
end
|
|
91
86
|
|
|
92
87
|
def admonition(node)
|
|
@@ -15,9 +15,8 @@ module Asciidoctor
|
|
|
15
15
|
def svgmap_moveattrs(xmldoc)
|
|
16
16
|
xmldoc.xpath("//svgmap").each do |s|
|
|
17
17
|
f = s.at(".//figure") or next
|
|
18
|
-
|
|
18
|
+
(t = s.at("./name")) && !f.at("./name") and
|
|
19
19
|
f.children.first.previous = t.remove
|
|
20
|
-
end
|
|
21
20
|
if s["id"] && guid?(f["id"])
|
|
22
21
|
f["id"] = s["id"]
|
|
23
22
|
s.delete("id")
|
|
@@ -26,13 +25,13 @@ module Asciidoctor
|
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
27
|
|
|
29
|
-
def svgmap_moveattrs1(
|
|
28
|
+
def svgmap_moveattrs1(svgmap, figure)
|
|
30
29
|
%w(unnumbered number subsequence keep-with-next
|
|
31
|
-
keep-lines-together).each do |a|
|
|
32
|
-
next if
|
|
30
|
+
keep-lines-together tag multilingual-rendering).each do |a|
|
|
31
|
+
next if figure[a] || !svgmap[a]
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
figure[a] = svgmap[a]
|
|
34
|
+
svgmap.delete(a)
|
|
36
35
|
end
|
|
37
36
|
end
|
|
38
37
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "metanorma-utils"
|
|
2
|
+
require "digest"
|
|
2
3
|
|
|
3
4
|
module Asciidoctor
|
|
4
5
|
module Standoc
|
|
@@ -112,6 +113,7 @@ module Asciidoctor
|
|
|
112
113
|
def anchor_cleanup(elem)
|
|
113
114
|
anchor_cleanup1(elem)
|
|
114
115
|
xreftarget_cleanup(elem)
|
|
116
|
+
contenthash_id_cleanup(elem)
|
|
115
117
|
end
|
|
116
118
|
|
|
117
119
|
def anchor_cleanup1(elem)
|
|
@@ -137,6 +139,29 @@ module Asciidoctor
|
|
|
137
139
|
end
|
|
138
140
|
end
|
|
139
141
|
end
|
|
142
|
+
|
|
143
|
+
def guid?(str)
|
|
144
|
+
/^_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
|
145
|
+
.match?(str)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def contenthash_id_cleanup(doc)
|
|
149
|
+
ids = doc.xpath("//*[@id]").each_with_object({}) do |x, m|
|
|
150
|
+
next unless guid?(x["id"])
|
|
151
|
+
|
|
152
|
+
m[x["id"]] = contenthash(x)
|
|
153
|
+
x["id"] = m[x["id"]]
|
|
154
|
+
end
|
|
155
|
+
[%w(review from), %(review to), %(callout target), %(eref bibitemid),
|
|
156
|
+
%(citation bibitemid), %(xref target), %(xref to)].each do |a|
|
|
157
|
+
doc.xpath("//#{a[0]}").each { |x| ids[a[1]] and x[a[1]] = ids[a[1]] }
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def contenthash(elem)
|
|
162
|
+
Digest::MD5.hexdigest("#{elem.path}////#{elem.text}")
|
|
163
|
+
.sub(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "_\\1-\\2-\\3-\\4-\\5")
|
|
164
|
+
end
|
|
140
165
|
end
|
|
141
166
|
end
|
|
142
167
|
end
|