metanorma-standoc 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asciidoctor/standoc/base.rb +1 -0
- data/lib/asciidoctor/standoc/blocks.rb +1 -2
- data/lib/asciidoctor/standoc/cleanup.rb +2 -1
- data/lib/asciidoctor/standoc/cleanup_ref.rb +36 -0
- data/lib/asciidoctor/standoc/isodoc.rng +8 -1
- data/lib/asciidoctor/standoc/ref.rb +1 -0
- data/lib/asciidoctor/standoc/section.rb +7 -6
- data/lib/asciidoctor/standoc/validate.rb +1 -1
- data/lib/asciidoctor/standoc/validate_section.rb +1 -1
- data/lib/asciidoctor/standoc/version.rb +1 -1
- data/spec/asciidoctor-standoc/cleanup_spec.rb +109 -0
- data/spec/asciidoctor-standoc/section_spec.rb +6 -0
- data/spec/examples/rice.sh +1 -1
- 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: 3e25ec1e8d5bc7bd069b096125a76184bd1349bc64bc79a4e5c51f2441d3fb89
|
4
|
+
data.tar.gz: 888e53e4d5a11a260d74a520715c9343cf6d5889430e8491c91a1abf2476e057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0b4f072611604bd9d6859676f98baaa6f09c95d886dbac7e5e21172fa34ccaec156c7560eccbb69a1e9bca784aae39325dce0e82bbbdf64dd0f27d05835b3b2
|
7
|
+
data.tar.gz: 405c4e68f48462b48249cc5d76de89b80b412f546a47992b37bd36ff68cce0a52f0cb82467439e7fe666b3b03fbf102831e17f3fb8b47757b56093627914581d
|
@@ -27,11 +27,12 @@ module Asciidoctor
|
|
27
27
|
biblio_cleanup(xmldoc)
|
28
28
|
reference_names(xmldoc)
|
29
29
|
xref_cleanup(xmldoc)
|
30
|
+
origin_cleanup(xmldoc)
|
31
|
+
iev_cleanup(xmldoc)
|
30
32
|
bpart_cleanup(xmldoc)
|
31
33
|
quotesource_cleanup(xmldoc)
|
32
34
|
para_cleanup(xmldoc)
|
33
35
|
callout_cleanup(xmldoc)
|
34
|
-
origin_cleanup(xmldoc)
|
35
36
|
element_name_cleanup(xmldoc)
|
36
37
|
footnote_renumber(xmldoc)
|
37
38
|
empty_element_cleanup(xmldoc)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "set"
|
2
|
+
|
1
3
|
module Asciidoctor
|
2
4
|
module Standoc
|
3
5
|
module Cleanup
|
@@ -120,6 +122,40 @@ module Asciidoctor
|
|
120
122
|
@anchors[ref["id"]] = { xref: reference }
|
121
123
|
end
|
122
124
|
end
|
125
|
+
|
126
|
+
# converts generic IEV citation to citation of IEC 60050-n
|
127
|
+
# assumes IEV citations are of form
|
128
|
+
# <eref type="inline" bibitemid="a" citeas="IEC 60050">
|
129
|
+
# <locality type="clause"><referenceFrom>101-01-01</referenceFrom></locality></eref>
|
130
|
+
def linksIev2iec60050part(xmldoc)
|
131
|
+
parts = Set.new()
|
132
|
+
xmldoc.xpath("//eref[@citeas = 'IEC 60050'] | //origin[@citeas = 'IEC 60050']").each do |x|
|
133
|
+
cl = x&.at("./locality[@type = 'clause']/referenceFrom")&.text || next
|
134
|
+
m = /^(\d+)/.match cl || next
|
135
|
+
parts << m[0]
|
136
|
+
x["citeas"] += "-#{m[0]}"
|
137
|
+
end
|
138
|
+
parts
|
139
|
+
end
|
140
|
+
|
141
|
+
# replace generic IEV reference with references to all extracted
|
142
|
+
# IEV parts
|
143
|
+
def refsIev2iec60050part(parts, iev)
|
144
|
+
new_iev = ""
|
145
|
+
parts.sort.each do |p|
|
146
|
+
hit = @bibdb&.fetch("IEC 60050-#{p}", nil, keep_year: true)
|
147
|
+
next if hit.nil?
|
148
|
+
new_iev += hit.to_xml
|
149
|
+
end
|
150
|
+
iev.replace(new_iev)
|
151
|
+
end
|
152
|
+
|
153
|
+
# call after xref_cleanup and origin_cleanup
|
154
|
+
def iev_cleanup(xmldoc)
|
155
|
+
iev = xmldoc.at("//bibitem[docidentifier = 'IEC 60050']") || return
|
156
|
+
parts = linksIev2iec60050part(xmldoc)
|
157
|
+
refsIev2iec60050part(parts, iev)
|
158
|
+
end
|
123
159
|
end
|
124
160
|
end
|
125
161
|
end
|
@@ -956,6 +956,11 @@
|
|
956
956
|
</define>
|
957
957
|
<define name="li">
|
958
958
|
<element name="li">
|
959
|
+
<optional>
|
960
|
+
<attribute name="id">
|
961
|
+
<data type="ID"/>
|
962
|
+
</attribute>
|
963
|
+
</optional>
|
959
964
|
<oneOrMore>
|
960
965
|
<ref name="paragraph-with-footnote"/>
|
961
966
|
</oneOrMore>
|
@@ -999,7 +1004,9 @@
|
|
999
1004
|
</define>
|
1000
1005
|
<define name="dt">
|
1001
1006
|
<element name="dt">
|
1002
|
-
<
|
1007
|
+
<zeroOrMore>
|
1008
|
+
<ref name="TextElement"/>
|
1009
|
+
</zeroOrMore>
|
1003
1010
|
</element>
|
1004
1011
|
</define>
|
1005
1012
|
<define name="dd">
|
@@ -21,18 +21,19 @@ module Asciidoctor
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def sectiontype(node)
|
24
|
-
node&.attr("heading")&.downcase || node.title.downcase
|
24
|
+
ret = node&.attr("heading")&.downcase || node.title.downcase
|
25
|
+
return ret if ret == "symbols and abbreviated terms"
|
26
|
+
return nil unless node.level == 1
|
27
|
+
return nil if @seen_headers.include? ret
|
28
|
+
@seen_headers << ret
|
29
|
+
ret
|
25
30
|
end
|
26
31
|
|
27
32
|
def section(node)
|
28
33
|
a = { id: Utils::anchor_or_uuid(node) }
|
29
34
|
noko do |xml|
|
30
35
|
case sectiontype(node)
|
31
|
-
when "introduction" then
|
32
|
-
if node.level == 1 then introduction_parse(a, xml, node)
|
33
|
-
else
|
34
|
-
clause_parse(a, xml, node)
|
35
|
-
end
|
36
|
+
when "introduction" then introduction_parse(a, xml, node)
|
36
37
|
when "normative references" then norm_ref_parse(a, xml, node)
|
37
38
|
when "terms and definitions",
|
38
39
|
"terms, definitions, symbols and abbreviated terms",
|
@@ -13,7 +13,7 @@ module Asciidoctor
|
|
13
13
|
|
14
14
|
def iev_validate(xmldoc)
|
15
15
|
xmldoc.xpath("//term").each do |t|
|
16
|
-
/^
|
16
|
+
/^IEC 60050-/.match(t&.at(".//origin/@citeas")&.text) or next
|
17
17
|
pref = t.xpath("./preferred").inject([]) { |m, x| m << x&.text&.downcase }
|
18
18
|
locality = t.xpath(SOURCELOCALITY)&.text or next
|
19
19
|
iev = @iev.fetch(locality, xmldoc&.at("//language")&.text || "en") or next
|
@@ -29,7 +29,7 @@ module Asciidoctor
|
|
29
29
|
root.xpath("//figure[image][not(title)]").each do |node|
|
30
30
|
style_warning(node, "Figure should have title", nil)
|
31
31
|
end
|
32
|
-
root.xpath("//table[not(
|
32
|
+
root.xpath("//table[not(name)]").each do |node|
|
33
33
|
style_warning(node, "Table should have title", nil)
|
34
34
|
end
|
35
35
|
end
|
@@ -757,4 +757,113 @@ r = 1 %</stem>
|
|
757
757
|
</standard-document>
|
758
758
|
OUTPUT
|
759
759
|
end
|
760
|
+
|
761
|
+
it "separates IEV citations by top-level clause" do
|
762
|
+
system "mv ~/.iev.pstore ~/.iev.pstore1"
|
763
|
+
system "rm test.iev.pstore"
|
764
|
+
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
|
765
|
+
#{CACHED_ISOBIB_BLANK_HDR}
|
766
|
+
|
767
|
+
[bibliography]
|
768
|
+
== Normative References
|
769
|
+
* [[[iev,IEV]]], _iev_
|
770
|
+
|
771
|
+
== Terms and definitions
|
772
|
+
=== Automation1
|
773
|
+
|
774
|
+
[.source]
|
775
|
+
<<iev,clause="103-01-02">>
|
776
|
+
|
777
|
+
=== Automation2
|
778
|
+
|
779
|
+
[.source]
|
780
|
+
<<iev,clause="102-01-02">>
|
781
|
+
|
782
|
+
=== Automation3
|
783
|
+
|
784
|
+
[.source]
|
785
|
+
<<iev,clause="103-01-02">>
|
786
|
+
INPUT
|
787
|
+
#{BLANK_HDR}
|
788
|
+
|
789
|
+
<sections>
|
790
|
+
<terms id="_" obligation="normative"><title>Terms and definitions</title><term id="_">
|
791
|
+
<preferred>Automation1</preferred>
|
792
|
+
<termsource status="identical">
|
793
|
+
<origin bibitemid="iev" type="inline" citeas="IEC 60050-103"><locality type="clause"><referenceFrom>103-01-02</referenceFrom></locality></origin>
|
794
|
+
</termsource>
|
795
|
+
</term>
|
796
|
+
<term id="_">
|
797
|
+
<preferred>Automation2</preferred>
|
798
|
+
<termsource status="identical">
|
799
|
+
<origin bibitemid="iev" type="inline" citeas="IEC 60050-102"><locality type="clause"><referenceFrom>102-01-02</referenceFrom></locality></origin>
|
800
|
+
</termsource>
|
801
|
+
</term>
|
802
|
+
<term id="_">
|
803
|
+
<preferred>Automation3</preferred>
|
804
|
+
<termsource status="identical">
|
805
|
+
<origin bibitemid="iev" type="inline" citeas="IEC 60050-103"><locality type="clause"><referenceFrom>103-01-02</referenceFrom></locality></origin>
|
806
|
+
</termsource>
|
807
|
+
</term></terms></sections><bibliography><references id="_" obligation="informative">
|
808
|
+
<title>Normative References</title>
|
809
|
+
<bibitem type="international-standard" id="IEC60050-102">
|
810
|
+
<title format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
|
811
|
+
<docidentifier>IEC 60050-102</docidentifier>
|
812
|
+
<contributor>
|
813
|
+
<role type="publisher"/>
|
814
|
+
<organization>
|
815
|
+
<name>International Electrotechnical Commission</name>
|
816
|
+
<abbreviation>IEC</abbreviation>
|
817
|
+
<uri>www.iec.ch</uri>
|
818
|
+
</organization>
|
819
|
+
</contributor>
|
820
|
+
<language>en</language>
|
821
|
+
<language>fr</language>
|
822
|
+
<script>Latn</script>
|
823
|
+
<status>
|
824
|
+
<stage>60</stage>
|
825
|
+
</status>
|
826
|
+
<copyright>
|
827
|
+
<from>2018</from>
|
828
|
+
<owner>
|
829
|
+
<organization>
|
830
|
+
<name>International Electrotechnical Commission</name>
|
831
|
+
<abbreviation>IEC</abbreviation>
|
832
|
+
<uri>www.iec.ch</uri>
|
833
|
+
</organization>
|
834
|
+
</owner>
|
835
|
+
</copyright>
|
836
|
+
</bibitem><bibitem type="international-standard" id="IEC60050-103">
|
837
|
+
<title format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
|
838
|
+
<docidentifier>IEC 60050-103</docidentifier>
|
839
|
+
<contributor>
|
840
|
+
<role type="publisher"/>
|
841
|
+
<organization>
|
842
|
+
<name>International Electrotechnical Commission</name>
|
843
|
+
<abbreviation>IEC</abbreviation>
|
844
|
+
<uri>www.iec.ch</uri>
|
845
|
+
</organization>
|
846
|
+
</contributor>
|
847
|
+
<language>en</language>
|
848
|
+
<language>fr</language>
|
849
|
+
<script>Latn</script>
|
850
|
+
<status>
|
851
|
+
<stage>60</stage>
|
852
|
+
</status>
|
853
|
+
<copyright>
|
854
|
+
<from>2018</from>
|
855
|
+
<owner>
|
856
|
+
<organization>
|
857
|
+
<name>International Electrotechnical Commission</name>
|
858
|
+
<abbreviation>IEC</abbreviation>
|
859
|
+
<uri>www.iec.ch</uri>
|
860
|
+
</organization>
|
861
|
+
</owner>
|
862
|
+
</copyright>
|
863
|
+
</bibitem>
|
864
|
+
</references></bibliography>
|
865
|
+
</standard-document>
|
866
|
+
OUTPUT
|
867
|
+
system "mv ~/.iev.pstore1 ~/.iev.pstore"
|
868
|
+
end
|
760
869
|
end
|
@@ -38,6 +38,8 @@ RSpec.describe Asciidoctor::Standoc do
|
|
38
38
|
|
39
39
|
=== Clause 4.2
|
40
40
|
|
41
|
+
== Terms and Definitions
|
42
|
+
|
41
43
|
[appendix]
|
42
44
|
== Annex
|
43
45
|
|
@@ -80,6 +82,10 @@ RSpec.describe Asciidoctor::Standoc do
|
|
80
82
|
<clause id="_" inline-header="false" obligation="normative">
|
81
83
|
<title>Clause 4.2</title>
|
82
84
|
</clause></clause>
|
85
|
+
<clause id="_" inline-header="false" obligation="normative">
|
86
|
+
<title>Terms and Definitions</title>
|
87
|
+
</clause>
|
88
|
+
|
83
89
|
|
84
90
|
</sections><annex id="_" inline-header="false" obligation="normative">
|
85
91
|
<title>Annex</title>
|
data/spec/examples/rice.sh
CHANGED
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.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|