marked-katex-extension 1.0.1 → 2.0.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/README.md +6 -6
- package/lib/index.cjs +56 -0
- package/lib/index.umd.js +3 -4
- package/package.json +31 -20
- package/.editorconfig +0 -16
- package/.eslintignore +0 -2
- package/.eslintrc.json +0 -26
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/automerge.yml +0 -39
- package/.github/workflows/main.yml +0 -74
- package/babel.config.json +0 -3
- package/jest.config.js +0 -21
- package/release.config.cjs +0 -10
- package/rollup.config.umd.js +0 -11
- package/spec/__snapshots__/index.test.js.snap +0 -105
- package/spec/index.test.js +0 -55
package/README.md
CHANGED
|
@@ -23,12 +23,12 @@ You will still need to include the css in your html document to allow katex styl
|
|
|
23
23
|
# Usage
|
|
24
24
|
|
|
25
25
|
```js
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
import {marked} from "marked";
|
|
27
|
+
import markedKatex from "marked-katex-extension";
|
|
28
28
|
|
|
29
|
-
// or
|
|
30
|
-
//
|
|
31
|
-
//
|
|
29
|
+
// or UMD script
|
|
30
|
+
// <script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
|
|
31
|
+
// <script src="https://cdn.jsdelivr.net/npm/marked-katex-extension/lib/index.umd.js"></script>
|
|
32
32
|
|
|
33
33
|
const options = {
|
|
34
34
|
throwOnError: false
|
|
@@ -36,7 +36,7 @@ const options = {
|
|
|
36
36
|
|
|
37
37
|
marked.use(markedKatex(options));
|
|
38
38
|
|
|
39
|
-
marked("katex: $c = \\pm\\sqrt{a^2 + b^2}$");
|
|
39
|
+
marked.parse("katex: $c = \\pm\\sqrt{a^2 + b^2}$");
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|

|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var katex = require('katex');
|
|
4
|
+
|
|
5
|
+
function index(options = {}) {
|
|
6
|
+
return {
|
|
7
|
+
extensions: [
|
|
8
|
+
inlineKatex(options),
|
|
9
|
+
blockKatex(options)
|
|
10
|
+
]
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function inlineKatex(options) {
|
|
15
|
+
return {
|
|
16
|
+
name: 'inlineKatex',
|
|
17
|
+
level: 'inline',
|
|
18
|
+
start(src) { return src.indexOf('$'); },
|
|
19
|
+
tokenizer(src, tokens) {
|
|
20
|
+
const match = src.match(/^\$+([^$\n]+?)\$+/);
|
|
21
|
+
if (match) {
|
|
22
|
+
return {
|
|
23
|
+
type: 'inlineKatex',
|
|
24
|
+
raw: match[0],
|
|
25
|
+
text: match[1].trim()
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
renderer(token) {
|
|
30
|
+
return katex.renderToString(token.text, options);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function blockKatex(options) {
|
|
36
|
+
return {
|
|
37
|
+
name: 'blockKatex',
|
|
38
|
+
level: 'block',
|
|
39
|
+
start(src) { return src.indexOf('\n$$'); },
|
|
40
|
+
tokenizer(src, tokens) {
|
|
41
|
+
const match = src.match(/^\$\$+\n([^$]+?)\n\$\$+\n/);
|
|
42
|
+
if (match) {
|
|
43
|
+
return {
|
|
44
|
+
type: 'blockKatex',
|
|
45
|
+
raw: match[0],
|
|
46
|
+
text: match[1].trim()
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
renderer(token) {
|
|
51
|
+
return `<p>${katex.renderToString(token.text, options)}</p>`;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = index;
|
package/lib/index.umd.js
CHANGED
|
@@ -8555,8 +8555,7 @@
|
|
|
8555
8555
|
names: ["\\\\"],
|
|
8556
8556
|
props: {
|
|
8557
8557
|
numArgs: 0,
|
|
8558
|
-
numOptionalArgs:
|
|
8559
|
-
argTypes: ["size"],
|
|
8558
|
+
numOptionalArgs: 0,
|
|
8560
8559
|
allowedInText: true
|
|
8561
8560
|
},
|
|
8562
8561
|
|
|
@@ -8564,7 +8563,7 @@
|
|
|
8564
8563
|
var {
|
|
8565
8564
|
parser
|
|
8566
8565
|
} = _ref;
|
|
8567
|
-
var size =
|
|
8566
|
+
var size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null;
|
|
8568
8567
|
var newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode");
|
|
8569
8568
|
return {
|
|
8570
8569
|
type: "cr",
|
|
@@ -18303,7 +18302,7 @@
|
|
|
18303
18302
|
/**
|
|
18304
18303
|
* Current KaTeX version
|
|
18305
18304
|
*/
|
|
18306
|
-
version: "0.16.
|
|
18305
|
+
version: "0.16.4",
|
|
18307
18306
|
|
|
18308
18307
|
/**
|
|
18309
18308
|
* Renders the given LaTeX into an HTML+MathML combination, and adds
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marked-katex-extension",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "MarkedJS extesion to render katex",
|
|
5
|
-
"main": "./
|
|
5
|
+
"main": "./lib/index.cjs",
|
|
6
|
+
"module": "./src/index.js",
|
|
6
7
|
"browser": "./lib/index.umd.js",
|
|
7
8
|
"type": "module",
|
|
8
9
|
"keywords": [
|
|
@@ -10,11 +11,21 @@
|
|
|
10
11
|
"katex",
|
|
11
12
|
"extension"
|
|
12
13
|
],
|
|
14
|
+
"files": [
|
|
15
|
+
"lib/",
|
|
16
|
+
"src/"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": "./src/index.js",
|
|
21
|
+
"require": "./lib/index.cjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
13
24
|
"scripts": {
|
|
14
25
|
"test": "jest --verbose",
|
|
15
26
|
"test:cover": "jest --coverage",
|
|
16
27
|
"lint": "eslint .",
|
|
17
|
-
"build": "rollup -c rollup.config.
|
|
28
|
+
"build": "rollup -c rollup.config.js"
|
|
18
29
|
},
|
|
19
30
|
"repository": {
|
|
20
31
|
"type": "git",
|
|
@@ -27,30 +38,30 @@
|
|
|
27
38
|
},
|
|
28
39
|
"homepage": "https://github.com/UziTech/marked-katex-extension#readme",
|
|
29
40
|
"peerDependencies": {
|
|
30
|
-
"marked": "^4.
|
|
41
|
+
"marked": "^4.3.0"
|
|
31
42
|
},
|
|
32
43
|
"devDependencies": {
|
|
33
|
-
"@babel/core": "^7.
|
|
34
|
-
"@babel/preset-env": "^7.
|
|
35
|
-
"@rollup/plugin-node-resolve": "^15.0.
|
|
36
|
-
"@semantic-release/changelog": "^6.0.
|
|
44
|
+
"@babel/core": "^7.21.4",
|
|
45
|
+
"@babel/preset-env": "^7.21.4",
|
|
46
|
+
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
47
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
37
48
|
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
38
49
|
"@semantic-release/git": "^10.0.1",
|
|
39
|
-
"@semantic-release/github": "^8.0.
|
|
40
|
-
"@semantic-release/npm": "^
|
|
50
|
+
"@semantic-release/github": "^8.0.7",
|
|
51
|
+
"@semantic-release/npm": "^10.0.3",
|
|
41
52
|
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
42
|
-
"babel-jest": "^29.
|
|
43
|
-
"eslint": "^8.
|
|
53
|
+
"babel-jest": "^29.5.0",
|
|
54
|
+
"eslint": "^8.38.0",
|
|
44
55
|
"eslint-config-standard": "^17.0.0",
|
|
45
|
-
"eslint-plugin-import": "^2.
|
|
46
|
-
"eslint-plugin-n": "^15.
|
|
47
|
-
"eslint-plugin-promise": "^6.1.
|
|
48
|
-
"jest-cli": "^29.
|
|
49
|
-
"marked": "^4.
|
|
50
|
-
"rollup": "^3.2
|
|
51
|
-
"semantic-release": "^
|
|
56
|
+
"eslint-plugin-import": "^2.27.5",
|
|
57
|
+
"eslint-plugin-n": "^15.7.0",
|
|
58
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
59
|
+
"jest-cli": "^29.5.0",
|
|
60
|
+
"marked": "^4.3.0",
|
|
61
|
+
"rollup": "^3.20.2",
|
|
62
|
+
"semantic-release": "^21.0.1"
|
|
52
63
|
},
|
|
53
64
|
"dependencies": {
|
|
54
|
-
"katex": "^0.16.
|
|
65
|
+
"katex": "^0.16.4"
|
|
55
66
|
}
|
|
56
67
|
}
|
package/.editorconfig
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
root = true
|
|
2
|
-
|
|
3
|
-
[*.{json,js}]
|
|
4
|
-
charset = utf-8
|
|
5
|
-
end_of_line = lf
|
|
6
|
-
insert_final_newline = true
|
|
7
|
-
indent_style = space
|
|
8
|
-
indent_size = 2
|
|
9
|
-
|
|
10
|
-
[*.md]
|
|
11
|
-
charset = utf-8
|
|
12
|
-
end_of_line = lf
|
|
13
|
-
insert_final_newline = true
|
|
14
|
-
trim_trailing_whitespace = true
|
|
15
|
-
indent_style = tab
|
|
16
|
-
indent_size = 4
|
package/.eslintignore
DELETED
package/.eslintrc.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "standard",
|
|
3
|
-
"rules": {
|
|
4
|
-
"semi": ["error", "always"],
|
|
5
|
-
"indent": ["error", 2, {
|
|
6
|
-
"SwitchCase": 1,
|
|
7
|
-
"VariableDeclarator": { "var": 2 },
|
|
8
|
-
"outerIIFEBody": 0
|
|
9
|
-
}],
|
|
10
|
-
"operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }],
|
|
11
|
-
"space-before-function-paren": ["error", "never"],
|
|
12
|
-
"no-cond-assign": "off",
|
|
13
|
-
"no-useless-escape": "off",
|
|
14
|
-
"one-var": "off",
|
|
15
|
-
"no-control-regex": "off",
|
|
16
|
-
"no-prototype-builtins": "off",
|
|
17
|
-
"no-extra-semi": "error",
|
|
18
|
-
|
|
19
|
-
"prefer-const": "error",
|
|
20
|
-
"no-var": "error"
|
|
21
|
-
},
|
|
22
|
-
"env": {
|
|
23
|
-
"node": true,
|
|
24
|
-
"jest": true
|
|
25
|
-
}
|
|
26
|
-
}
|
package/.github/dependabot.yml
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
name: "Automerge"
|
|
2
|
-
on:
|
|
3
|
-
workflow_run:
|
|
4
|
-
workflows:
|
|
5
|
-
- CI
|
|
6
|
-
types:
|
|
7
|
-
- completed
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
Automerge:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
if: |
|
|
13
|
-
github.event.workflow_run.event == 'pull_request' &&
|
|
14
|
-
github.event.workflow_run.conclusion == 'success'
|
|
15
|
-
steps:
|
|
16
|
-
- name: 'Merge PR'
|
|
17
|
-
uses: actions/github-script@v6
|
|
18
|
-
with:
|
|
19
|
-
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
20
|
-
script: |
|
|
21
|
-
const pr = await github.rest.pulls.get({
|
|
22
|
-
owner: context.repo.owner,
|
|
23
|
-
repo: context.repo.repo,
|
|
24
|
-
pull_number: context.payload.workflow_run.pull_requests[0].number,
|
|
25
|
-
});
|
|
26
|
-
if (!pr.data.title.startsWith('chore(deps-dev):')) {
|
|
27
|
-
console.log('Not Merged 🚫');
|
|
28
|
-
console.log(`Title '${pr.data.title}' does not start with 'chore(deps-dev):'`);
|
|
29
|
-
} else if (pr.data.user.login !== 'dependabot[bot]') {
|
|
30
|
-
console.log('Not Merged 🚫');
|
|
31
|
-
console.log(`User '${pr.data.user.login}' does not equal 'dependabot[bot]'`);
|
|
32
|
-
} else {
|
|
33
|
-
await github.rest.pulls.merge({
|
|
34
|
-
owner: context.repo.owner,
|
|
35
|
-
repo: context.repo.repo,
|
|
36
|
-
pull_number: context.payload.workflow_run.pull_requests[0].number,
|
|
37
|
-
});
|
|
38
|
-
console.log('Merged 🎉');
|
|
39
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
name: "CI"
|
|
2
|
-
on:
|
|
3
|
-
pull_request:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
|
|
10
|
-
Test:
|
|
11
|
-
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
steps:
|
|
14
|
-
- name: Checkout Code
|
|
15
|
-
uses: actions/checkout@v3
|
|
16
|
-
- name: Install Node
|
|
17
|
-
uses: dcodeIO/setup-node-nvm@master
|
|
18
|
-
with:
|
|
19
|
-
node-version: node
|
|
20
|
-
- name: Install Dependencies
|
|
21
|
-
run: npm ci
|
|
22
|
-
- name: Run Tests 👩🏽💻
|
|
23
|
-
run: npm run test
|
|
24
|
-
|
|
25
|
-
Coverage:
|
|
26
|
-
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
|
27
|
-
runs-on: ubuntu-latest
|
|
28
|
-
steps:
|
|
29
|
-
- name: Checkout Code
|
|
30
|
-
uses: actions/checkout@v3
|
|
31
|
-
- name: Install Node
|
|
32
|
-
uses: dcodeIO/setup-node-nvm@master
|
|
33
|
-
with:
|
|
34
|
-
node-version: 'lts/*'
|
|
35
|
-
- name: Install Dependencies
|
|
36
|
-
run: npm ci
|
|
37
|
-
- name: Run Tests 👩🏽💻
|
|
38
|
-
run: npm run test:cover
|
|
39
|
-
|
|
40
|
-
Lint:
|
|
41
|
-
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
|
42
|
-
runs-on: ubuntu-latest
|
|
43
|
-
steps:
|
|
44
|
-
- name: Checkout Code
|
|
45
|
-
uses: actions/checkout@v3
|
|
46
|
-
- name: Install Dependencies
|
|
47
|
-
run: npm ci
|
|
48
|
-
- name: Lint ✨
|
|
49
|
-
run: npm run lint
|
|
50
|
-
|
|
51
|
-
Release:
|
|
52
|
-
needs: [Test, Coverage, Lint]
|
|
53
|
-
if: |
|
|
54
|
-
github.ref == 'refs/heads/main' &&
|
|
55
|
-
github.event.repository.fork == false
|
|
56
|
-
runs-on: ubuntu-latest
|
|
57
|
-
steps:
|
|
58
|
-
- name: Checkout Code
|
|
59
|
-
uses: actions/checkout@v3
|
|
60
|
-
- name: Install Dependencies
|
|
61
|
-
run: npm ci
|
|
62
|
-
- name: Build 🗜️
|
|
63
|
-
run: |
|
|
64
|
-
npm run build
|
|
65
|
-
if ! git diff --quiet; then
|
|
66
|
-
git config --global user.email "<>"
|
|
67
|
-
git config --global user.name "CI Build"
|
|
68
|
-
git commit -am "🗜️ build [skip ci]"
|
|
69
|
-
fi
|
|
70
|
-
- name: Release 🎉
|
|
71
|
-
env:
|
|
72
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
73
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
74
|
-
run: npx semantic-release
|
package/babel.config.json
DELETED
package/jest.config.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
restoreMocks: true,
|
|
3
|
-
clearMocks: true,
|
|
4
|
-
// collectCoverage: true,
|
|
5
|
-
collectCoverageFrom: [
|
|
6
|
-
'src/index.js'
|
|
7
|
-
],
|
|
8
|
-
coverageDirectory: 'coverage',
|
|
9
|
-
coverageThreshold: {
|
|
10
|
-
global: {
|
|
11
|
-
branches: 100,
|
|
12
|
-
functions: 100,
|
|
13
|
-
lines: 100,
|
|
14
|
-
statements: 100
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
testRegex: /\.test\.js$/.source,
|
|
18
|
-
transform: {
|
|
19
|
-
'\\.[jt]sx?$': 'babel-jest'
|
|
20
|
-
}
|
|
21
|
-
};
|
package/release.config.cjs
DELETED
package/rollup.config.umd.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`marked-katex-extension block katex 1`] = `
|
|
4
|
-
"<p>This is block level katex:</p>
|
|
5
|
-
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mo>=</mo><mo>±</mo><msqrt><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup></mrow></msqrt></mrow><annotation encoding="application/x-tex">c = \\pm\\sqrt{a^2 + b^2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.1266em;"></span><span class="mord">±</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9134em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.8734em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
|
|
6
|
-
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
|
7
|
-
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
|
8
|
-
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|
|
9
|
-
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
|
|
10
|
-
c69,-144,104.5,-217.7,106.5,-221
|
|
11
|
-
l0 -0
|
|
12
|
-
c5.3,-9.3,12,-14,20,-14
|
|
13
|
-
H400000v40H845.2724
|
|
14
|
-
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
|
|
15
|
-
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
|
|
16
|
-
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.1266em;"><span></span></span></span></span></span></span></span></span></p>"
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
exports[`marked-katex-extension block katex 1 $ 1`] = `
|
|
20
|
-
"<p>This is block level katex:</p>
|
|
21
|
-
<p>$
|
|
22
|
-
c = \\pm\\sqrt{a^2 + b^2}
|
|
23
|
-
$</p>
|
|
24
|
-
"
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
exports[`marked-katex-extension block katex more $ 1`] = `
|
|
28
|
-
"<p>This is block level katex:</p>
|
|
29
|
-
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mo>=</mo><mo>±</mo><msqrt><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup></mrow></msqrt></mrow><annotation encoding="application/x-tex">c = \\pm\\sqrt{a^2 + b^2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.1266em;"></span><span class="mord">±</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9134em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.8734em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
|
|
30
|
-
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
|
31
|
-
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
|
32
|
-
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|
|
33
|
-
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
|
|
34
|
-
c69,-144,104.5,-217.7,106.5,-221
|
|
35
|
-
l0 -0
|
|
36
|
-
c5.3,-9.3,12,-14,20,-14
|
|
37
|
-
H400000v40H845.2724
|
|
38
|
-
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
|
|
39
|
-
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
|
|
40
|
-
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.1266em;"><span></span></span></span></span></span></span></span></span></p>"
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
exports[`marked-katex-extension inline katex 1`] = `
|
|
44
|
-
"<p>This is inline katex: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mo>=</mo><mo>±</mo><msqrt><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup></mrow></msqrt></mrow><annotation encoding="application/x-tex">c = \\pm\\sqrt{a^2 + b^2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.1266em;"></span><span class="mord">±</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9134em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.8734em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
|
|
45
|
-
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
|
46
|
-
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
|
47
|
-
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|
|
48
|
-
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
|
|
49
|
-
c69,-144,104.5,-217.7,106.5,-221
|
|
50
|
-
l0 -0
|
|
51
|
-
c5.3,-9.3,12,-14,20,-14
|
|
52
|
-
H400000v40H845.2724
|
|
53
|
-
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
|
|
54
|
-
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
|
|
55
|
-
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.1266em;"><span></span></span></span></span></span></span></span></span></p>
|
|
56
|
-
"
|
|
57
|
-
`;
|
|
58
|
-
|
|
59
|
-
exports[`marked-katex-extension inline katex 2`] = `
|
|
60
|
-
"<p>This is inline katex: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mo>=</mo><mo>±</mo><msqrt><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup></mrow></msqrt></mrow><annotation encoding="application/x-tex">c = \\pm\\sqrt{a^2 + b^2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.1266em;"></span><span class="mord">±</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9134em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.8734em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
|
|
61
|
-
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
|
62
|
-
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
|
63
|
-
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|
|
64
|
-
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
|
|
65
|
-
c69,-144,104.5,-217.7,106.5,-221
|
|
66
|
-
l0 -0
|
|
67
|
-
c5.3,-9.3,12,-14,20,-14
|
|
68
|
-
H400000v40H845.2724
|
|
69
|
-
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
|
|
70
|
-
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
|
|
71
|
-
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.1266em;"><span></span></span></span></span></span></span></span></span></p>
|
|
72
|
-
"
|
|
73
|
-
`;
|
|
74
|
-
|
|
75
|
-
exports[`marked-katex-extension inline katex more $ 1`] = `
|
|
76
|
-
"<p>This is inline katex: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mo>=</mo><mo>±</mo><msqrt><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup></mrow></msqrt></mrow><annotation encoding="application/x-tex">c = \\pm\\sqrt{a^2 + b^2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.1266em;"></span><span class="mord">±</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9134em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.8734em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
|
|
77
|
-
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
|
78
|
-
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
|
79
|
-
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|
|
80
|
-
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
|
|
81
|
-
c69,-144,104.5,-217.7,106.5,-221
|
|
82
|
-
l0 -0
|
|
83
|
-
c5.3,-9.3,12,-14,20,-14
|
|
84
|
-
H400000v40H845.2724
|
|
85
|
-
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
|
|
86
|
-
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
|
|
87
|
-
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.1266em;"><span></span></span></span></span></span></span></span></span></p>
|
|
88
|
-
"
|
|
89
|
-
`;
|
|
90
|
-
|
|
91
|
-
exports[`marked-katex-extension readme example 1`] = `
|
|
92
|
-
"<p>katex: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mo>=</mo><mo>±</mo><msqrt><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup></mrow></msqrt></mrow><annotation encoding="application/x-tex">c = \\pm\\sqrt{a^2 + b^2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.1266em;"></span><span class="mord">±</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9134em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.8734em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
|
|
93
|
-
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
|
94
|
-
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
|
95
|
-
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|
|
96
|
-
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
|
|
97
|
-
c69,-144,104.5,-217.7,106.5,-221
|
|
98
|
-
l0 -0
|
|
99
|
-
c5.3,-9.3,12,-14,20,-14
|
|
100
|
-
H400000v40H845.2724
|
|
101
|
-
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
|
|
102
|
-
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
|
|
103
|
-
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.1266em;"><span></span></span></span></span></span></span></span></span></p>
|
|
104
|
-
"
|
|
105
|
-
`;
|
package/spec/index.test.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { marked } from 'marked';
|
|
2
|
-
import markedKatex from '../src/index.js';
|
|
3
|
-
|
|
4
|
-
describe('marked-katex-extension', () => {
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
marked.setOptions(marked.getDefaults());
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
const snapshots = {
|
|
10
|
-
'readme example': 'katex: $c = \\pm\\sqrt{a^2 + b^2}$',
|
|
11
|
-
'inline katex': `
|
|
12
|
-
This is inline katex: $c = \\pm\\sqrt{a^2 + b^2}$
|
|
13
|
-
`,
|
|
14
|
-
'block katex': `
|
|
15
|
-
This is block level katex:
|
|
16
|
-
|
|
17
|
-
$$
|
|
18
|
-
c = \\pm\\sqrt{a^2 + b^2}
|
|
19
|
-
$$
|
|
20
|
-
`,
|
|
21
|
-
'inline katex more $': `
|
|
22
|
-
This is inline katex: $$c = \\pm\\sqrt{a^2 + b^2}$$
|
|
23
|
-
`,
|
|
24
|
-
'block katex more $': `
|
|
25
|
-
This is block level katex:
|
|
26
|
-
|
|
27
|
-
$$$
|
|
28
|
-
c = \\pm\\sqrt{a^2 + b^2}
|
|
29
|
-
$$$
|
|
30
|
-
`,
|
|
31
|
-
'block katex 1 $': `
|
|
32
|
-
This is block level katex:
|
|
33
|
-
|
|
34
|
-
$
|
|
35
|
-
c = \\pm\\sqrt{a^2 + b^2}
|
|
36
|
-
$
|
|
37
|
-
`
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
for (const name in snapshots) {
|
|
41
|
-
test(name, () => {
|
|
42
|
-
marked.use(markedKatex());
|
|
43
|
-
const md = snapshots[name];
|
|
44
|
-
expect(marked(md)).toMatchSnapshot();
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
test('inline katex', () => {
|
|
49
|
-
marked.use(markedKatex());
|
|
50
|
-
const md = `
|
|
51
|
-
This is inline katex: $c = \\pm\\sqrt{a^2 + b^2}$
|
|
52
|
-
`;
|
|
53
|
-
expect(marked(md)).toMatchSnapshot();
|
|
54
|
-
});
|
|
55
|
-
});
|