metanorma-standoc 1.0.1 → 1.0.2
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/biblio.rng +7 -3
- data/lib/asciidoctor/standoc/cleanup_ref.rb +7 -4
- data/lib/asciidoctor/standoc/ref.rb +19 -9
- data/lib/asciidoctor/standoc/section.rb +1 -1
- data/lib/asciidoctor/standoc/version.rb +1 -1
- data/spec/asciidoctor-standoc/cleanup_spec.rb +9 -3
- data/spec/asciidoctor-standoc/refs_spec.rb +20 -8
- data/spec/asciidoctor-standoc/section_spec.rb +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: 7d40164559c6167d8a76a56feec14ad218ad6b3151419dd7f5069859daf39945
|
4
|
+
data.tar.gz: 55b683b4abb435f27648c042092526121b9235cebe9dfc95ce633efe9af3e057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94f95a9f73f40f7037fccda3c15f7608e570f3cef8903aa3f11e4540d370bf9f84809dd2566fdf27106a263c5cf16fcef2757be434ff9d85f7ee424224240012
|
7
|
+
data.tar.gz: 17579d0d6cd9d1401a847d0cc9fe519a95b6708d181f621a8592b615d2b09ef9376452c20aa8e8baaa55ca3b6630a1a28c26dc38d557304f10086ab369b23188
|
@@ -384,7 +384,7 @@
|
|
384
384
|
</define>
|
385
385
|
<define name="LocalityType">
|
386
386
|
<data type="string">
|
387
|
-
<param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|example|volume|issue|locality:[a-zA-Z0-9_]+</param>
|
387
|
+
<param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|locality:[a-zA-Z0-9_]+</param>
|
388
388
|
</data>
|
389
389
|
</define>
|
390
390
|
<define name="referenceFrom">
|
@@ -700,8 +700,12 @@
|
|
700
700
|
<ref name="btitle"/>
|
701
701
|
<ref name="formattedref"/>
|
702
702
|
</choice>
|
703
|
-
<
|
704
|
-
|
703
|
+
<optional>
|
704
|
+
<ref name="bplace"/>
|
705
|
+
</optional>
|
706
|
+
<optional>
|
707
|
+
<ref name="seriesorganization"/>
|
708
|
+
</optional>
|
705
709
|
<optional>
|
706
710
|
<ref name="abbreviation"/>
|
707
711
|
</optional>
|
@@ -6,7 +6,7 @@ module Asciidoctor
|
|
6
6
|
# extending localities to cover ISO referencing
|
7
7
|
LOCALITY_REGEX_STR = <<~REGEXP.freeze
|
8
8
|
^((?<locality>section|clause|part|paragraph|chapter|page|
|
9
|
-
table|annex|figure|example|note|formula|
|
9
|
+
table|annex|figure|example|note|formula|list|
|
10
10
|
locality:[^ \\t\\n\\r:,]+)(\\s+|=)
|
11
11
|
(?<ref>[^"][^ \\t\\n,:-]*|"[^"]+")
|
12
12
|
(-(?<to>[^"][^ \\t\\n,:-]*|"[^"]"))?|
|
@@ -115,10 +115,12 @@ module Asciidoctor
|
|
115
115
|
def reference_names(xmldoc)
|
116
116
|
xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
|
117
117
|
isopub = ref.at(ISO_PUBLISHER_XPATH)
|
118
|
-
docid = ref.at("./docidentifier")
|
118
|
+
docid = ref.at("./docidentifier[not(@type = 'DOI')]")
|
119
119
|
date = ref.at("./date[@type = 'published']")
|
120
|
+
allparts = ref.at("./allparts")
|
120
121
|
reference = format_ref(docid.text, isopub)
|
121
122
|
reference += ":#{date_range(date)}" if date
|
123
|
+
reference += " (all parts)" if allparts
|
122
124
|
@anchors[ref["id"]] = { xref: reference }
|
123
125
|
end
|
124
126
|
end
|
@@ -129,11 +131,12 @@ module Asciidoctor
|
|
129
131
|
# <locality type="clause"><referenceFrom>101-01-01</referenceFrom></locality></eref>
|
130
132
|
def linksIev2iec60050part(xmldoc)
|
131
133
|
parts = Set.new()
|
132
|
-
xmldoc.xpath("//eref[@citeas = 'IEC 60050'] |
|
134
|
+
xmldoc.xpath("//eref[@citeas = 'IEC 60050:2011'] | "\
|
135
|
+
"//origin[@citeas = 'IEC 60050:2011']").each do |x|
|
133
136
|
cl = x&.at("./locality[@type = 'clause']/referenceFrom")&.text || next
|
134
137
|
m = /^(\d+)/.match cl || next
|
135
138
|
parts << m[0]
|
136
|
-
x["citeas"]
|
139
|
+
x["citeas"] = x["citeas"].sub(/60050/, "60050-#{m[0]}")
|
137
140
|
end
|
138
141
|
parts
|
139
142
|
end
|
@@ -58,29 +58,39 @@ module Asciidoctor
|
|
58
58
|
t.title(**plaintxt) { |i| i << ref_normalise(m[:text]) }
|
59
59
|
t.docidentifier m[:code]
|
60
60
|
t.date **{ type: "published" } do |d|
|
61
|
-
d.on "--"
|
61
|
+
d.on "--"
|
62
62
|
end
|
63
63
|
iso_publisher(t, m[:code])
|
64
64
|
t.note(**plaintxt) { |p| p << "ISO DATE: #{m[:fn]}" }
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
def conditional_date(t, m, noyr)
|
69
|
+
m.names.include?("year") and
|
70
|
+
t.date(**{ type: "published" }) do |d|
|
71
|
+
if noyr then d.on "--"
|
72
|
+
else
|
73
|
+
set_date_range(d, m[:year])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
68
78
|
def isorefmatches3(xml, m)
|
69
|
-
hasyr = m.names.include?("year")
|
70
|
-
|
79
|
+
hasyr = m.names.include?("year") && m[:year] != "--"
|
80
|
+
noyr = m.names.include?("year") && m[:year] == "--"
|
81
|
+
ref = fetch_ref xml, m[:code], hasyr ? m[:year] : nil, all_parts: true, no_year: noyr
|
71
82
|
return use_my_anchor(ref, m[:anchor]) if ref
|
72
83
|
xml.bibitem(**attr_code(ref_attributes(m))) do |t|
|
73
84
|
t.title(**plaintxt) { |i| i << ref_normalise(m[:text]) }
|
74
85
|
t.docidentifier "#{m[:code]}"
|
75
|
-
|
76
|
-
t.date(**{ type: "published" }) { |d| set_date_range(d, m[:year]) }
|
86
|
+
conditional_date(t, m, noyr)
|
77
87
|
iso_publisher(t, m[:code])
|
78
|
-
t.
|
88
|
+
t.note(**plaintxt) { |p| p << "ISO DATE: #{m[:fn]}" } if m.names.include?("fn") && m[:fn]
|
89
|
+
t.allparts "true"
|
79
90
|
end
|
80
91
|
end
|
81
92
|
|
82
93
|
def fetch_ref(xml, code, year, **opts)
|
83
|
-
#require "byebug"; byebug
|
84
94
|
hit = @bibdb&.fetch(code, year, opts)
|
85
95
|
return nil if hit.nil?
|
86
96
|
xml.parent.add_child(hit.to_xml)
|
@@ -135,9 +145,9 @@ module Asciidoctor
|
|
135
145
|
<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>,?\s?(?<text>.*)$}xm
|
136
146
|
|
137
147
|
ISO_REF_ALL_PARTS = %r{^<ref\sid="(?<anchor>[^"]+)">
|
138
|
-
\[(?<code>(ISO|IEC)[^0-9]*\s[0-9]+)(:(?<year
|
148
|
+
\[(?<code>(ISO|IEC)[^0-9]*\s[0-9]+)(:(?<year>--|[0-9][0-9-]+))?\s
|
139
149
|
\(all\sparts\)\]</ref>,?\s
|
140
|
-
(?<text>.*)$}xm
|
150
|
+
(<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>,?\s?)?(?<text>.*)$}xm
|
141
151
|
|
142
152
|
NON_ISO_REF = %r{^<ref\sid="(?<anchor>[^"]+)">
|
143
153
|
\[(?<code>[^\]]+?)([:-](?<year>(19|20)[0-9][0-9]))?\]</ref>,?\s
|
@@ -133,7 +133,7 @@ module Asciidoctor
|
|
133
133
|
xml.terms **attr_code(attrs) do |section|
|
134
134
|
section.title { |t| t << term_def_title(toplevel, node) }
|
135
135
|
(s = node.attr("source")) && s.split(/,/).each do |s1|
|
136
|
-
section.termdocsource(nil, **attr_code(bibitemid: s1
|
136
|
+
section.termdocsource(nil, **attr_code(bibitemid: s1))
|
137
137
|
end
|
138
138
|
section << node.content
|
139
139
|
end
|
@@ -790,25 +790,28 @@ r = 1 %</stem>
|
|
790
790
|
<terms id="_" obligation="normative"><title>Terms and definitions</title><term id="_">
|
791
791
|
<preferred>Automation1</preferred>
|
792
792
|
<termsource status="identical">
|
793
|
-
<origin bibitemid="iev" type="inline" citeas="IEC 60050-103"><locality type="clause"><referenceFrom>103-01-02</referenceFrom></locality></origin>
|
793
|
+
<origin bibitemid="iev" type="inline" citeas="IEC 60050-103:2011"><locality type="clause"><referenceFrom>103-01-02</referenceFrom></locality></origin>
|
794
794
|
</termsource>
|
795
795
|
</term>
|
796
796
|
<term id="_">
|
797
797
|
<preferred>Automation2</preferred>
|
798
798
|
<termsource status="identical">
|
799
|
-
<origin bibitemid="iev" type="inline" citeas="IEC 60050-102"><locality type="clause"><referenceFrom>102-01-02</referenceFrom></locality></origin>
|
799
|
+
<origin bibitemid="iev" type="inline" citeas="IEC 60050-102:2011"><locality type="clause"><referenceFrom>102-01-02</referenceFrom></locality></origin>
|
800
800
|
</termsource>
|
801
801
|
</term>
|
802
802
|
<term id="_">
|
803
803
|
<preferred>Automation3</preferred>
|
804
804
|
<termsource status="identical">
|
805
|
-
<origin bibitemid="iev" type="inline" citeas="IEC 60050-103"><locality type="clause"><referenceFrom>103-01-02</referenceFrom></locality></origin>
|
805
|
+
<origin bibitemid="iev" type="inline" citeas="IEC 60050-103:2011"><locality type="clause"><referenceFrom>103-01-02</referenceFrom></locality></origin>
|
806
806
|
</termsource>
|
807
807
|
</term></terms></sections><bibliography><references id="_" obligation="informative">
|
808
808
|
<title>Normative References</title>
|
809
809
|
<bibitem type="international-standard" id="IEC60050-102">
|
810
810
|
<title format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
|
811
811
|
<docidentifier>IEC 60050-102</docidentifier>
|
812
|
+
<date type="published">
|
813
|
+
<on>2011</on>
|
814
|
+
</date>
|
812
815
|
<contributor>
|
813
816
|
<role type="publisher"/>
|
814
817
|
<organization>
|
@@ -836,6 +839,9 @@ r = 1 %</stem>
|
|
836
839
|
</bibitem><bibitem type="international-standard" id="IEC60050-103">
|
837
840
|
<title format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
|
838
841
|
<docidentifier>IEC 60050-103</docidentifier>
|
842
|
+
<date type="published">
|
843
|
+
<on>2011</on>
|
844
|
+
</date>
|
839
845
|
<contributor>
|
840
846
|
<role type="publisher"/>
|
841
847
|
<organization>
|
@@ -332,7 +332,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
332
332
|
<name>ISO</name>
|
333
333
|
</organization>
|
334
334
|
</contributor>
|
335
|
-
<
|
335
|
+
<allparts>true</allparts>
|
336
336
|
</bibitem>
|
337
337
|
</references>
|
338
338
|
</bibliography>
|
@@ -347,16 +347,27 @@ RSpec.describe Asciidoctor::Standoc do
|
|
347
347
|
[bibliography]
|
348
348
|
== Normative References
|
349
349
|
|
350
|
-
* [[[iso123,IETF RFC 8341]]] _Standard_
|
350
|
+
* [[[iso123,IETF RFC 8341]]], _Standard_
|
351
|
+
|
352
|
+
== Clause 4
|
353
|
+
|
354
|
+
<<iso123>>
|
351
355
|
INPUT
|
352
356
|
#{BLANK_HDR}
|
353
357
|
<sections>
|
358
|
+
<clause id="_" inline-header="false" obligation="normative">
|
359
|
+
<title>Clause 4</title>
|
360
|
+
<p id="_">
|
361
|
+
<eref type="inline" bibitemid="iso123" citeas="RFC 8341:2018"/>
|
362
|
+
</p>
|
363
|
+
</clause>
|
354
364
|
|
355
365
|
</sections><bibliography><references id="_" obligation="informative">
|
356
366
|
<title>Normative References</title>
|
357
367
|
<bibitem type="" id="iso123">
|
358
368
|
<title format="text/plain" language="en" script="Latn">Network Configuration Access Control Model</title>
|
359
|
-
<docidentifier>
|
369
|
+
<docidentifier type="DOI">10.17487/RFC8341</docidentifier>
|
370
|
+
<docidentifier type="IETF">RFC 8341</docidentifier>
|
360
371
|
<date type="published">
|
361
372
|
<on>2018</on>
|
362
373
|
</date>
|
@@ -588,19 +599,20 @@ OUTPUT
|
|
588
599
|
end
|
589
600
|
end
|
590
601
|
|
591
|
-
|
602
|
+
def mock_rfcbib_get_rfc8341
|
592
603
|
expect(RfcBib::RfcBibliography).to receive(:get).with("RFC 8341", nil, {}) do
|
593
|
-
|
604
|
+
IsoBibItem.from_xml(<<~"OUTPUT")
|
594
605
|
<bibitem id="RFC8341">
|
595
606
|
<title format="text/plain" language="en" script="Latn">Network Configuration Access Control Model</title>
|
596
|
-
<docidentifier>
|
607
|
+
<docidentifier type="DOI">10.17487/RFC8341</docidentifier>
|
608
|
+
<docidentifier type="IETF">RFC 8341</docidentifier>
|
597
609
|
<date type="published">
|
598
610
|
<on>2018</on>
|
599
611
|
</date>
|
600
612
|
<status>published</status>
|
601
613
|
</bibitem>
|
602
|
-
OUTPUT
|
614
|
+
OUTPUT
|
615
|
+
end
|
603
616
|
end
|
604
|
-
end
|
605
617
|
|
606
618
|
end
|
@@ -298,7 +298,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
298
298
|
|
299
299
|
INPUT
|
300
300
|
#{BLANK_HDR}
|
301
|
-
<termdocsource bibitemid="iso1234"
|
301
|
+
<termdocsource bibitemid="iso1234"/><termdocsource bibitemid="iso5678"/>
|
302
302
|
<preface><foreword obligation="informative">
|
303
303
|
<title>Foreword</title>
|
304
304
|
<p id="_">Foreword</p>
|
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.2
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|