marked-katex-extension 1.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/.editorconfig +16 -0
- package/.eslintignore +2 -0
- package/.eslintrc.json +26 -0
- package/.github/dependabot.yml +11 -0
- package/.github/workflows/automerge.yml +39 -0
- package/.github/workflows/main.yml +74 -0
- package/LICENSE +21 -0
- package/README.md +40 -0
- package/babel.config.json +3 -0
- package/jest.config.js +21 -0
- package/lib/index.umd.js +18439 -0
- package/package.json +56 -0
- package/release.config.cjs +10 -0
- package/rollup.config.umd.js +11 -0
- package/spec/__snapshots__/index.test.js.snap +105 -0
- package/spec/index.test.js +55 -0
- package/src/index.js +52 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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
ADDED
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 @markedjs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# marked-katex-extension
|
|
2
|
+
|
|
3
|
+
Render [katex](https://katex.org/) code in marked
|
|
4
|
+
|
|
5
|
+
Note: Block level katex requires at least 2 `$` at the beginning and end.
|
|
6
|
+
|
|
7
|
+
```markdown
|
|
8
|
+
This is inline katex: $c = \\pm\\sqrt{a^2 + b^2}$
|
|
9
|
+
|
|
10
|
+
This is block level katex:
|
|
11
|
+
|
|
12
|
+
$$
|
|
13
|
+
c = \\pm\\sqrt{a^2 + b^2}
|
|
14
|
+
$$
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
# Usage
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
const {marked} = require("marked");
|
|
21
|
+
const markedKatex = require("marked-katex-extension");
|
|
22
|
+
|
|
23
|
+
// or ES Module script
|
|
24
|
+
// import marked from "https://cdn.jsdelivr.net/gh/markedjs/marked/lib/marked.esm.js";
|
|
25
|
+
// import markedKatex from "https://cdn.jsdelivr.net/gh/UziTech/marked-katex-extension/lib/index.mjs";
|
|
26
|
+
|
|
27
|
+
const options = {
|
|
28
|
+
throwOnError: false
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
marked.use(markedKatex(options));
|
|
32
|
+
|
|
33
|
+
marked("katex: $c = \\pm\\sqrt{a^2 + b^2}$");
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
## `options`
|
|
39
|
+
|
|
40
|
+
Options are sent directly to [`katex.renderToString`](https://katex.org/docs/api.html#server-side-rendering-or-rendering-to-a-string)
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
};
|