@cobapen/markdown 0.6.4 → 0.7.0
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/lib/index.d.ts +1 -2
- package/lib/index.js +3 -5
- package/lib/math/mdmath.d.ts +2 -2
- package/lib/math/mdmath.js +7 -12
- package/package.json +3 -4
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Options as MathOptions } from "@cobapen/math";
|
|
1
2
|
import markdownIt, { Options as MarkdownOptions } from "markdown-it";
|
|
2
3
|
import { ReplaceHandler } from "./link/replacelink.js";
|
|
3
|
-
import { Options as MathOptions } from "./math/mathjax.js";
|
|
4
4
|
export interface Config {
|
|
5
5
|
showCodeTitleByDefault: boolean;
|
|
6
6
|
linkRewrite?: ReplaceHandler;
|
|
@@ -18,6 +18,5 @@ export declare class CMarkdown {
|
|
|
18
18
|
constructor(option?: Options);
|
|
19
19
|
setup(md: markdownIt): void;
|
|
20
20
|
render(text: string, opt?: Partial<RenderOptions>): string;
|
|
21
|
-
waitMathInit(): Promise<void>;
|
|
22
21
|
mathcss(): string;
|
|
23
22
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MathJaxEngine } from "@cobapen/math";
|
|
1
2
|
import markdownIt from "markdown-it";
|
|
2
3
|
import advTable from "markdown-it-adv-table";
|
|
3
4
|
import anchor from "markdown-it-anchor";
|
|
@@ -8,8 +9,8 @@ import { cjk_break } from "./cjk-break/cjk-break.js";
|
|
|
8
9
|
import { fence_custom } from "./code/fence-custom.js";
|
|
9
10
|
import { highlighterForMarkdownIt } from "./code/highlight.js";
|
|
10
11
|
import { replacelink } from "./link/replacelink.js";
|
|
11
|
-
import { MathjaxEngine } from "./math/mathjax.js";
|
|
12
12
|
import { mdmath } from "./math/mdmath.js";
|
|
13
|
+
await MathJaxEngine.loadExtensions();
|
|
13
14
|
const defaultOptions = {
|
|
14
15
|
showCodeTitleByDefault: false,
|
|
15
16
|
markdown: {
|
|
@@ -34,7 +35,7 @@ export class CMarkdown {
|
|
|
34
35
|
_md;
|
|
35
36
|
constructor(option) {
|
|
36
37
|
const config = { ...defaultOptions, ...option };
|
|
37
|
-
const mj = new
|
|
38
|
+
const mj = new MathJaxEngine(config.math);
|
|
38
39
|
const md = markdownIt(config.markdown);
|
|
39
40
|
this._config = config;
|
|
40
41
|
this._mj = mj;
|
|
@@ -60,9 +61,6 @@ export class CMarkdown {
|
|
|
60
61
|
const env = { ...opt };
|
|
61
62
|
return this._md.render(text, env);
|
|
62
63
|
}
|
|
63
|
-
async waitMathInit() {
|
|
64
|
-
return this._mj.waitInit();
|
|
65
|
-
}
|
|
66
64
|
mathcss() {
|
|
67
65
|
return this._mj.stylesheet();
|
|
68
66
|
}
|
package/lib/math/mdmath.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import { MathJaxEngine } from "@cobapen/math";
|
|
1
2
|
import type { PluginSimple } from "markdown-it";
|
|
2
|
-
|
|
3
|
-
export declare function mdmath(math: MathjaxEngine): PluginSimple;
|
|
3
|
+
export declare function mdmath(math: MathJaxEngine): PluginSimple;
|
package/lib/math/mdmath.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import katex from "katex";
|
|
2
1
|
import { math_block, math_inline } from "./mdparser.js";
|
|
3
2
|
function getRenderers(mathjax) {
|
|
4
3
|
function renderInlineMath(tex) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return "warn";
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
});
|
|
4
|
+
try {
|
|
5
|
+
return mathjax.convert(tex, { inline: true });
|
|
6
|
+
}
|
|
7
|
+
catch (err) {
|
|
8
|
+
console.error(err);
|
|
9
|
+
return tex;
|
|
10
|
+
}
|
|
16
11
|
}
|
|
17
12
|
function renderBlockMath(tex) {
|
|
18
13
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobapen/markdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "A markdown converter for cobapen website",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown"
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"lint:fix": "eslint src --fix"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
+
"@cobapen/math": "^0.1.2",
|
|
38
39
|
"@mathjax/src": "^4.1.0",
|
|
39
40
|
"highlight.js": "^11.11.1",
|
|
40
|
-
"
|
|
41
|
-
"markdown-it": "^14.1.0",
|
|
41
|
+
"markdown-it": "^14.1.1",
|
|
42
42
|
"markdown-it-adv-table": "^0.2.3",
|
|
43
43
|
"markdown-it-anchor": "^9.2.0",
|
|
44
44
|
"markdown-it-deflist": "^3.0.0",
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@cobapen/eslint-config": "^0.5.1",
|
|
51
|
-
"@types/katex": "^0.16.8",
|
|
52
51
|
"@types/markdown-it": "^14.1.2",
|
|
53
52
|
"@types/mustache": "^4.2.6",
|
|
54
53
|
"@types/node": "^25.2.3",
|