hematite 0.1.3 → 0.1.6

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: 7c31b77be5a329f70985b04f78078a87cf74d79c1f462018d8eed576e18efadc
4
- data.tar.gz: 643ca6f28aaf67740b9e71b9de4a0f21bbe08f0f139b95e7b67819b28f9b1648
3
+ metadata.gz: 8764d5501c8a2e08a066ff8a3c595e6301544f302a3073505947faa226cd95d9
4
+ data.tar.gz: fd4b02059497fd70358abbd0dc7e753e4631c4c8c95347cb1cd201dc56ea9383
5
5
  SHA512:
6
- metadata.gz: 3200f91d6ddd479b360c08b74862ff2a1260d45a92d3e84aa5c9686556cea7303835129c10329bd1b84d0cf965225eeb0808771f4d8edb338870feeb2d9c52e2
7
- data.tar.gz: 79a331beca39bdfb4c1f8fb9447a3f04f9f36cb7f17856103b24353c875bc2ca36a77f866613d03d11daa3fff95a45de727d4a7a977eb022f5f4df31f09590d7
6
+ metadata.gz: 8e00a63422072524a31554c16c036b0be5a30f3e344cb955354b452506cc735a8eaf48e3ffb77a0c553209bd74596603c44322bf1ec231f5eacea3ad6d9a2b15
7
+ data.tar.gz: ec4c74f00d80c83f563727b0415a88408285bf849b8792e454335b582ffb4905a9b06a1708f2ede5d39935b6a87531a6ba2088ccced0ac4c05d66b348ad94368
@@ -5,3 +5,40 @@
5
5
 
6
6
  {% include mermaid_includes.html %}
7
7
  {% include katex_includes.html %}
8
+
9
+ <!-- Page/site-specific imports and configuration -->
10
+ {{ site.additional_import_html | default: "" }}
11
+ {{ layout.additional_import_html | default: "" }}
12
+ {{ page.additional_import_html | default: "" }}
13
+
14
+ {% comment %}
15
+ Each [spec]=["key", { property: value, property2: value2, ... }]
16
+ {% endcomment %}
17
+ {% for spec in layout.additional_imports | concat: page.additional_imports %}
18
+ {% assign target = spec[1] %}
19
+ {% if target.type == 'js' or target.type == 'mjs' %}
20
+ {% assign tag="script" %}
21
+ {% assign url_spec = "src" %}
22
+ {% assign options = "" %}
23
+ {% else %}
24
+ {% assign tag="link" %}
25
+ {% assign options = "rel='stylesheet'" %}
26
+ {% assign url_spec = "href" %}
27
+ {% endif %}
28
+
29
+ {% if target.type == 'mjs' %}
30
+ {% assign options = "type = 'module'" %}
31
+ {% endif %}
32
+
33
+ {% if target.absolute_url %}
34
+ {% assign url = target.absolute_url %}
35
+ {% else %}
36
+ {% assign url = target.url | relative_url %}
37
+ {% endif %}
38
+
39
+ <{{ tag }} {{ options }}
40
+ {{ target.inline_options | default: "" }}
41
+ {{url_spec}}={{ url | jsonify }}
42
+ onload={{ target.onload | default: "" | jsonify }}></{{tag}}>
43
+ {% endfor %}
44
+
@@ -4,7 +4,7 @@
4
4
  KaTeX can be enabled with page.katex.
5
5
  -->
6
6
 
7
- {% if page.katex || site.mermaid %}
7
+ {% if page.katex or layout.katex or site.mermaid %}
8
8
 
9
9
  <!-- See the releases tab on https://github.com/KaTeX/KaTeX -->
10
10
  <link
@@ -2,7 +2,7 @@
2
2
  <!--
3
3
  Include mermaid-js scripts.
4
4
  -->
5
- {% if page.mermaid || site.mermaid %}
5
+ {% if page.mermaid or site.mermaid or layout.mermaid %}
6
6
  <script>
7
7
  var MERMAID_CONFIG = window.MERMAID_CONFIG ?? {{ site.mermaid_config | jsonify }} ?? { };
8
8
 
