hematite 0.1.4 → 0.1.7

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: 57c0b3ae9bdec4a2e37d649a52dfbacb84a8c09b258d2a5bb676571c5fed060d
4
- data.tar.gz: '09bc9aa4956973f5cbb3dfa1e4889b9adfe70928eb5f2f25518b09b863a4e8ed'
3
+ metadata.gz: 05a0aa60a85dd027a9a75e119e54432b2ea0657775d872ae3b0474e9ebab9a5a
4
+ data.tar.gz: 2d93683789b2ecff19bcc54608484e64889488a151f3f668596d3df79a5fcf90
5
5
  SHA512:
6
- metadata.gz: 86065a34d00cc7d8844bdd02883dc7c8dd25c4c6436a1d4b28747d0140d4409d0ac7e7a910d8fe4f54ba546c303208cb347d598141a6e66b1d0c5607e282f249
7
- data.tar.gz: 2b218f88fec888c6029650fdd29b0809729cd321905e25e9151e26173347e7488813eebcc79d32c7ced657d8a4ce7a0e2acb4b9386e9d683607b6622e6911784
6
+ metadata.gz: 51770f1f5812dae37c4ff1eaf87c36f799cbb5ed73dbb45bb16cb3517dc34bf3d305c6d2a54fe4baeb2f6e4c623e6e271b7db9b2cdb60b078c326a88b97ce11b
7
+ data.tar.gz: ab0ccb98a0ab44a07d6e1d86c32ef42ab68f3bf0ec1fb626ca53a913c4d4c00fd0602c9373dbfac64af0b7b98b684dd4be523dd6d91fc51825422b8571bd3aeb
@@ -8,4 +8,40 @@
8
8
 
9
9
  <!-- Page/site-specific imports and configuration -->
10
10
  {{ site.additional_import_html | default: "" }}
11
+ {{ layout.additional_import_html | default: "" }}
11
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
+ {% if target.context and target.context != include.context %}
40
+ {% else %}
41
+ <{{ tag }} {{ options }}
42
+ {{ target.inline_options | default: "" }}
43
+ {{url_spec}}={{ url | jsonify }}
44
+ onload={{ target.onload | default: "" | jsonify }}></{{tag}}>
45
+ {% endif %}
46
+ {% endfor %}
47
+
@@ -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,47 @@
1
+ ---
2
+ layout: remark_slideshow
3
+ additional_imports:
4
+ katex:
5
+ type: js
6
+ url: /assets/plugin/katex/katex.min.js
7
+ context: remark_frame
8
+ comment: >-
9
+ Setting context to remark_frame means to only run this
10
+ in the remark-specific iframe.
11
+ katex_auto_init_math:
12
+ type: js
13
+ url: /assets/plugin/katex/contrib/auto-render.min.js
14
+ onload: renderMathInElement(document.body)
15
+ inline_options: defer
16
+ comment: >-
17
+ We're passing 'defer' above because we want this script to load
18
+ _after_ the body.
19
+ katex_css:
20
+ type: css
21
+ url: /assets/plugin/katex/katex.min.css
22
+
23
+ remark_presentation_config:
24
+ navigation:
25
+ scroll: false
26
+ slideNumberFormat: "Slide %current% of %total%."
27
+
28
+ mermaid: true
29
+ remark_presentation_config_html: >-
30
+ Testing... This should be included at the top of the file.
31
+ ---
32
+
33
+ {% comment %}
34
+ This template is an example of how to customize remark slideshows
35
+ by creating a new template.
36
+
37
+ `additional_imports` can be used on any page. In this case, the imports
38
+ are included both in the remark presentation `iframe` and in the main page.
39
+
40
+ Of course, we could include `katex` or `mermaid` here by setting `katex: true`
41
+ or `mermaid: true` in the header`, but `additional_imports` is another way to
42
+ specify this.
43
+
44
+ Note that `remark_presentation_config` is passed directly to remark.
45
+ {% endcomment %}
46
+
47
+ {{ content }}
@@ -3,9 +3,13 @@ layout: default
3
3
  ---
4
4
 
5
5
  <!-- Defines a https://remarkjs.com/ slideshow -->
6
- <!-- Configure remark with
6
+ <!--
7
+ Configure remark with
7
8
  page.remark_presentation_config, site.remark_presentation_config,
8
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>
9
13
  -->
10
14
 
11
15
  {% assign frame_resource_url = 'assets/html/remark_presentation_frame.html.resource' | relative_url %}
@@ -16,23 +20,54 @@ layout: default
16
20
  onload="window.presentationFrameLoaded = true;"></iframe>
17
21
  </main>
18
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
+
19
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
+
20
37
  import slideshow from "{{ 'assets/js/layout/remark_slideshow.mjs' | relative_url }}";
21
38
 
22
39
  let presentationFrame = document.querySelector("#presentation_frame");
23
40
  presentationFrame.src = {{ frame_resource_url | jsonify }};
24
41
  window.presentationFrameLoaded = false;
25
42
 
26
- let config =
27
- {{ page.remark_presentation_config | default: site.remark_presentation_config | jsonify }};
28
- config ??= {};
29
43
 
30
- 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
+ // Escape the content to prevent liquid from rendering it.
57
+ config.source = document.querySelector("#source").value;
58
+
59
+ // Unwrap if surrounded by markdown-parser-disabling HTML
60
+ let markdownDisableMatches = config.source.match(WRAPPING_DIV_EXP);
61
+
62
+ // Replace with first capture (contents of the wrapping element).
63
+ if (markdownDisableMatches && markdownDisableMatches.length > 0) {
64
+ config.source = markdownDisableMatches[1];
65
+ }
31
66
 
32
67
  // Library imports intended for this page: Forward to the frame.
33
68
  let libraryImports = unescape(`
