just-the-docs 0.4.0.rc2 → 0.4.0.rc4
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/CHANGELOG.md +461 -113
- data/README.md +36 -13
- data/_includes/components/aux_nav.html +15 -0
- data/_includes/components/breadcrumbs.html +15 -0
- data/_includes/components/children_nav.html +9 -0
- data/_includes/components/footer.html +34 -0
- data/_includes/components/header.html +11 -0
- data/_includes/components/mermaid.html +5 -0
- data/_includes/components/search_footer.html +7 -0
- data/_includes/components/search_header.html +9 -0
- data/_includes/components/sidebar.html +69 -0
- data/_includes/css/just-the-docs.scss.liquid +2 -1
- data/_includes/head.html +16 -15
- data/_includes/icons/code_copy.html +15 -0
- data/_includes/icons/document.html +6 -0
- data/_includes/icons/expand.html +6 -0
- data/_includes/icons/icons.html +13 -0
- data/_includes/icons/link.html +6 -0
- data/_includes/icons/menu.html +6 -0
- data/_includes/icons/search.html +6 -0
- data/_includes/nav.html +174 -110
- data/_includes/toc_heading_custom.html +1 -0
- data/_includes/vendor/anchor_headings.html +46 -18
- data/_layouts/default.html +11 -196
- data/_layouts/minimal.html +60 -0
- data/_sass/base.scss +15 -10
- data/_sass/buttons.scss +1 -4
- data/_sass/code.scss +85 -26
- data/_sass/labels.scss +1 -4
- data/_sass/layout.scss +1 -2
- data/_sass/navigation.scss +4 -14
- data/_sass/search.scss +9 -20
- data/_sass/tables.scss +1 -4
- data/assets/js/just-the-docs.js +44 -1
- data/assets/js/vendor/lunr.min.js +58 -3
- metadata +21 -4
- data/_includes/favicon.html +0 -1
data/_includes/nav.html
CHANGED
|
@@ -1,74 +1,167 @@
|
|
|
1
1
|
{%- comment -%}
|
|
2
|
-
|
|
2
|
+
The `nav_order` values of pages affect the order in which they are shown in
|
|
3
|
+
the navigation panel and in the automatically generated tables of contents.
|
|
4
|
+
Sibling pages with the same `nav_order` value may be shown in any order.
|
|
5
|
+
Sibling pages with no `nav_order` value are shown after all pages that have
|
|
6
|
+
explicit `nav_order` values, ordered by their `title` values.
|
|
3
7
|
|
|
4
|
-
The
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
The `nav_order` and `title` values can be numbers or strings. To avoid build
|
|
9
|
+
failures, we sort numbers and strings separately. We sort numbers by their
|
|
10
|
+
values, and strings lexicographically. The case-sensitivity of string sorting
|
|
11
|
+
is determined by the configuration setting of `nav_sort`. Pages with no `title`
|
|
12
|
+
value are excluded from the navigation.
|
|
13
|
+
|
|
14
|
+
Note: Numbers used as `title` or `nav_order` values should not be in quotes,
|
|
15
|
+
unless you intend them to be lexicographically ordered. Numbers are written
|
|
16
|
+
without spaces or thousands-separators. Negative numbers are preceded by `-`.
|
|
17
|
+
Floats are written with the integral and fractional parts separated by `.`.
|
|
18
|
+
(Bounds on the magnitude and precision are presumably the same as in Liquid.)
|
|
19
|
+
{%- endcomment -%}
|
|
7
20
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
(except that a numerical `title` value is treated as a string).
|
|
21
|
+
{%- assign title_pages = include.pages
|
|
22
|
+
| where_exp: "item", "item.title != nil" -%}
|
|
11
23
|
|
|
12
|
-
|
|
24
|
+
{%- comment -%}
|
|
25
|
+
A page with `nav_exclude: true` does not appear in the main navigation.
|
|
26
|
+
If it has a `parent`, it may appear in the parent's table of contents.
|
|
27
|
+
If it specifies `has_children: true`, it should appear in the breadcrumbs
|
|
28
|
+
of the child pages, but its order in relation to other pages is irrelevant.
|
|
29
|
+
Pages that never appear can be removed from the pages that need to be sorted.
|
|
30
|
+
This optimisation can be significant on a site with many pages.
|
|
31
|
+
|
|
32
|
+
In Jekyll 4, the pages to be sorted can be filtered by:
|
|
33
|
+
|
|
34
|
+
{%- assign title_pages = title_pages
|
|
35
|
+
| where_exp: "item", "item.nav_exclude != true or item.parent != nil" -%}
|
|
36
|
+
|
|
37
|
+
That filter is not allowed in Jekyll 3. The following iterative code gives the
|
|
38
|
+
same effect, but it is activated only when it will filter more than 50% of the
|
|
39
|
+
pages.
|
|
13
40
|
{%- endcomment -%}
|
|
14
41
|
|
|
15
|
-
{%-
|
|
16
|
-
|
|
42
|
+
{%- unless title_pages == empty -%}
|
|
43
|
+
{%- assign unsorted_pages = title_pages
|
|
44
|
+
| where_exp: "item", "item.parent == nil"
|
|
45
|
+
| where_exp: "item", "item.nav_exclude == true" -%}
|
|
46
|
+
{%- assign title_pages_size = title_pages.size -%}
|
|
47
|
+
{%- assign unsorted_pages_percent = unsorted_pages.size
|
|
48
|
+
| times: 100 | divided_by: title_pages_size -%}
|
|
49
|
+
{%- if unsorted_pages_percent > 50 -%}
|
|
50
|
+
{%- assign sorted_pages = "" | split: "" -%}
|
|
51
|
+
{%- for item in title_pages -%}
|
|
52
|
+
{%- if item.nav_exclude != true or item.parent -%}
|
|
53
|
+
{%- assign sorted_pages = sorted_pages | push: item -%}
|
|
54
|
+
{%- endif -%}
|
|
55
|
+
{%- endfor -%}
|
|
56
|
+
{%- assign title_pages = sorted_pages -%}
|
|
57
|
+
{%- endif -%}
|
|
58
|
+
{%- endunless -%}
|
|
17
59
|
|
|
18
|
-
{%- assign
|
|
60
|
+
{%- assign nav_order_pages = title_pages
|
|
61
|
+
| where_exp: "item", "item.nav_order != nil" -%}
|
|
62
|
+
{%- assign title_order_pages = title_pages
|
|
19
63
|
| where_exp: "item", "item.nav_order == nil" -%}
|
|
20
|
-
{%- assign nav_ordered_pages = titled_pages
|
|
21
|
-
| where_exp: "item", "item.nav_order != nil" -%}
|
|
22
64
|
|
|
23
65
|
{%- comment -%}
|
|
24
|
-
|
|
25
|
-
|
|
66
|
+
Divide the arrays of `nav_order_pages` and `title_order_pages` according to
|
|
67
|
+
the type of value.
|
|
26
68
|
|
|
27
|
-
The first character of the `jsonify`
|
|
69
|
+
The first character of the result of `jsonify` is `"` only for strings.
|
|
70
|
+
Grouping by a single character also ensures the number of groups is small.
|
|
28
71
|
{%- endcomment -%}
|
|
29
72
|
|
|
30
|
-
{%- assign
|
|
73
|
+
{%- assign nav_number_pages = "" | split: "" -%}
|
|
74
|
+
{%- assign nav_string_pages = "" | split: "" -%}
|
|
75
|
+
{%- assign nav_order_groups = nav_order_pages
|
|
31
76
|
| group_by_exp: "item", "item.nav_order | jsonify | slice: 0" -%}
|
|
77
|
+
{%- for group in nav_order_groups -%}
|
|
78
|
+
{%- if group.name == '"' -%}
|
|
79
|
+
{%- assign nav_string_pages = group.items -%}
|
|
80
|
+
{%- else -%}
|
|
81
|
+
{%- assign nav_number_pages = nav_number_pages | concat: group.items -%}
|
|
82
|
+
{%- endif -%}
|
|
83
|
+
{%- endfor -%}
|
|
84
|
+
|
|
85
|
+
{%- unless nav_number_pages == empty -%}
|
|
86
|
+
{%- assign nav_number_pages = nav_number_pages | sort: "nav_order" -%}
|
|
87
|
+
{%- endunless -%}
|
|
32
88
|
|
|
33
|
-
{%-
|
|
34
|
-
{%-
|
|
89
|
+
{%- unless nav_string_pages == empty -%}
|
|
90
|
+
{%- if site.nav_sort == 'case_insensitive' -%}
|
|
91
|
+
{%- assign nav_string_pages = nav_string_pages | sort_natural: "nav_order" -%}
|
|
92
|
+
{%- else -%}
|
|
93
|
+
{%- assign nav_string_pages = nav_string_pages | sort: "nav_order" -%}
|
|
94
|
+
{%- endif -%}
|
|
95
|
+
{%- endunless -%}
|
|
96
|
+
|
|
97
|
+
{%- assign title_number_pages = "" | split: "" -%}
|
|
98
|
+
{%- assign title_string_pages = "" | split: "" -%}
|
|
99
|
+
{%- assign title_order_groups = title_order_pages
|
|
100
|
+
| group_by_exp: "item", "item.title | jsonify | slice: 0" -%}
|
|
101
|
+
{%- for group in title_order_groups -%}
|
|
35
102
|
{%- if group.name == '"' -%}
|
|
36
|
-
{%- assign
|
|
103
|
+
{%- assign title_string_pages = group.items -%}
|
|
37
104
|
{%- else -%}
|
|
38
|
-
{%- assign
|
|
105
|
+
{%- assign title_number_pages = title_number_pages | concat: group.items -%}
|
|
39
106
|
{%- endif -%}
|
|
40
107
|
{%- endfor -%}
|
|
41
108
|
|
|
42
|
-
{%-
|
|
43
|
-
|
|
109
|
+
{%- unless title_number_pages == empty -%}
|
|
110
|
+
{%- assign title_number_pages = title_number_pages | sort: "title" -%}
|
|
111
|
+
{%- endunless -%}
|
|
44
112
|
|
|
45
|
-
{%-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{%-
|
|
113
|
+
{%- unless title_string_pages == empty -%}
|
|
114
|
+
{%- if site.nav_sort == 'case_insensitive' -%}
|
|
115
|
+
{%- assign title_string_pages = title_string_pages | sort_natural: "title" -%}
|
|
116
|
+
{%- else -%}
|
|
117
|
+
{%- assign title_string_pages = title_string_pages | sort: "title" -%}
|
|
118
|
+
{%- endif -%}
|
|
119
|
+
{%- endunless -%}
|
|
51
120
|
|
|
52
|
-
{%- assign
|
|
53
|
-
|
|
|
121
|
+
{%- assign pages_list = nav_number_pages | concat: nav_string_pages
|
|
122
|
+
| concat: title_number_pages | concat: title_string_pages -%}
|
|
54
123
|
|
|
55
|
-
{%-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
124
|
+
{%- assign first_level_pages = pages_list
|
|
125
|
+
| where_exp: "item", "item.parent == nil" -%}
|
|
126
|
+
{%- assign second_level_pages = pages_list
|
|
127
|
+
| where_exp: "item", "item.parent != nil"
|
|
128
|
+
| where_exp: "item", "item.grand_parent == nil" -%}
|
|
129
|
+
{%- assign third_level_pages = pages_list
|
|
130
|
+
| where_exp: "item", "item.grand_parent != nil" -%}
|
|
62
131
|
|
|
63
|
-
{%-
|
|
64
|
-
|
|
132
|
+
{%- comment -%}
|
|
133
|
+
The order of sibling pages in `pages_list` determines the order of display of
|
|
134
|
+
links to them in lists of navigation links and in auto-generated TOCs.
|
|
135
|
+
|
|
136
|
+
Note that Liquid evaluates conditions from right to left (and it does not allow
|
|
137
|
+
the use of parentheses). Some conditions are not so easy to express clearly...
|
|
138
|
+
|
|
139
|
+
For example, consider the following condition:
|
|
140
|
+
|
|
141
|
+
C: page.collection = = include.key and
|
|
142
|
+
page.url = = node.url or
|
|
143
|
+
page.grand_parent = = node.title or
|
|
144
|
+
page.parent = = node.title and
|
|
145
|
+
page.grand_parent = = nil
|
|
146
|
+
|
|
147
|
+
Here, `node` is a first-level page. The last part of the condition
|
|
148
|
+
-- namely: `page.parent = = node.title and page.grand_parent = = nil` --
|
|
149
|
+
is evaluated first; it holds if and only if `page` is a child of `node`.
|
|
150
|
+
|
|
151
|
+
The condition `page.grand_parent = = node.title or ...` holds when
|
|
152
|
+
`page` is a grandchild of node, OR `...` holds.
|
|
153
|
+
|
|
154
|
+
The condition `page.url = = node.url or ...` holds when
|
|
155
|
+
`page` is `node`, OR `...` holds.
|
|
156
|
+
|
|
157
|
+
The condition C: `page.collection = = include.key and ...` holds when we are
|
|
158
|
+
generating the nav links for a collection that includes `page`, AND `...` holds.
|
|
159
|
+
{%- endcomment -%}
|
|
65
160
|
|
|
66
161
|
<ul class="nav-list">
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{%- unless node.nav_exclude -%}
|
|
71
|
-
<li class="nav-list-item{% if page.collection == include.key and page.url == node.url or page.parent == node.title or page.grand_parent == node.title %} active{% endif %}">
|
|
162
|
+
{%- for node in first_level_pages -%}
|
|
163
|
+
{%- unless node.nav_exclude -%}
|
|
164
|
+
<li class="nav-list-item{% if page.collection == include.key and page.url == node.url or page.grand_parent == node.title or page.parent == node.title and page.grand_parent == nil %} active{% endif %}">
|
|
72
165
|
{%- if node.has_children -%}
|
|
73
166
|
<a href="#" class="nav-list-expander" aria-label="toggle links in {{ node.title }} category">
|
|
74
167
|
<svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg>
|
|
@@ -76,14 +169,9 @@
|
|
|
76
169
|
{%- endif -%}
|
|
77
170
|
<a href="{{ node.url | relative_url }}" class="nav-list-link{% if page.url == node.url %} active{% endif %}">{{ node.title }}</a>
|
|
78
171
|
{%- if node.has_children -%}
|
|
79
|
-
{%- assign children_list =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
| concat: parent_group.items
|
|
83
|
-
| where: "parent", node.title
|
|
84
|
-
| where_exp:"item", "item.grand_parent == nil" -%}
|
|
85
|
-
{%- endfor -%}
|
|
86
|
-
{%- if node.child_nav_order == 'desc' -%}
|
|
172
|
+
{%- assign children_list = second_level_pages
|
|
173
|
+
| where: "parent", node.title -%}
|
|
174
|
+
{%- if node.child_nav_order == 'desc' or node.child_nav_order == 'reversed' -%}
|
|
87
175
|
{%- assign children_list = children_list | reverse -%}
|
|
88
176
|
{%- endif -%}
|
|
89
177
|
<ul class="nav-list ">
|
|
@@ -97,21 +185,17 @@
|
|
|
97
185
|
{%- endif -%}
|
|
98
186
|
<a href="{{ child.url | relative_url }}" class="nav-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a>
|
|
99
187
|
{%- if child.has_children -%}
|
|
100
|
-
{%- assign
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
| where: "grand_parent", node.title -%}
|
|
106
|
-
{%- endfor -%}
|
|
107
|
-
{%- if node.child_nav_order == 'desc' -%}
|
|
108
|
-
{%- assign grandchildren_list = grandchildren_list | reverse -%}
|
|
188
|
+
{%- assign grand_children_list = third_level_pages
|
|
189
|
+
| where: "parent", child.title
|
|
190
|
+
| where: "grand_parent", node.title -%}
|
|
191
|
+
{%- if child.child_nav_order == 'desc' or child.child_nav_order == 'reversed' -%}
|
|
192
|
+
{%- assign grand_children_list = grand_children_list | reverse -%}
|
|
109
193
|
{%- endif -%}
|
|
110
194
|
<ul class="nav-list">
|
|
111
|
-
{%- for
|
|
112
|
-
{%- unless
|
|
113
|
-
<li class="nav-list-item {% if page.url ==
|
|
114
|
-
<a href="{{
|
|
195
|
+
{%- for grand_child in grand_children_list -%}
|
|
196
|
+
{%- unless grand_child.nav_exclude -%}
|
|
197
|
+
<li class="nav-list-item {% if page.url == grand_child.url %} active{% endif %}">
|
|
198
|
+
<a href="{{ grand_child.url | relative_url }}" class="nav-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a>
|
|
115
199
|
</li>
|
|
116
200
|
{%- endunless -%}
|
|
117
201
|
{%- endfor -%}
|
|
@@ -123,65 +207,45 @@
|
|
|
123
207
|
</ul>
|
|
124
208
|
{%- endif -%}
|
|
125
209
|
</li>
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
{%- endfor -%}
|
|
129
|
-
{%- endfor -%}
|
|
130
|
-
{%- assign nav_external_links = site.nav_external_links -%}
|
|
131
|
-
{%- for node in nav_external_links -%}
|
|
132
|
-
<li class="nav-list-item external">
|
|
133
|
-
<a href="{{ node.url | absolute_url }}" class="nav-list-link external">
|
|
134
|
-
{{ node.title }}
|
|
135
|
-
{% unless node.hide_icon %}<svg viewBox="0 0 24 24" aria-labelledby="svg-external-link-title"><use xlink:href="#svg-external-link"></use></svg>{% endunless %}
|
|
136
|
-
</a>
|
|
137
|
-
</li>
|
|
138
|
-
{%- endfor -%}
|
|
210
|
+
{%- endunless -%}
|
|
211
|
+
{%- endfor -%}
|
|
139
212
|
</ul>
|
|
140
213
|
|
|
141
|
-
{%-
|
|
214
|
+
{%- comment -%}
|
|
215
|
+
`page.collection` is the name of the Jekyll collection that contains the page,
|
|
216
|
+
if any, and otherwise nil. Similarly for `include.key`.
|
|
217
|
+
|
|
218
|
+
If the current page is in the collection (if any) whose navigation is currently
|
|
219
|
+
being generated, the following code sets `first_level_url` to the URL used in
|
|
220
|
+
the page's top-level breadcrumb (if any), and `second_level_url` to that used
|
|
221
|
+
in the page's second-level breadcrumb (if any).
|
|
222
|
+
|
|
223
|
+
For pages with children, the code also sets `toc_list` to the list of child pages,
|
|
224
|
+
reversing the order if needed.
|
|
225
|
+
{%- endcomment -%}
|
|
142
226
|
|
|
143
|
-
|
|
144
|
-
{%- for node in
|
|
145
|
-
|
|
146
|
-
{%- if page.grand_parent == node.title
|
|
147
|
-
or page.parent == node.title
|
|
148
|
-
and page.grand_parent == nil -%}
|
|
227
|
+
{%- if page.collection == include.key -%}
|
|
228
|
+
{%- for node in first_level_pages -%}
|
|
229
|
+
{%- if page.grand_parent == node.title or page.parent == node.title and page.grand_parent == nil -%}
|
|
149
230
|
{%- assign first_level_url = node.url | relative_url -%}
|
|
150
231
|
{%- endif -%}
|
|
151
232
|
{%- if node.has_children -%}
|
|
152
|
-
{%- assign children_list =
|
|
153
|
-
{%- for parent_group in groups_list -%}
|
|
154
|
-
{%- assign children_list = children_list | concat:
|
|
155
|
-
parent_group.items | where: "parent", node.title -%}
|
|
156
|
-
{%- endfor -%}
|
|
157
|
-
{%- if node.child_nav_order == 'desc' -%}
|
|
158
|
-
{%- assign children_list = children_list | reverse -%}
|
|
159
|
-
{%- endif -%}
|
|
233
|
+
{%- assign children_list = second_level_pages | where: "parent", node.title -%}
|
|
160
234
|
{%- for child in children_list -%}
|
|
161
235
|
{%- if child.has_children -%}
|
|
162
|
-
{%- if page.url == child.url
|
|
163
|
-
or page.parent == child.title
|
|
164
|
-
and page.grand_parent == child.parent -%}
|
|
236
|
+
{%- if page.url == child.url or page.parent == child.title and page.grand_parent == child.parent -%}
|
|
165
237
|
{%- assign second_level_url = child.url | relative_url -%}
|
|
166
238
|
{%- endif -%}
|
|
167
239
|
{%- endif -%}
|
|
168
240
|
{%- endfor -%}
|
|
169
241
|
{%- endif -%}
|
|
170
|
-
{%- endif -%}
|
|
171
|
-
{%- endfor -%}
|
|
172
242
|
{%- endfor -%}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
| concat: parent_group.items
|
|
179
|
-
| where: "parent", page.title
|
|
180
|
-
| where: "grand_parent", page.parent -%}
|
|
181
|
-
{%- endfor -%}
|
|
182
|
-
{%- if node.child_nav_order == 'desc' -%}
|
|
243
|
+
{%- if page.has_children == true and page.has_toc != false -%}
|
|
244
|
+
{%- assign toc_list = pages_list
|
|
245
|
+
| where: "parent", page.title
|
|
246
|
+
| where_exp: "item", "item.grand_parent == page.parent" -%}
|
|
247
|
+
{%- if page.child_nav_order == 'desc' or page.child_nav_order == 'reversed' -%}
|
|
183
248
|
{%- assign toc_list = toc_list | reverse -%}
|
|
184
249
|
{%- endif -%}
|
|
185
250
|
{%- endif -%}
|
|
186
|
-
|
|
187
251
|
{%- endif -%}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h2 class="text-delta">Table of contents</h2>
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
25
25
|
{% endcomment %}
|
|
26
26
|
{% comment %}
|
|
27
|
-
Version 1.0.
|
|
27
|
+
Version 1.0.12
|
|
28
28
|
https://github.com/allejo/jekyll-anchor-headings
|
|
29
29
|
|
|
30
30
|
"Be the pull request you wish to see in the world." ~Ben Balter
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
|
|
38
38
|
Optional Parameters:
|
|
39
39
|
* beforeHeading (bool) : false - Set to true if the anchor should be placed _before_ the heading's content
|
|
40
|
+
* headerAttrs (string) : '' - Any custom HTML attributes that will be added to the heading tag; you may NOT use `id`;
|
|
41
|
+
the `%heading%` and `%html_id%` placeholders are available
|
|
40
42
|
* anchorAttrs (string) : '' - Any custom HTML attributes that will be added to the `<a>` tag; you may NOT use `href`, `class` or `title`;
|
|
41
43
|
the `%heading%` and `%html_id%` placeholders are available
|
|
42
44
|
* anchorBody (string) : '' - The content that will be placed inside the anchor; the `%heading%` placeholder is available
|
|
@@ -46,6 +48,7 @@
|
|
|
46
48
|
* h_max (int) : 6 - The maximum header level to build an anchor for; any header greater than this value will be ignored
|
|
47
49
|
* bodyPrefix (string) : '' - Anything that should be inserted inside of the heading tag _before_ its anchor and content
|
|
48
50
|
* bodySuffix (string) : '' - Anything that should be inserted inside of the heading tag _after_ its anchor and content
|
|
51
|
+
* generateId (true) : false - Set to true if a header without id should generate an id to use.
|
|
49
52
|
|
|
50
53
|
Output:
|
|
51
54
|
The original HTML with the addition of anchors inside of all of the h1-h6 headings.
|
|
@@ -54,6 +57,7 @@
|
|
|
54
57
|
{% assign minHeader = include.h_min | default: 1 %}
|
|
55
58
|
{% assign maxHeader = include.h_max | default: 6 %}
|
|
56
59
|
{% assign beforeHeading = include.beforeHeading %}
|
|
60
|
+
{% assign headerAttrs = include.headerAttrs %}
|
|
57
61
|
{% assign nodes = include.html | split: '<h' %}
|
|
58
62
|
|
|
59
63
|
{% capture edited_headings %}{% endcapture %}
|
|
@@ -84,17 +88,41 @@
|
|
|
84
88
|
|
|
85
89
|
{% capture _closingTag %}</h{{ headerLevel }}>{% endcapture %}
|
|
86
90
|
{% assign _workspace = node | split: _closingTag %}
|
|
87
|
-
{% assign _idWorkspace = _workspace[0] | split: 'id="' %}
|
|
88
|
-
{% assign _idWorkspace = _idWorkspace[1] | split: '"' %}
|
|
89
|
-
{% assign html_id = _idWorkspace[0] %}
|
|
90
|
-
|
|
91
91
|
{% capture _hAttrToStrip %}{{ _workspace[0] | split: '>' | first }}>{% endcapture %}
|
|
92
92
|
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' %}
|
|
93
|
+
{% assign escaped_header = header | strip_html | strip %}
|
|
94
|
+
|
|
95
|
+
{% assign _classWorkspace = _workspace[0] | split: 'class="' %}
|
|
96
|
+
{% assign _classWorkspace = _classWorkspace[1] | split: '"' %}
|
|
97
|
+
{% assign _html_class = _classWorkspace[0] %}
|
|
98
|
+
|
|
99
|
+
{% if _html_class contains "no_anchor" %}
|
|
100
|
+
{% assign skip_anchor = true %}
|
|
101
|
+
{% else %}
|
|
102
|
+
{% assign skip_anchor = false %}
|
|
103
|
+
{% endif %}
|
|
104
|
+
|
|
105
|
+
{% assign _idWorkspace = _workspace[0] | split: 'id="' %}
|
|
106
|
+
{% if _idWorkspace[1] %}
|
|
107
|
+
{% assign _idWorkspace = _idWorkspace[1] | split: '"' %}
|
|
108
|
+
{% assign html_id = _idWorkspace[0] %}
|
|
109
|
+
{% elsif include.generateId %}
|
|
110
|
+
<!-- If the header did not have an id we create one. -->
|
|
111
|
+
{% assign html_id = escaped_header | slugify %}
|
|
112
|
+
{% if html_id == "" %}
|
|
113
|
+
{% assign html_id = false %}
|
|
114
|
+
{% endif %}
|
|
115
|
+
{% capture headerAttrs %}{{ headerAttrs }} id="%html_id%"{% endcapture %}
|
|
116
|
+
{% endif %}
|
|
93
117
|
|
|
94
118
|
<!-- Build the anchor to inject for our heading -->
|
|
95
119
|
{% capture anchor %}{% endcapture %}
|
|
96
120
|
|
|
97
|
-
{% if html_id and headerLevel >= minHeader and headerLevel <= maxHeader %}
|
|
121
|
+
{% if skip_anchor == false and html_id and headerLevel >= minHeader and headerLevel <= maxHeader %}
|
|
122
|
+
{% if headerAttrs %}
|
|
123
|
+
{% capture _hAttrToStrip %}{{ _hAttrToStrip | split: '>' | first }} {{ headerAttrs | replace: '%heading%', escaped_header | replace: '%html_id%', html_id }}>{% endcapture %}
|
|
124
|
+
{% endif %}
|
|
125
|
+
|
|
98
126
|
{% capture anchor %}href="#{{ html_id }}"{% endcapture %}
|
|
99
127
|
|
|
100
128
|
{% if include.anchorClass %}
|
|
@@ -102,14 +130,14 @@
|
|
|
102
130
|
{% endif %}
|
|
103
131
|
|
|
104
132
|
{% if include.anchorTitle %}
|
|
105
|
-
{% capture anchor %}{{ anchor }} title="{{ include.anchorTitle | replace: '%heading%',
|
|
133
|
+
{% capture anchor %}{{ anchor }} title="{{ include.anchorTitle | replace: '%heading%', escaped_header }}"{% endcapture %}
|
|
106
134
|
{% endif %}
|
|
107
135
|
|
|
108
136
|
{% if include.anchorAttrs %}
|
|
109
|
-
{% capture anchor %}{{ anchor }} {{ include.anchorAttrs | replace: '%heading%',
|
|
137
|
+
{% capture anchor %}{{ anchor }} {{ include.anchorAttrs | replace: '%heading%', escaped_header | replace: '%html_id%', html_id }}{% endcapture %}
|
|
110
138
|
{% endif %}
|
|
111
139
|
|
|
112
|
-
{% capture anchor %}<a {{ anchor }}>{{ include.anchorBody | replace: '%heading%',
|
|
140
|
+
{% capture anchor %}<a {{ anchor }}>{{ include.anchorBody | replace: '%heading%', escaped_header | default: '' }}</a>{% endcapture %}
|
|
113
141
|
|
|
114
142
|
<!-- In order to prevent adding extra space after a heading, we'll let the 'anchor' value contain it -->
|
|
115
143
|
{% if beforeHeading %}
|
|
@@ -120,15 +148,15 @@
|
|
|
120
148
|
{% endif %}
|
|
121
149
|
|
|
122
150
|
{% capture new_heading %}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
151
|
+
<h{{ _hAttrToStrip }}
|
|
152
|
+
{{ include.bodyPrefix }}
|
|
153
|
+
{% if beforeHeading %}
|
|
154
|
+
{{ anchor }}{{ header }}
|
|
155
|
+
{% else %}
|
|
156
|
+
{{ header }}{{ anchor }}
|
|
157
|
+
{% endif %}
|
|
158
|
+
{{ include.bodySuffix }}
|
|
159
|
+
</h{{ headerLevel }}>
|
|
132
160
|
{% endcapture %}
|
|
133
161
|
|
|
134
162
|
<!--
|