@@ -0,0 +1,43 @@
1
+ ---
2
+ layout: remark_slideshow
3
+ additional_imports:
4
+ katex:
5
+ type: js
6
+ url: /assets/plugin/katex/katex.min.js
7
+ katex_auto_init_math:
8
+ type: js
9
+ url: /assets/plugin/katex/contrib/auto-render.min.js
10
+ onload: renderMathInElement(document.body)
11
+ inline_options: defer
12
+ comment: >-
13
+ We're passing 'defer' above because we want this script to load
14
+ _after_ the body.
15
+ katex_css:
16
+ type: css
17
+ url: /assets/plugin/katex/katex.min.css
18
+
19
+ remark_presentation_config:
20
+ navigation:
21
+ scroll: false
22
+ slideNumberFormat: "Slide %current% of %total%."
23
+
24
+ mermaid: true
25
+ remark_presentation_config_html: >-
26
+ Testing...
27
+ ---
28
+
29
+ {% comment %}
30
+ This template is an example of how to customize remark slideshows
31
+ by creating a new template.
32
+
33
+ `additional_imports` can be used on any page. In this case, the imports
34
+ are included both in the remark presentation `iframe` and in the main page.
35
+
36
+ Of course, we could include `katex` or `mermaid` here by setting `katex: true`
37
+ or `mermaid: true` in the header`, but `additional_imports` is another way to
38
+ specify this.
39
+
40
+ Note that `remark_presentation_config` is passed directly to remark.
41
+ {% endcomment %}
42
+
43
+ {{ content }}
@@ -3,6 +3,14 @@ layout: default
3
3
  ---
4
4
 
5
5
  <!-- Defines a https://remarkjs.com/ slideshow -->
6
+ <!--
7
+ Configure remark with
8
+ page.remark_presentation_config, site.remark_presentation_config,
9
+ page.remark_presentation_config_html
10
+
11
+ Note: Jekyll's default parser must not parse the input markdown file.
12
+ Either use a non-md extension or wrap its content in a <div markdown=false>...</div>
13
+ -->
6
14
 
7
15
  {% assign frame_resource_url = 'assets/html/remark_presentation_frame.html.resource' | relative_url %}
8
16
 
@@ -12,17 +20,51 @@ layout: default
12
20
  onload="window.presentationFrameLoaded = true;"></iframe>
13
21
  </main>
14
22
 
23
+ <!--
24
+ Liquid (sometimes?) does not handle unicode (e.g. π) characters properly when using
25
+ url_encode (or at least not consistently with JS's unescape), so include
26
+ content directly:
27
+ -->
28
+ <textarea id="source" style="display: none;">
29
+ {{content}}
30
+ </textarea>
31
+
15
32
  <script defer type="module">
33
+ // Matches <div>...</div> or <div markdown=0>...</div>
34
+ // Jekyll can remove the 'markdown=0' while parsing.
35
+ const WRAPPING_DIV_EXP = /\s*[<]div.*[>]((?:.|[\n\r])*)[<]\/div[>]\s*/;
36
+
16
37
  import slideshow from "{{ 'assets/js/layout/remark_slideshow.mjs' | relative_url }}";
17
38
 
18
39
  let presentationFrame = document.querySelector("#presentation_frame");
19
40
  presentationFrame.src = {{ frame_resource_url | jsonify }};
20
41
  window.presentationFrameLoaded = false;
21
42
 
22
- let config = {{ page.remark_presentation_config | default: site.remark_presentation_config | jsonify }};
23
- config ??= {};
24
43
 
25
- config.source = {{ page.content | jsonify }};
44
+ let siteConfig = {{ site.remark_presentation_config | jsonify }} ?? {};
45
+ let layoutConfig = {{ layout.remark_presentation_config | jsonify }} ?? {};
46
+ let pageConfig = {{ page.remark_presentation_config | jsonify }} ?? {};
47
+ let config = {};
48
+
49
+ // Merge the remark configurations. siteConfig has highest precedence.
50
+ for (let currentConfig of [siteConfig, layoutConfig, pageConfig]) {
51
+ for (let key in currentConfig) {
52
+ config[key] = currentConfig[key];
53
+ }
54
+ }
55
+
56
+ console.log(config);
57
+
58
+ // Escape the content to prevent liquid from rendering it.
59
+ config.source = document.querySelector("#source").value;
60
+
61
+ // Unwrap if surrounded by markdown-parser-disabling HTML
62
+ let markdownDisableMatches = config.source.match(WRAPPING_DIV_EXP);
63
+
64
+ // Replace with first capture (contents of the wrapping element).
65
+ if (markdownDisableMatches && markdownDisableMatches.length > 0) {
66
+ config.source = markdownDisableMatches[1];
67
+ }
26
68
 
27
69
  // Library imports intended for this page: Forward to the frame.
28
70
  let libraryImports = unescape(`
@@ -47,6 +89,19 @@ layout: default
47
89
  presentationDoc.write("<!DOCTYPE html>");
48
90
  presentationDoc.write(slideshowHtml);
49
91
  presentationDoc.write(libraryImports);
92
+
93
+ // Any additional configuration scripts/html specific to remark
94
+ presentationDoc.write(unescape(
95
+ {{
96
+ page.remark_presentation_config_html | default: site.remark_presentation_config_html | default: "" | url_encode | replace: "+", " " | jsonify
97
+ }}
98
+ ));
99
+
100
+ // If another layout extends this layout,
101
+ presentationDoc.write(unescape(
102
+ {{ layout.remark_presentation_config_html | default: "" | url_encode | replace: "+", " " | jsonify }}
103
+ ));
104
+
50
105
  presentationDoc.write(`
51
106
  <${"script"}>
52
107
  if (window.MERMAID_CONFIG) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hematite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Heino
@@ -48,6 +48,7 @@ files:
48
48
  - _includes/settings.html
49
49
  - _layouts/calendar.html
50
50
  - _layouts/default.html
51
+ - _layouts/example_custom_remark_slideshow.html
51
52
  - _layouts/home.html
52
53
  - _layouts/page.html
53
54
  - _layouts/post.html