juicelang-theme 0.3.1 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa58248dfa2dd15f30ff5c9030de425dcfe9462c962997a75e6837cf2ae48647
4
- data.tar.gz: d76114253c93366ab0183f22c1f7aeb5a3b682889aea26280f17a7a501e61dd9
3
+ metadata.gz: 740c3e556c963c534d68fb31863c36c6a75e6259a087a1d2f7c47ea8a6c1421d
4
+ data.tar.gz: 53d35a1db962f5270352d12aa8aa030f524f715a9b7fd33f75f84efcd1b5f7d6
5
5
  SHA512:
6
- metadata.gz: 1da76954e13e845fbc486d680c83fb7c24a1bb3f17a86f2e758ec199f38900cc53806ea8fc1dd4c8af39ed109e1364756c92f12c491d1a4a66f86f0984b48b6e
7
- data.tar.gz: 3ec51c71167f73fd8f8432e067d26900ce060fda03b4538efdc5f424aa4a28a8f4f33af343280a9b666b633c8b8bdb615f89c4fc2e338488352131366c7572fe
6
+ metadata.gz: 3bcd39b926964dfa310bdf7dcf6c6f89d01fbd2aaf3dff8e9a78a83dc09620c314f358bcfa000e0d2eb5432955991078d44dce676376a04a070082c8a32c4dc2
7
+ data.tar.gz: c512e7499709b099e8b8f29a271ed4e72d0c0ae990b38a2b46ce72698f5f78b3204b8e711a7e73a2956cfc266894e074a616f18d5c274654af179f3b2999cfd1
data/README.md CHANGED
@@ -8,28 +8,34 @@ This is the theme of the website of the *juice* programming language ([juicelang
8
8
  Add this line to your Jekyll site's `Gemfile`:
9
9
 
10
10
  ```ruby
11
- gem "juicelang-theme"
11
+ gem "juicelang-theme", "~> 0.4", group: :jekyll_plugins
12
12
  ```
13
13
 
14
- And add this line to your Jekyll site's `_config.yml`:
14
+ And add the following lines to your Jekyll site's `_config.yml`:
15
15
 
16
16
  ```yaml
17
17
  theme: juicelang-theme
18
+ plugins:
19
+ - juicelang-theme
18
20
  ```
19
21
 
20
- And then execute:
22
+ Then execute:
21
23
 
22
- $ bundle
24
+ ```bash
25
+ $ bundle install
26
+ ```
23
27
 
24
- Or install it yourself as:
28
+ Or install the gem yourself using:
25
29
 
26
- $ gem install juicelang-theme
30
+ ```bash
31
+ $ gem install juicelang-theme
32
+ ```
27
33
 
28
34
  ## Development
29
35
 
30
36
  To set up your environment to develop this theme, run `bundle install`.
31
37
 
32
- To test this 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 this theme's contents. As you make modifications to this theme and to your content, your site will regenerate and you should see the changes in the browser after a refresh, just like normal.
38
+ To test this theme, run `bundle exec jekyll serve --watch` 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 this theme's contents. As you make modifications to this theme and to your content, your site will regenerate and you should see the changes in the browser after a refresh, just like normal.
33
39
 
34
40
  ## License
35
41
 
data/_includes/nav.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <ul class="uk-nav-default" uk-nav='{"toggle": "> a.nav-parent-toggle"}''>
4
4
  {% assign navigation = site.data.navigation[include.navigation] %}
5
5
  {% assign indexPage = site.pages | find: "path", navigation.index_path %}
6
- <li class="uk-nav-header"><a href="{{ indexPage.url | absolute_url }}">{{ navigation.title }}</a></li>
6
+ <li class="uk-nav-header"><a href="{{ indexPage | url_without_ext }}">{{ navigation.title }}</a></li>
7
7
  {% include nav_list.html menu=navigation.menu accordion=true %}
8
8
  </ul>
9
9
  </div>
@@ -3,7 +3,7 @@
3
3
  {% if item.children %}
4
4
  {% assign active = itemPage | is_active?: item.children %}
5
5
  <li class="uk-parent{% if active %} uk-active uk-open{% endif %} uk-grid-collapse" uk-grid>
6
- <a href="{{ itemPage.url | absolute_url }}">{{ itemPage.title }}</a>
6
+ <a href="{{ itemPage | url_without_ext }}">{{ itemPage.title }}</a>
7
7
  {% if include.accordion %}
8
8
  <a href="#" class="nav-parent-toggle uk-width-expand"{% if active %} aria-expanded="true"{% endif %}><span uk-nav-parent-icon></span></a>
9
9
  {% endif %}
@@ -14,7 +14,7 @@
14
14
  {% else %}
15
15
  {% assign active = itemPage | is_active? %}
16
16
  <li{% if active %} class="uk-active"{% endif %}>
17
- <a href="{{ itemPage.url | absolute_url }}">{{ itemPage.title }}</a>
17
+ <a href="{{ itemPage | url_without_ext }}">{{ itemPage.title }}</a>
18
18
  </li>
19
19
  {% endif %}
20
20
  {% endfor %}
@@ -0,0 +1,23 @@
1
+ {% if page.nav %}
2
+ {% assign previousAndNext = page | previous_and_next: site.data.navigation[page.nav] %}
3
+ {% assign previous = previousAndNext['previous'] %}
4
+ {% assign next = previousAndNext['next'] %}
5
+ <div class="uk-container uk-container-small uk-margin-medium-top">
6
+ <ul class="uk-pagination">
7
+ {% if previous %}
8
+ <li>
9
+ <a href="{{ previous | url_without_ext }}">
10
+ <span class="uk-margin-small-right" uk-pagination-previous></span> Previous
11
+ </a>
12
+ </li>
13
+ {% endif %}
14
+ {% if next %}
15
+ <li class="uk-margin-auto-left">
16
+ <a href="{{ next | url_without_ext }}">
17
+ Next <span class="uk-margin-small-left" uk-pagination-next></span>
18
+ </a>
19
+ </li>
20
+ {% endif %}
21
+ </ul>
22
+ </div>
23
+ {% endif %}
@@ -0,0 +1,9 @@
1
+ {% unless page.no_toc %}
2
+ <div class="sidebar-right uk-visible@l">
3
+ <div uk-sticky="offset: 175">
4
+ <ul class="uk-nav uk-nav-default" uk-scrollspy-nav="closest: li; scroll: true; offset: 175">
5
+ {% toc %}
6
+ </ul>
7
+ </div>
8
+ </div>
9
+ {% endunless %}
@@ -10,20 +10,20 @@
10
10
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
11
11
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
12
12
 
13
- <link rel="apple-touch-icon" sizes="180x180" href="{{ '/assets/images/icons/apple-touch-icon.png' | relative_url }}">
14
- <link rel="icon" type="image/png" sizes="32x32" href="{{ '/assets/images/icons/favicon-32x32.png' | relative_url }}">
15
- <link rel="icon" type="image/png" sizes="16x16" href="{{ '/assets/images/icons/favicon-16x16.png' | relative_url }}">
16
- <link rel="manifest" href="{{ '/assets/images/icons/site.webmanifest' | relative_url }}">
17
- <link rel="mask-icon" href="{{ '/assets/images/icons/safari-pinned-tab.svg' | relative_url }}" color="#df8e15">
18
- <link rel="shortcut icon" href="{{ '/assets/images/icons/favicon.ico' | relative_url }}">
13
+ <link rel="apple-touch-icon" sizes="180x180" href="{{ '/assets/images/icons/apple-touch-icon.png' | absolute_url }}">
14
+ <link rel="icon" type="image/png" sizes="32x32" href="{{ '/assets/images/icons/favicon-32x32.png' | absolute_url }}">
15
+ <link rel="icon" type="image/png" sizes="16x16" href="{{ '/assets/images/icons/favicon-16x16.png' | absolute_url }}">
16
+ <link rel="manifest" href="{{ '/assets/images/icons/site.webmanifest' | absolute_url }}">
17
+ <link rel="mask-icon" href="{{ '/assets/images/icons/safari-pinned-tab.svg' | absolute_url }}" color="#df8e15">
18
+ <link rel="shortcut icon" href="{{ '/assets/images/icons/favicon.ico' | absolute_url }}">
19
19
  <meta name="apple-mobile-web-app-title" content="juicelang">
20
20
  <meta name="application-name" content="juicelang">
21
21
  <meta name="msapplication-TileColor" content="#df8e15">
22
- <meta name="msapplication-config" content="{{ '/assets/images/icons/browserconfig.xml' | relative_url }}">
22
+ <meta name="msapplication-config" content="{{ '/assets/images/icons/browserconfig.xml' | absolute_url }}">
23
23
  <meta name="theme-color" content="#df8e15" media="(prefers-color-scheme: light)">
24
24
  <meta name="theme-color" content="#02020b" media="(prefers-color-scheme: dark)">
25
25
 
26
- <link href="{{ '/assets/css/default.css' | relative_url }}" rel="stylesheet">
26
+ <link href="{{ '/assets/css/default.css' | absolute_url }}" rel="stylesheet">
27
27
  </head>
28
28
  <body>
29
29
  <nav class="uk-navbar-container uk-container uk-container-expand uk-navbar-transparent uk-light header" uk-navbar>
@@ -4,4 +4,5 @@ layout: default
4
4
 
5
5
  <div class="uk-container uk-container-expand content" uk-height-viewport="offset-top: true; offset-bottom: true">
6
6
  {{ content }}
7
+ {% include previous_and_next.html %}
7
8
  </div>
data/_layouts/page.html CHANGED
@@ -4,4 +4,6 @@ layout: default
4
4
 
5
5
  <div class="uk-container uk-container-small content" uk-height-viewport="offset-top: true; offset-bottom: true">
6
6
  {{ content }}
7
+ {% include toc.html %}
8
+ {% include previous_and_next.html %}
7
9
  </div>
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/juicelang-theme'
@@ -1,4 +1,4 @@
1
- $syntax-background-color: #272822;
1
+ $syntax-background-color: #181e25;
2
2
  $syntax-comment-color: #75715e;
3
3
  $syntax-error-color: #960050;
4
4
  $syntax-error-background-color: #1e0010;
@@ -30,11 +30,11 @@ $syntax-name-color: #a6e22e;
30
30
  .k {
31
31
  color: $syntax-keyword-color;
32
32
  }
33
-
33
+
34
34
  .l {
35
35
  color: $syntax-literal-color;
36
36
  }
37
-
37
+
38
38
  .n {
39
39
  color: $syntax-color-light;
40
40
  }
@@ -66,7 +66,7 @@ $syntax-name-color: #a6e22e;
66
66
  .ge {
67
67
  font-style: italic
68
68
  }
69
-
69
+
70
70
  .gs {
71
71
  font-weight: bold
72
72
  }
@@ -74,91 +74,91 @@ $syntax-name-color: #a6e22e;
74
74
  .kc {
75
75
  color: $syntax-keyword-color;
76
76
  }
77
-
77
+
78
78
  .kd {
79
79
  color: $syntax-keyword-color;
80
80
  }
81
-
81
+
82
82
  .kn {
83
83
  color: $syntax-operator-color;
84
84
  }
85
-
85
+
86
86
  .kp {
87
87
  color: $syntax-keyword-color;
88
88
  }
89
-
89
+
90
90
  .kr {
91
91
  color: $syntax-keyword-color;
92
92
  }
93
-
93
+
94
94
  .kt {
95
95
  color: $syntax-keyword-color;
96
96
  }
97
-
97
+
98
98
  .ld {
99
99
  color: $syntax-string-literal-color;
100
100
  }
101
-
101
+
102
102
  .m {
103
103
  color: $syntax-literal-color;
104
104
  }
105
-
105
+
106
106
  .s {
107
107
  color: $syntax-string-literal-color;
108
108
  }
109
-
109
+
110
110
  .na {
111
111
  color: $syntax-name-color;
112
112
  }
113
-
113
+
114
114
  .nb {
115
115
  color: $syntax-color-light;
116
116
  }
117
-
117
+
118
118
  .nc {
119
119
  color: $syntax-name-color;
120
120
  }
121
-
121
+
122
122
  .no {
123
123
  color: $syntax-keyword-color;
124
124
  }
125
-
125
+
126
126
  .nd {
127
127
  color: $syntax-name-color;
128
128
  }
129
-
129
+
130
130
  .ni {
131
131
  color: $syntax-color-light;
132
132
  }
133
-
133
+
134
134
  .ne {
135
135
  color: $syntax-name-color;
136
136
  }
137
-
137
+
138
138
  .nf {
139
139
  color: $syntax-name-color;
140
140
  }
141
-
141
+
142
142
  .nl {
143
143
  color: $syntax-color-light;
144
144
  }
145
-
145
+
146
146
  .nn {
147
147
  color: $syntax-color-light;
148
148
  }
149
-
149
+
150
150
  .nx {
151
151
  color: $syntax-name-color;
152
152
  }
153
-
153
+
154
154
  .py {
155
155
  color: $syntax-color-light;
156
156
  }
157
-
157
+
158
158
  .nt {
159
159
  color: $syntax-operator-color;
160
160
  }
161
-
161
+
162
162
  .nv {
163
163
  color: $syntax-color-light;
164
164
  }
@@ -166,87 +166,87 @@ $syntax-name-color: #a6e22e;
166
166
  .ow {
167
167
  color: $syntax-operator-color;
168
168
  }
169
-
169
+
170
170
  .w {
171
171
  color: $syntax-color-light;
172
172
  }
173
-
173
+
174
174
  .mf {
175
175
  color: $syntax-literal-color;
176
176
  }
177
-
177
+
178
178
  .mh {
179
179
  color: $syntax-literal-color;
180
180
  }
181
-
181
+
182
182
  .mi {
183
183
  color: $syntax-literal-color;
184
184
  }
185
-
185
+
186
186
  .mo {
187
187
  color: $syntax-literal-color;
188
188
  }
189
-
189
+
190
190
  .sb {
191
191
  color: $syntax-string-literal-color;
192
192
  }
193
-
193
+
194
194
  .sc {
195
195
  color: $syntax-string-literal-color;
196
196
  }
197
-
197
+
198
198
  .sd {
199
199
  color: $syntax-string-literal-color;
200
200
  }
201
-
201
+
202
202
  .s2 {
203
203
  color: $syntax-string-literal-color;
204
204
  }
205
-
205
+
206
206
  .se {
207
207
  color: $syntax-literal-color;
208
208
  }
209
-
209
+
210
210
  .sh {
211
211
  color: $syntax-string-literal-color;
212
212
  }
213
-
213
+
214
214
  .si {
215
215
  color: $syntax-string-literal-color;
216
216
  }
217
-
217
+
218
218
  .sx {
219
219
  color: $syntax-string-literal-color;
220
220
  }
221
-
221
+
222
222
  .sr {
223
223
  color: $syntax-string-literal-color;
224
224
  }
225
-
225
+
226
226
  .s1 {
227
227
  color: $syntax-string-literal-color;
228
228
  }
229
-
229
+
230
230
  .ss {
231
231
  color: $syntax-string-literal-color;
232
232
  }
233
-
233
+
234
234
  .bp {
235
235
  color: $syntax-color-light;
236
236
  }
237
-
237
+
238
238
  .vc {
239
239
  color: $syntax-color-light;
240
240
  }
241
-
241
+
242
242
  .vg {
243
243
  color: $syntax-color-light;
244
244
  }
245
-
245
+
246
246
  .vi {
247
247
  color: $syntax-color-light;
248
248
  }
249
-
249
+
250
250
  .il {
251
251
  color: $syntax-literal-color;
252
252
  }
@@ -254,11 +254,11 @@ $syntax-name-color: #a6e22e;
254
254
  .gu {
255
255
  color: $syntax-comment-color;
256
256
  }
257
-
257
+
258
258
  .gd {
259
259
  color: $syntax-operator-color;
260
260
  }
261
-
261
+
262
262
  .gi {
263
263
  color: $syntax-name-color;
264
264
  }
@@ -14,6 +14,8 @@ $base-heading-font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI
14
14
  $navbar-nav-item-font-family: $base-heading-font-family;
15
15
  $logo-font-family: $base-heading-font-family;
16
16
 
17
+ $global-secondary-background: #181e25;
18
+
17
19
  $inverse-logo-hover-color: rgba(white, .85);
18
20
  $logo-font-size: 4rem;
19
21
  $navbar-gap: 0;
@@ -236,6 +238,56 @@ $languages: "ebnf", "juice";
236
238
  margin-top: $margin-large-margin;
237
239
  }
238
240
 
241
+ .sidebar-right {
242
+ position: absolute;
243
+ left: unquote('calc(50% + #{$half-container-small-width} + 25px)');
244
+ right: 10px;
245
+ top: 0;
246
+ max-width: 250px;
247
+
248
+ ul.uk-nav {
249
+ & > li {
250
+ & > a {
251
+ position: relative;
252
+
253
+ &::before, &::after {
254
+ content: "";
255
+ position: absolute;
256
+ top: 100%;
257
+ bottom: 0;
258
+ left: -5px;
259
+ transition: all .2s ease-in-out;
260
+ }
261
+
262
+ &::before {
263
+ width: 0;
264
+ border-left: 1px solid #df8e15;
265
+ }
266
+
267
+ &::after {
268
+ right: 0;
269
+ background: linear-gradient(to right, rgba(#df8e15, .3), transparent);
270
+ }
271
+ }
272
+
273
+ &.uk-active {
274
+ & > a {
275
+ &::before, &::after {
276
+ top: 0;
277
+ }
278
+ }
279
+
280
+ & ~ li:not(.uk-active) > a {
281
+ &::before, &::after {
282
+ top: 0;
283
+ bottom: 100%;
284
+ }
285
+ }
286
+ }
287
+ }
288
+ }
289
+ }
290
+
239
291
  .highlighter-rouge {
240
292
  position: relative;
241
293
 
@@ -256,7 +308,7 @@ $languages: "ebnf", "juice";
256
308
  }
257
309
 
258
310
  .header {
259
- background: #181E25;
311
+ background: #181e25;
260
312
 
261
313
  .header-nav {
262
314
  color: #ee5a16;
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll'
4
+ require 'liquid'
5
+
6
+ module Jekyll
7
+ module CustomFilters
8
+ def is_active?(pageHash, children = nil)
9
+ page = pageFromHash(pageHash)
10
+ return true if page.equal? currentPage
11
+
12
+ isActiveRecursion? children
13
+ end
14
+
15
+ def find(input, property, targetValue = nil)
16
+ first(where(input, property, targetValue))
17
+ end
18
+
19
+ def previous_and_next(pageHash, nav)
20
+ result = {'previous' => nil, 'next' => nil}
21
+ page = pageFromHash(pageHash)
22
+
23
+ indexPage = pageFromHash(nav, 'index_path')
24
+
25
+ if page.equal? indexPage
26
+ result['next'] = pageFromHash(nav['menu'].first)
27
+ return result
28
+ end
29
+
30
+ flattenedMenu = flattenMenu(nav['menu'])
31
+
32
+ for i in 0...flattenedMenu.count
33
+ pageI = flattenedMenu[i]
34
+
35
+ if page.equal? pageI
36
+ result['previous'] = i == 0 ? indexPage : flattenedMenu[i - 1]
37
+ result['next'] = flattenedMenu[i + 1] unless i == flattenedMenu.count - 1
38
+ return result
39
+ end
40
+ end
41
+
42
+ result
43
+ end
44
+
45
+ def url_without_ext(pageHash)
46
+ page = pageFromHash(pageHash)
47
+ url = absolute_url(page.url)
48
+
49
+ return url.sub /\.x?html?$/, ''
50
+ end
51
+
52
+
53
+ private
54
+
55
+ include Liquid::StandardFilters
56
+ include Jekyll::Filters::URLFilters
57
+
58
+ def currentPage
59
+ pageFromHash(@context.registers[:page])
60
+ end
61
+
62
+ def site
63
+ @context.registers[:site]
64
+ end
65
+
66
+ def pageFromHash(hash, pathKey = 'path')
67
+ site.pages.find { |page|
68
+ page.path == hash[pathKey]
69
+ } unless hash.nil?
70
+ end
71
+
72
+ def isActiveRecursion?(children)
73
+ children && children.any? { |item|
74
+ pageFromHash(item).equal?(currentPage) || isActiveRecursion?(item['children'])
75
+ }
76
+ end
77
+
78
+ def flattenMenu(menu)
79
+ result = []
80
+
81
+ for item in menu
82
+ result.push(pageFromHash(item))
83
+ if item['children']
84
+ result.concat(flattenMenu(item['children']))
85
+ end
86
+ end
87
+
88
+ result
89
+ end
90
+ end
91
+ end
92
+
93
+ Liquid::Template.register_filter(Jekyll::CustomFilters)
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll'
4
+ require 'kramdown'
5
+ require 'liquid'
6
+
7
+ require_relative 'markdown_toc'
8
+
9
+
10
+ class ToCTag < Liquid::Tag
11
+ def initialize(tag_name, input, tokens)
12
+ super
13
+ end
14
+
15
+ def render(context)
16
+ toc = Kramdown::Document.new(context.registers[:page]['content'], {
17
+ input: "GFM"
18
+ }).to_ToC
19
+ build_list(toc.select { |item| item[0] == 2 }, toc.first[1])
20
+ end
21
+
22
+ private
23
+
24
+ def build_list(toc, topLink)
25
+ result = '<li class="uk-active"><a href="#' + topLink + '">Top</a></li>' + "\n"
26
+
27
+ for i in 0...toc.count
28
+ item = toc[i]
29
+ result += '<li><a href="#' + item[1] + '">' + item[2][0].value + "</a></li>\n"
30
+ end
31
+
32
+ result
33
+ end
34
+ end
35
+
36
+ Liquid::Template.register_tag('toc', ToCTag)
@@ -1,3 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll'
4
+ require 'rouge'
5
+
1
6
  Jekyll::Hooks.register :site, :pre_render do |site|
2
7
  require "rouge"
3
8
 
@@ -73,7 +78,7 @@ Jekyll::Hooks.register :site, :pre_render do |site|
73
78
  token Punctuation
74
79
  push :optional_rhs; push :expecting_symbol
75
80
  end
76
-
81
+
77
82
  rule %r/\{/ do
78
83
  token Punctuation
79
84
  push :repeating_rhs; push :expecting_symbol
@@ -1,3 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll'
4
+ require 'rouge'
5
+
1
6
  Jekyll::Hooks.register :site, :pre_render do |site|
2
7
  require "rouge"
3
8
 
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'custom_filters'
4
+ require_relative 'custom_tags'
5
+ require_relative 'ebnf_lexer'
6
+ require_relative 'juice_lexer'
7
+ require_relative 'markdown'
@@ -1,3 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll'
4
+ require 'kramdown'
5
+
1
6
  class Kramdown::Converter::CustomHtml < Kramdown::Converter::Html
2
7
  def convert_em(el, indent)
3
8
  "<span#{html_attributes(add_class(el.attr, "uk-text-italic"))}>#{inner(el, indent)}</span>"
@@ -15,19 +20,19 @@ class Kramdown::Converter::CustomHtml < Kramdown::Converter::Html
15
20
  def convert_thead(el, indent)
16
21
  format_as_indented_block_html(el.type, el.attr, inner(el, indent), indent)
17
22
  end
18
-
23
+
19
24
  def convert_tbody(el, indent)
20
25
  format_as_indented_block_html(el.type, el.attr, inner(el, indent), indent)
21
26
  end
22
-
27
+
23
28
  def convert_tfoot(el, indent)
24
29
  format_as_indented_block_html(el.type, el.attr, inner(el, indent), indent)
25
30
  end
26
-
31
+
27
32
  def convert_tr(el, indent)
28
33
  format_as_indented_block_html(el.type, el.attr, inner(el, indent), indent)
29
34
  end
30
-
35
+
31
36
 
32
37
  def add_class(attr, class_name)
33
38
  if attr.has_key?("class")
@@ -38,7 +43,7 @@ class Kramdown::Converter::CustomHtml < Kramdown::Converter::Html
38
43
  attr
39
44
  end
40
45
  end
41
-
46
+
42
47
  class Jekyll::Converters::Markdown::CustomMarkdown < Jekyll::Converters::Markdown
43
48
  def initialize(config)
44
49
  require 'kramdown'
@@ -48,7 +53,7 @@ class Jekyll::Converters::Markdown::CustomMarkdown < Jekyll::Converters::Markdow
48
53
  STDERR.puts ' $ [sudo] gem install kramdown'
49
54
  raise FatalException.new("Missing dependency: kramdown")
50
55
  end
51
-
56
+
52
57
  def convert(content)
53
58
  Kramdown::Document.new(content, {
54
59
  input: "GFM",
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll'
4
+ require 'kramdown'
5
+
6
+ class Kramdown::Converter::ToC < Kramdown::Converter::Html
7
+ def convert(el, indent = -@indent)
8
+ result = super
9
+ return result unless el.type == :root
10
+
11
+ @toc
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: juicelang-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Zoller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-30 00:00:00.000000000 Z
11
+ date: 2022-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: kramdown
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: liquid
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: webrick
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -64,14 +92,13 @@ files:
64
92
  - _includes/logo.html
65
93
  - _includes/nav.html
66
94
  - _includes/nav_list.html
95
+ - _includes/previous_and_next.html
96
+ - _includes/toc.html
67
97
  - _layouts/default.html
68
98
  - _layouts/fullwidth_page.html
69
99
  - _layouts/page.html
70
100
  - _layouts/post.html
71
- - _plugins/custom_filters.rb
72
- - _plugins/ebnf_lexer.rb
73
- - _plugins/juice_lexer.rb
74
- - _plugins/markdown.rb
101
+ - _plugins/juicelang-theme.rb
75
102
  - _sass/syntax-highlighting.scss
76
103
  - _sass/uikit/components/_import.components.scss
77
104
  - _sass/uikit/components/_import.scss
@@ -242,6 +269,13 @@ files:
242
269
  - assets/images/icons/site.webmanifest
243
270
  - assets/images/juice.svg
244
271
  - assets/js/default.js
272
+ - lib/custom_filters.rb
273
+ - lib/custom_tags.rb
274
+ - lib/ebnf_lexer.rb
275
+ - lib/juice_lexer.rb
276
+ - lib/juicelang-theme.rb
277
+ - lib/markdown.rb
278
+ - lib/markdown_toc.rb
245
279
  homepage: https://github.com/juice-lang/juicelang-theme
246
280
  licenses:
247
281
  - MIT
@@ -1,40 +0,0 @@
1
- module Jekyll
2
- module CustomFilters
3
- def is_active?(pageHash, children = nil)
4
- page = pageFromHash(pageHash)
5
- return true if page.equal? currentPage
6
-
7
- isActiveRecursion? children
8
- end
9
-
10
- def find(input, property, targetValue = nil)
11
- standardFilters = Class.new.extend(Liquid::StandardFilters)
12
- standardFilters.first(standardFilters.where(input, property, targetValue))
13
- end
14
-
15
-
16
- private
17
-
18
- def currentPage
19
- pageFromHash(@context.registers[:page])
20
- end
21
-
22
- def site
23
- @context.registers[:site]
24
- end
25
-
26
- def pageFromHash(hash)
27
- site.pages.find { |page|
28
- page.path == hash['path']
29
- }
30
- end
31
-
32
- def isActiveRecursion?(children)
33
- children && children.any? { |item|
34
- pageFromHash(item).equal?(currentPage) || isActiveRecursion?(item['children'])
35
- }
36
- end
37
- end
38
- end
39
-
40
- Liquid::Template.register_filter(Jekyll::CustomFilters)