metanorma-iso 1.7.4 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +3 -13
- data/.hound.yml +3 -1
- data/.rubocop.yml +3 -7
- data/lib/asciidoctor/iso/base.rb +14 -11
- data/lib/asciidoctor/iso/biblio.rng +1 -0
- data/lib/asciidoctor/iso/cleanup.rb +40 -24
- data/lib/asciidoctor/iso/front.rb +28 -16
- data/lib/asciidoctor/iso/front_id.rb +66 -50
- data/lib/asciidoctor/iso/isodoc.rng +321 -4
- data/lib/asciidoctor/iso/isostandard-amd.rng +3 -0
- data/lib/asciidoctor/iso/isostandard.rng +12 -0
- data/lib/asciidoctor/iso/section.rb +2 -1
- data/lib/asciidoctor/iso/validate.rb +22 -110
- data/lib/asciidoctor/iso/validate_image.rb +97 -0
- data/lib/asciidoctor/iso/validate_requirements.rb +26 -20
- data/lib/asciidoctor/iso/validate_section.rb +55 -29
- data/lib/asciidoctor/iso/validate_style.rb +36 -24
- data/lib/asciidoctor/iso/validate_title.rb +2 -4
- data/lib/isodoc/iso/base_convert.rb +8 -2
- data/lib/isodoc/iso/html/style-human.css +7 -0
- data/lib/isodoc/iso/html/style-iso.css +7 -0
- data/lib/isodoc/iso/html_convert.rb +0 -1
- data/lib/isodoc/iso/iso.amendment.xsl +680 -198
- data/lib/isodoc/iso/iso.international-standard.xsl +680 -198
- data/lib/isodoc/iso/metadata.rb +1 -0
- data/lib/isodoc/iso/presentation_xml_convert.rb +44 -33
- data/lib/isodoc/iso/sts_convert.rb +10 -13
- data/lib/isodoc/iso/word_convert.rb +0 -1
- data/lib/isodoc/iso/xref.rb +52 -34
- data/lib/metanorma/iso/processor.rb +1 -0
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +7 -7
- data/spec/asciidoctor/base_spec.rb +426 -305
- data/spec/asciidoctor/blocks_spec.rb +96 -34
- data/spec/asciidoctor/cleanup_spec.rb +383 -25
- data/spec/asciidoctor/section_spec.rb +0 -14
- data/spec/asciidoctor/validate_spec.rb +218 -83
- data/spec/isodoc/postproc_spec.rb +481 -438
- data/spec/spec_helper.rb +16 -15
- metadata +46 -46
- data/lib/isodoc/iso/html/scripts.html +0 -178
data/spec/spec_helper.rb
CHANGED
@@ -24,16 +24,14 @@ RSpec.configure do |config|
|
|
24
24
|
c.syntax = :expect
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
=end
|
27
|
+
# config.around do |example|
|
28
|
+
# Dir.mktmpdir("rspec-") do |dir|
|
29
|
+
# tmp_assets = File.join(dir, "spec/assets/")
|
30
|
+
# FileUtils.mkdir_p tmp_assets
|
31
|
+
# FileUtils.cp_r Dir.glob("spec/assets/*"), tmp_assets
|
32
|
+
# Dir.chdir(dir) { example.run }
|
33
|
+
# end
|
34
|
+
# end
|
37
35
|
end
|
38
36
|
|
39
37
|
def strip_guid(xml)
|
@@ -120,22 +118,25 @@ VALIDATING_BLANK_HDR = <<~"HDR".freeze
|
|
120
118
|
:no-isobib:
|
121
119
|
HDR
|
122
120
|
|
123
|
-
ASCIIDOCTOR_ISO_DIR = Pathname
|
121
|
+
ASCIIDOCTOR_ISO_DIR = Pathname
|
122
|
+
.new(File.dirname(__FILE__)) / "../lib/asciidoctor/iso"
|
124
123
|
|
125
124
|
BOILERPLATE =
|
126
125
|
HTMLEntities.new.decode(
|
127
126
|
File.read(ASCIIDOCTOR_ISO_DIR / "boilerplate.xml", encoding: "utf-8")
|
128
|
-
.gsub(/\{\{ agency \}\}/, "ISO")
|
127
|
+
.gsub(/\{\{ agency \}\}/, "ISO")
|
128
|
+
.gsub(/\{\{ docyear \}\}/, Date.today.year.to_s)
|
129
129
|
.gsub(/\{% if unpublished %\}.*\{% endif %\}/m, "")
|
130
|
-
.gsub(/(?<=\p{Alnum})'(?=\p{Alpha})/, "’")
|
130
|
+
.gsub(/(?<=\p{Alnum})'(?=\p{Alpha})/, "’"),
|
131
131
|
)
|
132
132
|
|
133
133
|
BOILERPLATE_FR =
|
134
134
|
HTMLEntities.new.decode(
|
135
135
|
File.read(ASCIIDOCTOR_ISO_DIR / "boilerplate-fr.xml", encoding: "utf-8")
|
136
|
-
.gsub(/\{\{ agency \}\}/, "ISO")
|
136
|
+
.gsub(/\{\{ agency \}\}/, "ISO")
|
137
|
+
.gsub(/\{\{ docyear \}\}/, Date.today.year.to_s)
|
137
138
|
.gsub(/\{% if unpublished %\}.*\{% endif %\}/m, "")
|
138
|
-
.gsub(/(?<=\p{Alnum})'(?=\p{Alpha})/, "’")
|
139
|
+
.gsub(/(?<=\p{Alnum})'(?=\p{Alpha})/, "’"),
|
139
140
|
)
|
140
141
|
|
141
142
|
BLANK_HDR1 = <<~"HDR".freeze
|
metadata
CHANGED
@@ -1,73 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-iso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: ruby-jing
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: isodoc
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - "~>"
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
19
|
+
version: 1.6.2
|
34
20
|
type: :runtime
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
24
|
- - "~>"
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
26
|
+
version: 1.6.2
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: metanorma-standoc
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
33
|
+
version: 1.9.0
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
40
|
+
version: 1.9.0
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
42
|
+
name: mn2sts
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
47
|
+
version: 1.8.0
|
62
48
|
type: :runtime
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
54
|
+
version: 1.8.0
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: ruby-jing
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - ">="
|
@@ -81,27 +67,27 @@ dependencies:
|
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: tokenizer
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
75
|
+
version: 0.3.0
|
90
76
|
type: :runtime
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
82
|
+
version: 0.3.0
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
84
|
+
name: twitter_cldr
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - ">="
|
102
88
|
- !ruby/object:Gem::Version
|
103
89
|
version: '0'
|
104
|
-
type: :
|
90
|
+
type: :runtime
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
@@ -109,19 +95,19 @@ dependencies:
|
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
98
|
+
name: byebug
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
103
|
+
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
|
-
- -
|
108
|
+
- - ">="
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
110
|
+
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: equivalent-xml
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +150,20 @@ dependencies:
|
|
164
150
|
- - "~>"
|
165
151
|
- !ruby/object:Gem::Version
|
166
152
|
version: '4.7'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: iev
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.2.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.2.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rake
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,47 +207,47 @@ dependencies:
|
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: 1.5.2
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
|
-
name:
|
210
|
+
name: sassc
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
|
-
- -
|
213
|
+
- - '='
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version:
|
215
|
+
version: 2.4.0
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
|
-
- -
|
220
|
+
- - '='
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version:
|
222
|
+
version: 2.4.0
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
|
-
name:
|
224
|
+
name: simplecov
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
226
226
|
requirements:
|
227
227
|
- - "~>"
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: '0.
|
229
|
+
version: '0.15'
|
230
230
|
type: :development
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - "~>"
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version: '0.
|
236
|
+
version: '0.15'
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
|
-
name:
|
238
|
+
name: timecop
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
240
240
|
requirements:
|
241
241
|
- - "~>"
|
242
242
|
- !ruby/object:Gem::Version
|
243
|
-
version: 0.
|
243
|
+
version: '0.9'
|
244
244
|
type: :development
|
245
245
|
prerelease: false
|
246
246
|
version_requirements: !ruby/object:Gem::Requirement
|
247
247
|
requirements:
|
248
248
|
- - "~>"
|
249
249
|
- !ruby/object:Gem::Version
|
250
|
-
version: 0.
|
250
|
+
version: '0.9'
|
251
251
|
description: |
|
252
252
|
metanorma-iso lets you write ISO standards in AsciiDoc syntax.
|
253
253
|
|
@@ -294,6 +294,7 @@ files:
|
|
294
294
|
- lib/asciidoctor/iso/reqt.rng
|
295
295
|
- lib/asciidoctor/iso/section.rb
|
296
296
|
- lib/asciidoctor/iso/validate.rb
|
297
|
+
- lib/asciidoctor/iso/validate_image.rb
|
297
298
|
- lib/asciidoctor/iso/validate_requirements.rb
|
298
299
|
- lib/asciidoctor/iso/validate_section.rb
|
299
300
|
- lib/asciidoctor/iso/validate_style.rb
|
@@ -306,7 +307,6 @@ files:
|
|
306
307
|
- lib/isodoc/iso/html/htmlstyle.scss
|
307
308
|
- lib/isodoc/iso/html/isodoc.css
|
308
309
|
- lib/isodoc/iso/html/isodoc.scss
|
309
|
-
- lib/isodoc/iso/html/scripts.html
|
310
310
|
- lib/isodoc/iso/html/style-human.css
|
311
311
|
- lib/isodoc/iso/html/style-human.scss
|
312
312
|
- lib/isodoc/iso/html/style-iso.css
|
@@ -1,178 +0,0 @@
|
|
1
|
-
<script>
|
2
|
-
$("#toc").on('click', 'li', function(e) {
|
3
|
-
$(this).parent().find('li.toc-active').removeClass('toc-active');
|
4
|
-
$(this).addClass('toc-active');
|
5
|
-
});
|
6
|
-
</script>
|
7
|
-
|
8
|
-
<script>
|
9
|
-
//TOC toggle animation
|
10
|
-
$('#toggle').on('click', function(){
|
11
|
-
if( $('nav').is(':visible') ) {
|
12
|
-
$('nav').animate({ 'left': '-353px' }, 'slow', function(){
|
13
|
-
$('nav').hide();
|
14
|
-
});
|
15
|
-
$('body').animate({ 'margin-left': '0' }, 'slow');
|
16
|
-
}
|
17
|
-
else {
|
18
|
-
$('nav').show();
|
19
|
-
$('nav').animate({ 'left': '0px' }, 'slow');
|
20
|
-
$('body').animate({ 'margin-left': '298px' }, 'slow');
|
21
|
-
}
|
22
|
-
});
|
23
|
-
</script>
|
24
|
-
|
25
|
-
<script>
|
26
|
-
// Scroll to top button
|
27
|
-
window.onscroll = function() {scrollFunction()};
|
28
|
-
|
29
|
-
function scrollFunction() {
|
30
|
-
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
|
31
|
-
document.getElementById("myBtn").style.display = "block";
|
32
|
-
} else {
|
33
|
-
document.getElementById("myBtn").style.display = "none";
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
// When the user clicks on the button, scroll to the top of the document
|
38
|
-
function topFunction() {
|
39
|
-
document.body.scrollTop = 0;
|
40
|
-
document.documentElement.scrollTop = 0;
|
41
|
-
}
|
42
|
-
</script>
|
43
|
-
|
44
|
-
<script>
|
45
|
-
/*
|
46
|
-
$(document).ready(function() {
|
47
|
-
$('[id^=toc]').each(function ()
|
48
|
-
{
|
49
|
-
var currentToc = $(this);
|
50
|
-
var url = window.location.href;
|
51
|
-
currentToc.wrap("<a href='" + url + "#" + currentToc.attr("id") + "'></a>");
|
52
|
-
});
|
53
|
-
});
|
54
|
-
*/
|
55
|
-
</script>
|
56
|
-
|
57
|
-
|
58
|
-
<script>
|
59
|
-
|
60
|
-
// jQuery Inline Footnotes v1.0.3
|
61
|
-
// Copyright (c) 2011 Vesa Vänskä, released under the MIT License.
|
62
|
-
|
63
|
-
// Generated by CoffeeScript 1.6.1
|
64
|
-
(function() {
|
65
|
-
|
66
|
-
(function($) {
|
67
|
-
$.inlineFootnote = function(el, options) {
|
68
|
-
var _this = this;
|
69
|
-
this.el = $(el);
|
70
|
-
this.el.data("inlineFootnote", this);
|
71
|
-
this.initialize = function() {
|
72
|
-
this.options = $.extend({}, $.inlineFootnote.defaultOptions, options);
|
73
|
-
this.footnoteId = this.el.attr("href").match(/#(.*)/)[1];
|
74
|
-
if (this.footnoteId) {
|
75
|
-
this.el.mouseenter(this.openBox);
|
76
|
-
return $("body").mousemove(this.closeBox);
|
77
|
-
}
|
78
|
-
};
|
79
|
-
this.openBox = function(event) {
|
80
|
-
var footnoteContent, linkOffset;
|
81
|
-
if (!_this.box) {
|
82
|
-
footnoteContent = $("[id='" + _this.footnoteId + "']").children().filter(":not('" + _this.options.hideFromContent + "')");
|
83
|
-
linkOffset = _this.el.offset();
|
84
|
-
_this.box = $("<div />", {
|
85
|
-
id: _this.options.boxId,
|
86
|
-
html: footnoteContent.clone().find(_this.options.hideFromContent).remove().end(),
|
87
|
-
css: {
|
88
|
-
position: "absolute",
|
89
|
-
top: linkOffset.top,
|
90
|
-
left: linkOffset.left + _this.el.outerWidth()
|
91
|
-
}
|
92
|
-
}).appendTo("body");
|
93
|
-
return _this.positionBox();
|
94
|
-
}
|
95
|
-
};
|
96
|
-
this.closeBox = function(event) {
|
97
|
-
if (_this.box) {
|
98
|
-
if (_this.isHoveringFootnote(event)) {
|
99
|
-
clearTimeout(_this.closeTimeout);
|
100
|
-
return _this.closeTimeout = null;
|
101
|
-
} else {
|
102
|
-
if (!_this.closeTimeout) {
|
103
|
-
return _this.closeTimeout = setTimeout((function() {
|
104
|
-
_this.box.remove();
|
105
|
-
return _this.box = null;
|
106
|
-
}), _this.options.hideDelay);
|
107
|
-
}
|
108
|
-
}
|
109
|
-
}
|
110
|
-
};
|
111
|
-
this.isHoveringFootnote = function(event) {
|
112
|
-
return this.box.is(event.target) || $(event.target).closest(this.box).length > 0 || event.target === this.el[0];
|
113
|
-
};
|
114
|
-
this.positionBox = function() {
|
115
|
-
var boxHorizontalPadding, boxLeft, boxWidth, linkLeftOffset, windowWidth;
|
116
|
-
boxHorizontalPadding = parseInt(this.box.css("padding-left")) + parseInt(this.box.css("padding-right"));
|
117
|
-
linkLeftOffset = this.el.offset().left;
|
118
|
-
windowWidth = $(window).width();
|
119
|
-
if ((windowWidth / 2) > linkLeftOffset) {
|
120
|
-
boxLeft = linkLeftOffset + 20;
|
121
|
-
boxWidth = windowWidth - boxLeft - boxHorizontalPadding - this.options.boxMargin * 2;
|
122
|
-
if (boxWidth > this.options.maximumBoxWidth) {
|
123
|
-
boxWidth = this.options.maximumBoxWidth;
|
124
|
-
}
|
125
|
-
} else {
|
126
|
-
boxWidth = linkLeftOffset - boxHorizontalPadding - this.options.boxMargin * 2;
|
127
|
-
if (boxWidth > this.options.maximumBoxWidth) {
|
128
|
-
boxWidth = this.options.maximumBoxWidth;
|
129
|
-
}
|
130
|
-
boxLeft = linkLeftOffset - boxWidth - this.options.boxMargin * 2;
|
131
|
-
}
|
132
|
-
return this.box.css({
|
133
|
-
width: boxWidth,
|
134
|
-
left: boxLeft
|
135
|
-
});
|
136
|
-
};
|
137
|
-
return this.initialize();
|
138
|
-
};
|
139
|
-
$.inlineFootnote.defaultOptions = {
|
140
|
-
boxMargin: 20,
|
141
|
-
hideDelay: 200,
|
142
|
-
hideFromContent: "[rel=footnote]",
|
143
|
-
maximumBoxWidth: 500,
|
144
|
-
boxId: "footnote_box"
|
145
|
-
};
|
146
|
-
return $.fn.inlineFootnote = function(options) {
|
147
|
-
return this.each(function() {
|
148
|
-
return new $.inlineFootnote(this, options);
|
149
|
-
});
|
150
|
-
};
|
151
|
-
})(jQuery);
|
152
|
-
|
153
|
-
}).call(this);
|
154
|
-
</script>
|
155
|
-
|
156
|
-
<script>
|
157
|
-
$(function() {
|
158
|
-
$("[rel=footnote]").inlineFootnote();
|
159
|
-
});
|
160
|
-
</script>
|
161
|
-
<script>
|
162
|
-
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
|
163
|
-
//
|
164
|
-
// AnchorJS - v4.2.2 - 2020-04-20
|
165
|
-
// https://www.bryanbraun.com/anchorjs/
|
166
|
-
// Copyright (c) 2020 Bryan Braun; Licensed MIT
|
167
|
-
//
|
168
|
-
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
|
169
|
-
!function(A,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():(A.AnchorJS=e(),A.anchors=new A.AnchorJS)}(this,function(){"use strict";return function(A){function f(A){A.icon=A.hasOwnProperty("icon")?A.icon:"",A.visible=A.hasOwnProperty("visible")?A.visible:"hover",A.placement=A.hasOwnProperty("placement")?A.placement:"right",A.ariaLabel=A.hasOwnProperty("ariaLabel")?A.ariaLabel:"Anchor",A.class=A.hasOwnProperty("class")?A.class:"",A.base=A.hasOwnProperty("base")?A.base:"",A.truncate=A.hasOwnProperty("truncate")?Math.floor(A.truncate):64,A.titleText=A.hasOwnProperty("titleText")?A.titleText:""}function p(A){var e;if("string"==typeof A||A instanceof String)e=[].slice.call(document.querySelectorAll(A));else{if(!(Array.isArray(A)||A instanceof NodeList))throw new Error("The selector provided to AnchorJS was invalid.");e=[].slice.call(A)}return e}this.options=A||{},this.elements=[],f(this.options),this.isTouchDevice=function(){return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)},this.add=function(A){var e,t,i,n,o,s,a,r,c,h,l,u,d=[];if(f(this.options),"touch"===(l=this.options.visible)&&(l=this.isTouchDevice()?"always":"hover"),0===(e=p(A=A||"h2, h3, h4, h5, h6")).length)return this;for(!function(){if(null!==document.head.querySelector("style.anchorjs"))return;var A,e=document.createElement("style");e.className="anchorjs",e.appendChild(document.createTextNode("")),void 0===(A=document.head.querySelector('[rel="stylesheet"],style'))?document.head.appendChild(e):document.head.insertBefore(e,A);e.sheet.insertRule(".anchorjs-link{opacity:0;text-decoration:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}",e.sheet.cssRules.length),e.sheet.insertRule(":hover>.anchorjs-link,.anchorjs-link:focus{opacity:1}",e.sheet.cssRules.length),e.sheet.insertRule("[data-anchorjs-icon]::after{content:attr(data-anchorjs-icon)}",e.sheet.cssRules.length),e.sheet.insertRule('@font-face{font-family:anchorjs-icons;src:url(data:n/a;base64,AAEAAAALAIAAAwAwT1MvMg8yG2cAAAE4AAAAYGNtYXDp3gC3AAABpAAAAExnYXNwAAAAEAAAA9wAAAAIZ2x5ZlQCcfwAAAH4AAABCGhlYWQHFvHyAAAAvAAAADZoaGVhBnACFwAAAPQAAAAkaG10eASAADEAAAGYAAAADGxvY2EACACEAAAB8AAAAAhtYXhwAAYAVwAAARgAAAAgbmFtZQGOH9cAAAMAAAAAunBvc3QAAwAAAAADvAAAACAAAQAAAAEAAHzE2p9fDzz1AAkEAAAAAADRecUWAAAAANQA6R8AAAAAAoACwAAAAAgAAgAAAAAAAAABAAADwP/AAAACgAAA/9MCrQABAAAAAAAAAAAAAAAAAAAAAwABAAAAAwBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAMCQAGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAg//0DwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAAIAAAACgAAxAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEADAAAAAIAAgAAgAAACDpy//9//8AAAAg6cv//f///+EWNwADAAEAAAAAAAAAAAAAAAAACACEAAEAAAAAAAAAAAAAAAAxAAACAAQARAKAAsAAKwBUAAABIiYnJjQ3NzY2MzIWFxYUBwcGIicmNDc3NjQnJiYjIgYHBwYUFxYUBwYGIwciJicmNDc3NjIXFhQHBwYUFxYWMzI2Nzc2NCcmNDc2MhcWFAcHBgYjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAAADACWAAEAAAAAAAEACAAAAAEAAAAAAAIAAwAIAAEAAAAAAAMACAAAAAEAAAAAAAQACAAAAAEAAAAAAAUAAQALAAEAAAAAAAYACAAAAAMAAQQJAAEAEAAMAAMAAQQJAAIABgAcAAMAAQQJAAMAEAAMAAMAAQQJAAQAEAAMAAMAAQQJAAUAAgAiAAMAAQQJAAYAEAAMYW5jaG9yanM0MDBAAGEAbgBjAGgAbwByAGoAcwA0ADAAMABAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAP) format("truetype")}',e.sheet.cssRules.length)}(),t=document.querySelectorAll("[id]"),i=[].map.call(t,function(A){return A.id}),o=0;o<e.length;o++)if(this.hasAnchorJSLink(e[o]))d.push(o);else{if(e[o].hasAttribute("id"))n=e[o].getAttribute("id");else if(e[o].hasAttribute("data-anchor-id"))n=e[o].getAttribute("data-anchor-id");else{for(c=r=this.urlify(e[o].textContent),a=0;void 0!==s&&(c=r+"-"+a),a+=1,-1!==(s=i.indexOf(c)););s=void 0,i.push(c),e[o].setAttribute("id",c),n=c}(h=document.createElement("a")).className="anchorjs-link "+this.options.class,h.setAttribute("aria-label",this.options.ariaLabel),h.setAttribute("data-anchorjs-icon",this.options.icon),this.options.titleText&&(h.title=this.options.titleText),u=document.querySelector("base")?window.location.pathname+window.location.search:"",u=this.options.base||u,h.href=u+"#"+n,"always"===l&&(h.style.opacity="1"),""===this.options.icon&&(h.style.font="1em/1 anchorjs-icons","left"===this.options.placement&&(h.style.lineHeight="inherit")),"left"===this.options.placement?(h.style.position="absolute",h.style.marginLeft="-1em",h.style.paddingRight="0.5em",e[o].insertBefore(h,e[o].firstChild)):(h.style.paddingLeft="0.375em",e[o].appendChild(h))}for(o=0;o<d.length;o++)e.splice(d[o]-o,1);return this.elements=this.elements.concat(e),this},this.remove=function(A){for(var e,t,i=p(A),n=0;n<i.length;n++)(t=i[n].querySelector(".anchorjs-link"))&&(-1!==(e=this.elements.indexOf(i[n]))&&this.elements.splice(e,1),i[n].removeChild(t));return this},this.removeAll=function(){this.remove(this.elements)},this.urlify=function(A){return this.options.truncate||f(this.options),A.trim().replace(/\'/gi,"").replace(/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\\n\t\b\v]/g,"-").replace(/-{2,}/g,"-").substring(0,this.options.truncate).replace(/^-+|-+$/gm,"").toLowerCase()},this.hasAnchorJSLink=function(A){var e=A.firstChild&&-1<(" "+A.firstChild.className+" ").indexOf(" anchorjs-link "),t=A.lastChild&&-1<(" "+A.lastChild.className+" ").indexOf(" anchorjs-link ");return e||t||!1}}});
|
170
|
-
// @license-end
|
171
|
-
</script>
|
172
|
-
<script>
|
173
|
-
anchors.options = {
|
174
|
-
placement: 'left'
|
175
|
-
};
|
176
|
-
anchors.add('h1, h2, h3, h4');
|
177
|
-
</script>
|
178
|
-
|