Skip to content

Commit

Permalink
🧮 - Add KaTeX for MathML in markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
xdesro committed Oct 19, 2023
1 parent 3dc7dc3 commit 013289e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const markdownRenderer = require('markdown-it')({
typographer: true,
breaks: true
})
.use(require('markdown-it-katex'))
.use(require('markdown-it-attrs'))
.use(require('markdown-it-implicit-figures'));

Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"editor.formatOnSave": true
"editor.formatOnSave": false
}
48 changes: 48 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@11ty/eleventy": "^2.0.0",
"@11ty/eleventy-plugin-vue": "^0.2.2",
"@dogstudio/highway": "^2.2.1",
"@iktakahiro/markdown-it-katex": "^4.0.1",
"concurrently": "^5.3.0",
"contentful": "^8.1.7",
"core-js": "^3.8.2",
Expand Down
2 changes: 2 additions & 0 deletions src/_includes/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
<link rel="preload" href="/fonts/neue-haas-grotesk/neue-haas-grotesk-bold.woff2" as="font" type="font/woff2"
crossorigin />
<link rel="stylesheet" href="/css/index.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css">

<script>
if (localStorage.getItem('darkMode') == 'true')
document.documentElement.setAttribute('dark', true);
Expand Down
2 changes: 2 additions & 0 deletions src/_lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const markdownRenderer = require('markdown-it')({
typographer: true,
breaks: true
})
.use(require('@iktakahiro/markdown-it-katex'), { throwOnError: true, output: 'mathml' })
.use(require('markdown-it-attrs'))
.use(require('markdown-it-implicit-figures'))
.use(require('markdown-it-anchor'), {
Expand All @@ -22,3 +23,4 @@ const dateFormatter = dateString => {
});
};
export { markdownRenderer, dateFormatter };

0 comments on commit 013289e

Please sign in to comment.