just-the-umbrel-docs 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +72 -0
- data/Rakefile +1 -0
- data/_includes/css/custom.scss.liquid +1 -0
- data/_includes/css/just-the-docs.scss.liquid +7 -0
- data/_includes/fix_linenos.html +65 -0
- data/_includes/footer_custom.html +3 -0
- data/_includes/head.html +40 -0
- data/_includes/head_custom.html +0 -0
- data/_includes/header_custom.html +0 -0
- data/_includes/js/custom.js +0 -0
- data/_includes/nav.html +99 -0
- data/_includes/title.html +5 -0
- data/_includes/vendor/anchor_headings.html +144 -0
- data/_layouts/about.html +5 -0
- data/_layouts/default.html +202 -0
- data/_layouts/home.html +5 -0
- data/_layouts/page.html +5 -0
- data/_layouts/post.html +5 -0
- data/_layouts/table_wrappers.html +7 -0
- data/_layouts/vendor/compress.html +10 -0
- data/_sass/base.scss +108 -0
- data/_sass/buttons.scss +118 -0
- data/_sass/code.scss +340 -0
- data/_sass/color_schemes/dark.scss +17 -0
- data/_sass/color_schemes/light.scss +0 -0
- data/_sass/content.scss +231 -0
- data/_sass/custom/custom.scss +0 -0
- data/_sass/labels.scss +37 -0
- data/_sass/layout.scss +205 -0
- data/_sass/modules.scss +20 -0
- data/_sass/navigation.scss +219 -0
- data/_sass/print.scss +40 -0
- data/_sass/search.scss +323 -0
- data/_sass/support/_functions.scss +9 -0
- data/_sass/support/_variables.scss +153 -0
- data/_sass/support/mixins/_buttons.scss +27 -0
- data/_sass/support/mixins/_layout.scss +34 -0
- data/_sass/support/mixins/_typography.scss +84 -0
- data/_sass/support/mixins/mixins.scss +3 -0
- data/_sass/support/support.scss +3 -0
- data/_sass/tables.scss +58 -0
- data/_sass/typography.scss +64 -0
- data/_sass/utilities/_colors.scss +239 -0
- data/_sass/utilities/_layout.scss +95 -0
- data/_sass/utilities/_lists.scss +17 -0
- data/_sass/utilities/_spacing.scss +165 -0
- data/_sass/utilities/_typography.scss +91 -0
- data/_sass/utilities/utilities.scss +5 -0
- data/_sass/vendor/normalize.scss/README.md +7 -0
- data/_sass/vendor/normalize.scss/normalize.scss +349 -0
- data/assets/css/just-the-docs-dark.scss +3 -0
- data/assets/css/just-the-docs-default.scss +8 -0
- data/assets/css/just-the-docs-light.scss +3 -0
- data/assets/images/just-the-docs.png +0 -0
- data/assets/images/search.svg +1 -0
- data/assets/js/just-the-docs.js +471 -0
- data/assets/js/vendor/lunr.min.js +6 -0
- data/assets/js/zzzz-search-data.json +72 -0
- data/bin/just-the-docs +16 -0
- data/lib/tasks/search.rake +86 -0
- metadata +183 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2d25a4faa005b7862da60e653ac48c865ff92f0ba18a0706cf2e2f1d8d49df03
|
4
|
+
data.tar.gz: d60fc7e515b7c0cc0833239a27e67086c99455e65a7bd7fb1ffec71dd5be91c6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e4ceaa7d29d9fc59560750722971804048cc68dae361162c740c4c93c636e00f93c36565635b5edc3be8ac9bfd14de1e38cb0f4e4942daff948873fe1e27616d
|
7
|
+
data.tar.gz: 56ebdb1c1af7d30cb9b0fd424ab4895a75e6601b0db6eb32072219fc5e212efe00698f2d37118f3e089d9ddddeb6965e00e815d9ed7029e2611f89ccb5ffda5d
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Patrick Marsceill
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
<p align="right">
|
2
|
+
<a href="https://badge.fury.io/rb/just-the-docs"><img src="https://badge.fury.io/rb/just-the-docs.svg" alt="Gem version"></a> <a href="https://github.com/pmarsceill/just-the-docs/actions?query=workflow%3A%22Master+branch+CI%22"><img src="https://github.com/pmarsceill/just-the-docs/workflows/Master%20branch%20CI/badge.svg" alt="Build status"></a>
|
3
|
+
</p>
|
4
|
+
<br><br>
|
5
|
+
<p align="center">
|
6
|
+
<h1 align="center">Just the Docs</h1>
|
7
|
+
<p align="center">A modern, highly customizable, and responsive Jekyll theme for documentation with built-in search.<br>Easily hosted on GitHub Pages with few dependencies.</p>
|
8
|
+
<p align="center"><strong><a href="https://pmarsceill.github.io/just-the-docs/">See it in action!</a></strong></p>
|
9
|
+
<br><br><br>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
![jtd](https://user-images.githubusercontent.com/896475/47384541-89053c80-d6d5-11e8-98dc-dba16e192de9.gif)
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your Jekyll site's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem "just-the-docs"
|
20
|
+
```
|
21
|
+
|
22
|
+
And add this line to your Jekyll site's `_config.yml`:
|
23
|
+
|
24
|
+
```yaml
|
25
|
+
theme: just-the-docs
|
26
|
+
```
|
27
|
+
|
28
|
+
And then execute:
|
29
|
+
|
30
|
+
$ bundle
|
31
|
+
|
32
|
+
Or install it yourself as:
|
33
|
+
|
34
|
+
$ gem install just-the-docs
|
35
|
+
|
36
|
+
Alternatively, you can run it inside Docker while developing your site
|
37
|
+
|
38
|
+
$ docker-compose up
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
[View the documentation](https://pmarsceill.github.io/just-the-docs/) for usage information.
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pmarsceill/just-the-docs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
47
|
+
|
48
|
+
### Submitting code changes:
|
49
|
+
|
50
|
+
- Open a [Pull Request](https://github.com/pmarsceill/just-the-docs/pulls)
|
51
|
+
- Ensure all CI tests pass
|
52
|
+
- Await code review
|
53
|
+
- Bump the version number in `just-the-docs.gemspec` and `package.json` according to [semantic versioning](https://semver.org/).
|
54
|
+
|
55
|
+
### Design and development principles of this theme:
|
56
|
+
|
57
|
+
1. As few dependencies as possible
|
58
|
+
2. No build script needed
|
59
|
+
3. First class mobile experience
|
60
|
+
4. Make the content shine
|
61
|
+
|
62
|
+
## Development
|
63
|
+
|
64
|
+
To set up your environment to develop this theme, run `bundle install`.
|
65
|
+
|
66
|
+
Your theme is set up just like a normal Jekyll site! To test your theme, run `bundle exec jekyll serve` and open your browser at `http://localhost:4000`. This starts a Jekyll server using your theme. Add pages, documents, data, etc. like normal to test your theme's contents. As you make modifications to your theme and to your content, your site will regenerate and you should see the changes in the browser after a refresh, just like normal.
|
67
|
+
|
68
|
+
When the theme is released, only the files in `_layouts`, `_includes`, and `_sass` tracked with Git will be released.
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
The theme is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob('lib/tasks/*.rake').each {|r| import r}
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "./custom/custom";
|
@@ -0,0 +1,65 @@
|
|
1
|
+
{%- comment -%}
|
2
|
+
This file can be used to fix the HTML produced by Jekyll for highlighted
|
3
|
+
code with line numbers.
|
4
|
+
|
5
|
+
It works with `{% highlight some_language linenos %}...{% endhighlight %}`
|
6
|
+
and with the Kramdown option to add line numbers to fenced code.
|
7
|
+
|
8
|
+
The implementation was derived from the workaround provided by
|
9
|
+
Dmitry Hrabrov (DeXP) at
|
10
|
+
https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-188144901
|
11
|
+
|
12
|
+
EXPLANATION
|
13
|
+
|
14
|
+
The HTML produced by Rouge highlighting with lie numbers is of the form
|
15
|
+
`code table`. Jekyll (<= 4.1.1) always wraps the highlighted HTML
|
16
|
+
with `pre`. This wrapping is not only unnecessary, but also transforms
|
17
|
+
the conforming HTML produced by Rouge to non-conforming HTML, which
|
18
|
+
results in HTML validation error reports.
|
19
|
+
|
20
|
+
The fix removes the outer `pre` tags whenever they contain the pattern
|
21
|
+
`<table class="rouge-table">`.
|
22
|
+
|
23
|
+
Apart from avoiding HTML validation errors, the fix allows the use of
|
24
|
+
the [Jekyll layout for compressing HTML](http://jch.penibelst.de),
|
25
|
+
which relies on `pre` tags not being nested, according to
|
26
|
+
https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-172069842
|
27
|
+
|
28
|
+
USAGE
|
29
|
+
|
30
|
+
(Any names can be used for `some_var` and `some_language`.)
|
31
|
+
|
32
|
+
{% capture some_var %}
|
33
|
+
{% highlight some_language linenos %}
|
34
|
+
Some code
|
35
|
+
{% endhighlight %}
|
36
|
+
{% endcapture %}
|
37
|
+
{% include fix_linenos.html code=some_var %}
|
38
|
+
|
39
|
+
For code fences:
|
40
|
+
|
41
|
+
{% capture some_var %}
|
42
|
+
```some_language
|
43
|
+
Some code
|
44
|
+
```
|
45
|
+
{% endcapture %}
|
46
|
+
{% assign some_var = some_var | markdownify %}
|
47
|
+
{% include fix_linenos.html code=some_var %}
|
48
|
+
|
49
|
+
CAVEATS
|
50
|
+
|
51
|
+
The above does not work when `Some code` happens to contain the matched string
|
52
|
+
`<table class="rouge-table">`.
|
53
|
+
|
54
|
+
The use of this file overwrites the variable `fix_linenos_code` with `nil`.
|
55
|
+
|
56
|
+
{%- endcomment -%}
|
57
|
+
|
58
|
+
{% assign fix_linenos_code = include.code %}
|
59
|
+
{% if fix_linenos_code contains '<table class="rouge-table">' %}
|
60
|
+
{% assign fix_linenos_code = fix_linenos_code | replace: '<pre class="highlight">', '<pre>' %}
|
61
|
+
{% assign fix_linenos_code = fix_linenos_code | replace: "<pre><code", "<code" %}
|
62
|
+
{% assign fix_linenos_code = fix_linenos_code | replace: "</code></pre>", "</code>" %}
|
63
|
+
{% endif %}
|
64
|
+
{{ fix_linenos_code }}
|
65
|
+
{% assign fix_linenos_code = nil %}
|
data/_includes/head.html
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
<head>
|
2
|
+
<meta charset="UTF-8">
|
3
|
+
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
|
4
|
+
|
5
|
+
{% unless site.plugins contains "jekyll-seo-tag" %}
|
6
|
+
<title>{{ page.title }} - {{ site.title }}</title>
|
7
|
+
|
8
|
+
{% if page.description %}
|
9
|
+
<meta name="Description" content="{{ page.description }}">
|
10
|
+
{% endif %}
|
11
|
+
{% endunless %}
|
12
|
+
|
13
|
+
<link rel="shortcut icon" href="{{ 'favicon.ico' | relative_url }}" type="image/x-icon">
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="{{ '/assets/css/just-the-docs-default.css' | relative_url }}">
|
16
|
+
|
17
|
+
{% if site.ga_tracking != nil %}
|
18
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.ga_tracking }}"></script>
|
19
|
+
<script>
|
20
|
+
window.dataLayer = window.dataLayer || [];
|
21
|
+
function gtag(){dataLayer.push(arguments);}
|
22
|
+
gtag('js', new Date());
|
23
|
+
|
24
|
+
gtag('config', '{{ site.ga_tracking }}'{% unless site.ga_tracking_anonymize_ip == nil %}, { 'anonymize_ip': true }{% endunless %});
|
25
|
+
</script>
|
26
|
+
|
27
|
+
{% endif %}
|
28
|
+
|
29
|
+
{% if site.search_enabled != false %}
|
30
|
+
<script type="text/javascript" src="{{ '/assets/js/vendor/lunr.min.js' | relative_url }}"></script>
|
31
|
+
{% endif %}
|
32
|
+
<script type="text/javascript" src="{{ '/assets/js/just-the-docs.js' | relative_url }}"></script>
|
33
|
+
|
34
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
35
|
+
|
36
|
+
{% seo %}
|
37
|
+
|
38
|
+
{% include head_custom.html %}
|
39
|
+
|
40
|
+
</head>
|
File without changes
|
File without changes
|
File without changes
|
data/_includes/nav.html
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
<ul class="nav-list">
|
2
|
+
{%- assign titled_pages = include.pages
|
3
|
+
| where_exp:"item", "item.title != nil" -%}
|
4
|
+
|
5
|
+
{%- comment -%}
|
6
|
+
The values of `title` and `nav_order` can be numbers or strings.
|
7
|
+
Jekyll gives build failures when sorting on mixtures of different types,
|
8
|
+
so numbers and strings need to be sorted separately.
|
9
|
+
|
10
|
+
Here, numbers are sorted by their values, and come before all strings.
|
11
|
+
An omitted `nav_order` value is equivalent to the page's `title` value
|
12
|
+
(except that a numerical `title` value is treated as a string).
|
13
|
+
|
14
|
+
The case-sensitivity of string sorting is determined by `site.nav_sort`.
|
15
|
+
{%- endcomment -%}
|
16
|
+
|
17
|
+
{%- assign string_ordered_pages = titled_pages
|
18
|
+
| where_exp:"item", "item.nav_order == nil" -%}
|
19
|
+
{%- assign nav_ordered_pages = titled_pages
|
20
|
+
| where_exp:"item", "item.nav_order != nil" -%}
|
21
|
+
|
22
|
+
{%- comment -%}
|
23
|
+
The nav_ordered_pages have to be added to number_ordered_pages and
|
24
|
+
string_ordered_pages, depending on the nav_order value.
|
25
|
+
The first character of the jsonify result is `"` only for strings.
|
26
|
+
{%- endcomment -%}
|
27
|
+
{%- assign nav_ordered_groups = nav_ordered_pages
|
28
|
+
| group_by_exp:"item", "item.nav_order | jsonify | slice: 0" -%}
|
29
|
+
{%- assign number_ordered_pages = "" | split:"X" -%}
|
30
|
+
{%- for group in nav_ordered_groups -%}
|
31
|
+
{%- if group.name == '"' -%}
|
32
|
+
{%- assign string_ordered_pages = string_ordered_pages | concat: group.items -%}
|
33
|
+
{%- else -%}
|
34
|
+
{%- assign number_ordered_pages = number_ordered_pages | concat: group.items -%}
|
35
|
+
{%- endif -%}
|
36
|
+
{%- endfor -%}
|
37
|
+
|
38
|
+
{%- assign sorted_number_ordered_pages = number_ordered_pages | sort:"nav_order" -%}
|
39
|
+
|
40
|
+
{%- comment -%}
|
41
|
+
The string_ordered_pages have to be sorted by nav_order, and otherwise title
|
42
|
+
(where appending the empty string to a numeric title converts it to a string).
|
43
|
+
After grouping them by those values, the groups are sorted, then the items
|
44
|
+
of each group are concatenated.
|
45
|
+
{%- endcomment -%}
|
46
|
+
{%- assign string_ordered_groups = string_ordered_pages
|
47
|
+
| group_by_exp:"item", "item.nav_order | default: item.title | append:''" -%}
|
48
|
+
{%- if site.nav_sort == 'case_insensitive' -%}
|
49
|
+
{%- assign sorted_string_ordered_groups = string_ordered_groups | sort_natural:"name" -%}
|
50
|
+
{%- else -%}
|
51
|
+
{%- assign sorted_string_ordered_groups = string_ordered_groups | sort:"name" -%}
|
52
|
+
{%- endif -%}
|
53
|
+
{%- assign sorted_string_ordered_pages = "" | split:"X" -%}
|
54
|
+
{%- for group in sorted_string_ordered_groups -%}
|
55
|
+
{%- assign sorted_string_ordered_pages = sorted_string_ordered_pages | concat: group.items -%}
|
56
|
+
{%- endfor -%}
|
57
|
+
|
58
|
+
{%- assign pages_list = sorted_number_ordered_pages | concat: sorted_string_ordered_pages -%}
|
59
|
+
|
60
|
+
{%- for node in pages_list -%}
|
61
|
+
{%- if node.parent == nil -%}
|
62
|
+
{%- unless node.nav_exclude -%}
|
63
|
+
<li class="nav-list-item{% if page.url == node.url or page.parent == node.title or page.grand_parent == node.title %} active{% endif %}">
|
64
|
+
{%- if node.has_children -%}
|
65
|
+
<a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a>
|
66
|
+
{%- endif -%}
|
67
|
+
<a href="{{ node.url | absolute_url }}" class="nav-list-link{% if page.url == node.url %} active{% endif %}">{{ node.title }}</a>
|
68
|
+
{%- if node.has_children -%}
|
69
|
+
{%- assign children_list = pages_list | where: "parent", node.title -%}
|
70
|
+
<ul class="nav-list ">
|
71
|
+
{%- for child in children_list -%}
|
72
|
+
{%- unless child.nav_exclude -%}
|
73
|
+
<li class="nav-list-item {% if page.url == child.url or page.parent == child.title %} active{% endif %}">
|
74
|
+
{%- if child.has_children -%}
|
75
|
+
<a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a>
|
76
|
+
{%- endif -%}
|
77
|
+
<a href="{{ child.url | absolute_url }}" class="nav-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a>
|
78
|
+
{%- if child.has_children -%}
|
79
|
+
{%- assign grand_children_list = pages_list | where: "parent", child.title | where: "grand_parent", node.title -%}
|
80
|
+
<ul class="nav-list">
|
81
|
+
{%- for grand_child in grand_children_list -%}
|
82
|
+
{%- unless grand_child.nav_exclude -%}
|
83
|
+
<li class="nav-list-item {% if page.url == grand_child.url %} active{% endif %}">
|
84
|
+
<a href="{{ grand_child.url | absolute_url }}" class="nav-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a>
|
85
|
+
</li>
|
86
|
+
{%- endunless -%}
|
87
|
+
{%- endfor -%}
|
88
|
+
</ul>
|
89
|
+
{%- endif -%}
|
90
|
+
</li>
|
91
|
+
{%- endunless -%}
|
92
|
+
{%- endfor -%}
|
93
|
+
</ul>
|
94
|
+
{%- endif -%}
|
95
|
+
</li>
|
96
|
+
{%- endunless -%}
|
97
|
+
{%- endif -%}
|
98
|
+
{%- endfor -%}
|
99
|
+
</ul>
|
@@ -0,0 +1,144 @@
|
|
1
|
+
{% capture headingsWorkspace %}
|
2
|
+
{% comment %}
|
3
|
+
Copyright (c) 2018 Vladimir "allejo" Jimenez
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
6
|
+
obtaining a copy of this software and associated documentation
|
7
|
+
files (the "Software"), to deal in the Software without
|
8
|
+
restriction, including without limitation the rights to use,
|
9
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the
|
11
|
+
Software is furnished to do so, subject to the following
|
12
|
+
conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
19
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
23
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
24
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
25
|
+
{% endcomment %}
|
26
|
+
{% comment %}
|
27
|
+
Version 1.0.7
|
28
|
+
https://github.com/allejo/jekyll-anchor-headings
|
29
|
+
|
30
|
+
"Be the pull request you wish to see in the world." ~Ben Balter
|
31
|
+
|
32
|
+
Usage:
|
33
|
+
{% include anchor_headings.html html=content anchorBody="#" %}
|
34
|
+
|
35
|
+
Parameters:
|
36
|
+
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll
|
37
|
+
|
38
|
+
Optional Parameters:
|
39
|
+
* beforeHeading (bool) : false - Set to true if the anchor should be placed _before_ the heading's content
|
40
|
+
* anchorAttrs (string) : '' - Any custom HTML attributes that will be added to the `<a>` tag; you may NOT use `href`, `class` or `title`;
|
41
|
+
the `%heading%` and `%html_id%` placeholders are available
|
42
|
+
* anchorBody (string) : '' - The content that will be placed inside the anchor; the `%heading%` placeholder is available
|
43
|
+
* anchorClass (string) : '' - The class(es) that will be used for each anchor. Separate multiple classes with a space
|
44
|
+
* anchorTitle (string) : '' - The `title` attribute that will be used for anchors
|
45
|
+
* h_min (int) : 1 - The minimum header level to build an anchor for; any header lower than this value will be ignored
|
46
|
+
* h_max (int) : 6 - The maximum header level to build an anchor for; any header greater than this value will be ignored
|
47
|
+
* bodyPrefix (string) : '' - Anything that should be inserted inside of the heading tag _before_ its anchor and content
|
48
|
+
* bodySuffix (string) : '' - Anything that should be inserted inside of the heading tag _after_ its anchor and content
|
49
|
+
|
50
|
+
Output:
|
51
|
+
The original HTML with the addition of anchors inside of all of the h1-h6 headings.
|
52
|
+
{% endcomment %}
|
53
|
+
|
54
|
+
{% assign minHeader = include.h_min | default: 1 %}
|
55
|
+
{% assign maxHeader = include.h_max | default: 6 %}
|
56
|
+
{% assign beforeHeading = include.beforeHeading %}
|
57
|
+
{% assign nodes = include.html | split: '<h' %}
|
58
|
+
|
59
|
+
{% capture edited_headings %}{% endcapture %}
|
60
|
+
|
61
|
+
{% for _node in nodes %}
|
62
|
+
{% capture node %}{{ _node | strip }}{% endcapture %}
|
63
|
+
|
64
|
+
{% if node == "" %}
|
65
|
+
{% continue %}
|
66
|
+
{% endif %}
|
67
|
+
|
68
|
+
{% assign nextChar = node | replace: '"', '' | strip | slice: 0, 1 %}
|
69
|
+
{% assign headerLevel = nextChar | times: 1 %}
|
70
|
+
|
71
|
+
<!-- If the level is cast to 0, it means it's not a h1-h6 tag, so let's see if we need to fix it -->
|
72
|
+
{% if headerLevel == 0 %}
|
73
|
+
<!-- Split up the node based on closing angle brackets and get the first one. -->
|
74
|
+
{% assign firstChunk = node | split: '>' | first %}
|
75
|
+
|
76
|
+
<!-- If the first chunk does NOT contain a '<', that means we've broken another HTML tag that starts with 'h' -->
|
77
|
+
{% unless firstChunk contains '<' %}
|
78
|
+
{% capture node %}<h{{ node }}{% endcapture %}
|
79
|
+
{% endunless %}
|
80
|
+
|
81
|
+
{% capture edited_headings %}{{ edited_headings }}{{ node }}{% endcapture %}
|
82
|
+
{% continue %}
|
83
|
+
{% endif %}
|
84
|
+
|
85
|
+
{% capture _closingTag %}</h{{ headerLevel }}>{% endcapture %}
|
86
|
+
{% 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
|
+
{% capture _hAttrToStrip %}{{ _workspace[0] | split: '>' | first }}>{% endcapture %}
|
92
|
+
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' %}
|
93
|
+
|
94
|
+
<!-- Build the anchor to inject for our heading -->
|
95
|
+
{% capture anchor %}{% endcapture %}
|
96
|
+
|
97
|
+
{% if html_id and headerLevel >= minHeader and headerLevel <= maxHeader %}
|
98
|
+
{% capture anchor %}href="#{{ html_id }}"{% endcapture %}
|
99
|
+
|
100
|
+
{% if include.anchorClass %}
|
101
|
+
{% capture anchor %}{{ anchor }} class="{{ include.anchorClass }}"{% endcapture %}
|
102
|
+
{% endif %}
|
103
|
+
|
104
|
+
{% if include.anchorTitle %}
|
105
|
+
{% capture anchor %}{{ anchor }} title="{{ include.anchorTitle | replace: '%heading%', header }}"{% endcapture %}
|
106
|
+
{% endif %}
|
107
|
+
|
108
|
+
{% if include.anchorAttrs %}
|
109
|
+
{% capture anchor %}{{ anchor }} {{ include.anchorAttrs | replace: '%heading%', header | replace: '%html_id%', html_id }}{% endcapture %}
|
110
|
+
{% endif %}
|
111
|
+
|
112
|
+
{% capture anchor %}<a {{ anchor }}>{{ include.anchorBody | replace: '%heading%', header | default: '' }}</a>{% endcapture %}
|
113
|
+
|
114
|
+
<!-- In order to prevent adding extra space after a heading, we'll let the 'anchor' value contain it -->
|
115
|
+
{% if beforeHeading %}
|
116
|
+
{% capture anchor %}{{ anchor }} {% endcapture %}
|
117
|
+
{% else %}
|
118
|
+
{% capture anchor %} {{ anchor }}{% endcapture %}
|
119
|
+
{% endif %}
|
120
|
+
{% endif %}
|
121
|
+
|
122
|
+
{% capture new_heading %}
|
123
|
+
<h{{ _hAttrToStrip }}
|
124
|
+
{{ include.bodyPrefix }}
|
125
|
+
{% if beforeHeading %}
|
126
|
+
{{ anchor }}{{ header }}
|
127
|
+
{% else %}
|
128
|
+
{{ header }}{{ anchor }}
|
129
|
+
{% endif %}
|
130
|
+
{{ include.bodySuffix }}
|
131
|
+
</h{{ headerLevel }}>
|
132
|
+
{% endcapture %}
|
133
|
+
|
134
|
+
<!--
|
135
|
+
If we have content after the `</hX>` tag, then we'll want to append that here so we don't lost any content.
|
136
|
+
-->
|
137
|
+
{% assign chunkCount = _workspace | size %}
|
138
|
+
{% if chunkCount > 1 %}
|
139
|
+
{% capture new_heading %}{{ new_heading }}{{ _workspace | last }}{% endcapture %}
|
140
|
+
{% endif %}
|
141
|
+
|
142
|
+
{% capture edited_headings %}{{ edited_headings }}{{ new_heading }}{% endcapture %}
|
143
|
+
{% endfor %}
|
144
|
+
{% endcapture %}{% assign headingsWorkspace = '' %}{{ edited_headings | strip }}
|