34
69
  {% capture library_imports %}
35
- {% include extern_library_imports.html %}
70
+ {% include extern_library_imports.html context='remark_frame' %}
36
71
  {% endcapture %}
37
72
  {{ library_imports | url_encode | replace: "+", " " }}
38
73
  `);
@@ -55,7 +90,14 @@ layout: default
55
90
 
56
91
  // Any additional configuration scripts/html specific to remark
57
92
  presentationDoc.write(unescape(
58
- {{ page.remark_presentation_config_html | default: "" | url_encode | replace: "+", " " | jsonify }}
93
+ {{
94
+ page.remark_presentation_config_html | default: site.remark_presentation_config_html | default: "" | url_encode | replace: "+", " " | jsonify
95
+ }}
96
+ ));
97
+
98
+ // If another layout extends this layout,
99
+ presentationDoc.write(unescape(
100
+ {{ layout.remark_presentation_config_html | default: "" | url_encode | replace: "+", " " | jsonify }}
59
101
  ));
60
102
 
61
103
  presentationDoc.write(`
@@ -67,8 +109,8 @@ layout: default
67
109
  }
68
110
  </${"script"}>
69
111
  `);
70
- presentationDoc.close();
71
- (async () => {
112
+
113
+ presentationWin.initPresentation = (async () => {
72
114
  await slideshow.start(presentationFrame.contentWindow, config);
73
115
 
74
116
  // Ensure that mermaid has already been run!
@@ -76,7 +118,14 @@ layout: default
76
118
  presentationWin.mermaid.init();
77
119
  console.log("Ran mermaid!");
78
120
  }
79
- })();
121
+ });
122
+
123
+ presentationDoc.write(`
124
+ <${"script"}>
125
+ window.initPresentation();
126
+ </${"script"}>
127
+ `);
128
+ presentationDoc.close();
80
129
  };
81
130
 
82
131
  if (window.presentationFrameLoaded) {
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.4
4
+ version: 0.1.7
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