fossbook 0.0.8 → 0.0.9
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.
- package/README.md +15 -0
- package/lib/mod/marked.js +21 -0
- package/package.json +1 -1
- package/themes/archie/layouts/post.html +4 -0
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ It was originally part of the [F/OSS Comics blog](https://fosscomics.com) and is
|
|
|
13
13
|
- **GitHub Pages** — Built-in CNAME support for custom domains
|
|
14
14
|
- **Dev server** — Local preview server with Express
|
|
15
15
|
- **Syntax highlighting** — Code block highlighting via highlight.js
|
|
16
|
+
- **Mermaid diagrams** — ` ```mermaid ` code blocks render as diagrams
|
|
16
17
|
|
|
17
18
|
## Quick Start
|
|
18
19
|
|
|
@@ -147,6 +148,20 @@ This affects the generated output directory, the post URL, post links on the
|
|
|
147
148
|
home/all-posts/tag pages, and image paths. The on-disk source layout under
|
|
148
149
|
`content/posts/` does not change.
|
|
149
150
|
|
|
151
|
+
### Mermaid diagrams
|
|
152
|
+
|
|
153
|
+
Fenced code blocks tagged `mermaid` are rendered as diagrams instead of code.
|
|
154
|
+
The [Mermaid](https://mermaid.js.org) script is loaded from a CDN only on pages
|
|
155
|
+
that contain a diagram.
|
|
156
|
+
|
|
157
|
+
````markdown
|
|
158
|
+
```mermaid
|
|
159
|
+
sequenceDiagram
|
|
160
|
+
Alice->>Bob: Hello Bob
|
|
161
|
+
Bob-->>Alice: Hi Alice
|
|
162
|
+
```
|
|
163
|
+
````
|
|
164
|
+
|
|
150
165
|
## CLI Reference
|
|
151
166
|
|
|
152
167
|
```
|
package/lib/mod/marked.js
CHANGED
|
@@ -18,6 +18,27 @@ marked.setOptions({
|
|
|
18
18
|
|
|
19
19
|
// Override function
|
|
20
20
|
const renderer = {
|
|
21
|
+
code(code, infostring) {
|
|
22
|
+
// marked >=15 passes a token object; older versions pass positional args.
|
|
23
|
+
let text = code;
|
|
24
|
+
let lang = infostring;
|
|
25
|
+
if (code && typeof code === "object") {
|
|
26
|
+
text = code.text;
|
|
27
|
+
lang = code.lang;
|
|
28
|
+
}
|
|
29
|
+
const language = (lang || "").trim().split(/\s+/)[0];
|
|
30
|
+
// Emit mermaid fenced blocks as <pre class="mermaid"> so the mermaid
|
|
31
|
+
// client script can render them as diagrams instead of code.
|
|
32
|
+
if (language === "mermaid") {
|
|
33
|
+
const escaped = text
|
|
34
|
+
.replace(/&/g, "&")
|
|
35
|
+
.replace(/</g, "<")
|
|
36
|
+
.replace(/>/g, ">");
|
|
37
|
+
return `<pre class="mermaid">${escaped}</pre>`;
|
|
38
|
+
}
|
|
39
|
+
// Fall back to marked's default code rendering for everything else.
|
|
40
|
+
return false;
|
|
41
|
+
},
|
|
21
42
|
image(href, title, text) {
|
|
22
43
|
let size = null;
|
|
23
44
|
// Check if the title contains a size specification
|
package/package.json
CHANGED
|
@@ -78,5 +78,9 @@
|
|
|
78
78
|
${page.footer()}
|
|
79
79
|
</footer>
|
|
80
80
|
</div>
|
|
81
|
+
${page.body.includes('class="mermaid"') ? `<script type="module">
|
|
82
|
+
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
|
|
83
|
+
mermaid.initialize({ startOnLoad: true });
|
|
84
|
+
</script>` : ""}
|
|
81
85
|
</body>
|
|
82
86
|
</html>
|