Skip to content

Commit

Permalink
use vscode-markdown-it-katex to render KaTex
Browse files Browse the repository at this point in the history
  • Loading branch information
ZekeLu committed Nov 10, 2024
1 parent 373a7f1 commit cb6d9a5
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* [markdown-it-checkbox](https://github.com/mcecot/markdown-it-checkbox)
* [markdown-it-container](https://github.com/markdown-it/markdown-it-container)
* [markdown-it-include](https://github.com/camelaissani/markdown-it-include)
* [markdown-it-katex](https://github.com/microsoft/vscode-markdown-it-katex)
* [PlantUML](https://plantuml.com/)
* [markdown-it-plantuml](https://github.com/gmunguia/markdown-it-plantuml)
* [mermaid](https://mermaid-js.github.io/mermaid/)
Expand Down Expand Up @@ -105,6 +106,21 @@ Content of plugins/README.md
Content of CHANGELOG.md
```

### markdown-it-katex

INPUT

```
$$
\sqrt{3x-1}+(1+x)^2
$$
```

OUTPUT

![katex](images/katex.png)


### mermaid

INPUT
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Supports the following features
* [markdown-it-checkbox](https://github.com/mcecot/markdown-it-checkbox)
* [markdown-it-container](https://github.com/markdown-it/markdown-it-container)
* [markdown-it-include](https://github.com/camelaissani/markdown-it-include)
* [markdown-it-katex](https://github.com/microsoft/vscode-markdown-it-katex)
* [PlantUML](https://plantuml.com/)
* [markdown-it-plantuml](https://github.com/gmunguia/markdown-it-plantuml)
* [mermaid](https://mermaid-js.github.io/mermaid/)
Expand Down Expand Up @@ -107,6 +108,20 @@ Content of plugins/README.md
Content of CHANGELOG.md
```

### markdown-it-katex

INPUT

```
$$
\sqrt{3x-1}+(1+x)^2
$$
```

OUTPUT

![katex](images/katex.png)

### mermaid

INPUT
Expand Down
Binary file added images/katex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 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 @@ -494,6 +494,7 @@
"vscode-test": "^1.3.0"
},
"dependencies": {
"@vscode/markdown-it-katex": "^1.1.0",
"cheerio": "^0.20.0",
"emoji-images": "^0.1.1",
"gray-matter": "^4.0.2",
Expand Down
3 changes: 3 additions & 0 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ function convertMarkdownToHtml(filename, type, text) {
// checkbox
md.use(require('markdown-it-checkbox'));

// katex
md.use(require('@vscode/markdown-it-katex').default);

// emoji
var emoji_f = setBooleanValue(matterParts.data.emoji, vscode.workspace.getConfiguration('markdown-pdf')['emoji']);
if (emoji_f) {
Expand Down
1 change: 1 addition & 0 deletions template/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>{{{title}}}</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
{{{style}}}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+" crossorigin="anonymous">
{{{mermaid}}}
</head>
<body>
Expand Down

0 comments on commit cb6d9a5

Please sign in to comment.