Skip to content

Commit 9a18895

Browse files
Merge pull request #210 from MaddyGuthridge/maddy-marked-katex
Use katex in markdown rendering
2 parents 19c3f51 + 9535c06 commit 9a18895

File tree

5 files changed

+44
-23
lines changed

5 files changed

+44
-23
lines changed

package-lock.json

Lines changed: 32 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "minifolio",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"private": true,
55
"license": "GPL-3.0-only",
66
"scripts": {
@@ -28,6 +28,7 @@
2828
"marked": "^16.2.1",
2929
"marked-custom-heading-id": "^2.0.15",
3030
"marked-gfm-heading-id": "^4.1.2",
31+
"marked-katex-extension": "^5.1.5",
3132
"marked-smartypants-lite": "^1.0.3",
3233
"mermaid": "^11.10.1",
3334
"mime-types": "^3.0.1",

src/app.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<head>
55
<meta charset="utf-8" />
66
<!-- LineAwesome -->
7-
<link rel= "stylesheet" href= "https://maxst.icons8.com/vue-static/landings/line-awesome/line-awesome/1.3.0/css/line-awesome.min.css" >
7+
<link rel= "stylesheet" href= "https://maxst.icons8.com/vue-static/landings/line-awesome/line-awesome/1.3.0/css/line-awesome.min.css" ><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css" integrity="sha384-GvrOXuhMATgEsSwCs4smul74iXGOixntILdUW9XmUC6+HX0sLNAK3q71HotJqlAn" crossorigin="anonymous">
8+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css" integrity="sha384-GvrOXuhMATgEsSwCs4smul74iXGOixntILdUW9XmUC6+HX0sLNAK3q71HotJqlAn" crossorigin="anonymous">
89
<meta name="viewport" content="width=device-width, initial-scale=1" />
910
%sveltekit.head%
1011
</head>

src/components/markdown/Markdown.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import customHeadingId from 'marked-custom-heading-id';
77
// GitHub-flavoured Markdown, automatic heading IDs
88
import { gfmHeadingId } from 'marked-gfm-heading-id';
9+
// Katex (math rendering)
10+
import markedKatex from 'marked-katex-extension';
911
// Smartypants quotation marks and the like
1012
import { markedSmartypantsLite } from 'marked-smartypants-lite';
1113
import markedMermaid from '@maddyguthridge/marked-mermaid';
@@ -31,12 +33,17 @@
3133
},
3234
};
3335
36+
const katexOptions = {
37+
throwOnError: false,
38+
};
39+
3440
// Specifically instantiate a new `Marked` instance to avoid exceeding the call stack
3541
const marked = new Marked(
3642
gfmHeadingId(),
3743
customHeadingId(),
3844
markedSmartypantsLite(),
3945
markedMermaid(),
46+
markedKatex(katexOptions),
4047
{ renderer },
4148
);
4249

src/routes/[...item]/+page.svelte

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
import api from '$endpoints';
1212
import consts from '$lib/consts';
1313
import DelayedUpdater from '$lib/delayedUpdate';
14-
import {
15-
applyFiltersToItemChildren,
16-
createItemFilter,
17-
} from '$lib/itemFilter';
14+
import { applyFiltersToItemChildren, createItemFilter } from '$lib/itemFilter';
1815
import itemId from '$lib/itemId';
1916
import { generateKeywords, getDescription } from '$lib/seo';
2017
import type { ItemInfo } from '$lib/server/data/item';

0 commit comments

Comments
 (0)