@nakobase/nakobase-md-html 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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/esm/constants.d.ts +19 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +18 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +35 -0
- package/dist/esm/sanitizer.d.ts +2 -0
- package/dist/esm/sanitizer.d.ts.map +1 -0
- package/dist/esm/sanitizer.js +41 -0
- package/dist/esm/types.d.ts +4 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils/highlight.d.ts +2 -0
- package/dist/esm/utils/highlight.d.ts.map +1 -0
- package/dist/esm/utils/highlight.js +304 -0
- package/dist/esm/utils/md-container.d.ts +10 -0
- package/dist/esm/utils/md-container.d.ts.map +1 -0
- package/dist/esm/utils/md-container.js +59 -0
- package/dist/esm/utils/md-renderer-fence.d.ts +7 -0
- package/dist/esm/utils/md-renderer-fence.d.ts.map +1 -0
- package/dist/esm/utils/md-renderer-fence.js +74 -0
- package/dist/styles/style.css +1 -0
- package/package.json +104 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 NakoBase
|
|
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,53 @@
|
|
|
1
|
+
# @nakobase/nakobase-md-html
|
|
2
|
+
|
|
3
|
+
Convert Markdown to **sanitized HTML** and apply consistent styles – simple, secure, and styled.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# npm
|
|
9
|
+
npm install @nakobase/nakobase-md-html
|
|
10
|
+
|
|
11
|
+
# yarn
|
|
12
|
+
yarn add @nakobase/nakobase-md-html
|
|
13
|
+
|
|
14
|
+
# pnpm
|
|
15
|
+
pnpm add @nakobase/nakobase-md-html
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Basic Usage
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { mdToHtml } from '@nakobase/nakobase-md-html';
|
|
24
|
+
|
|
25
|
+
const html = mdToHtml(
|
|
26
|
+
`
|
|
27
|
+
# Hello World
|
|
28
|
+
|
|
29
|
+
This is a test of the markdown to html converter.
|
|
30
|
+
`,
|
|
31
|
+
{ codeHighlight: true }
|
|
32
|
+
); // codeHighlight is optional, default is false
|
|
33
|
+
|
|
34
|
+
console.log(html);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Styles
|
|
38
|
+
|
|
39
|
+
We have some default styles that are applied to the HTML.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import '@nakobase/nakobase-md-html/styles/style.css';
|
|
43
|
+
|
|
44
|
+
import 'prismjs/themes/prism-okaidia.css'; // or any other prism theme if you want
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Add `.nbcontents` to the container of the markdown.
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<div class="nbcontent">
|
|
51
|
+
<!-- HTML parsed from markdown -->
|
|
52
|
+
</div>
|
|
53
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const ARGUMENT_DIVIDER = "|";
|
|
2
|
+
export declare const CONTAINER_TYPES: {
|
|
3
|
+
readonly TOC: "toc";
|
|
4
|
+
readonly SOCIAL_EMBED: "socialEmbed";
|
|
5
|
+
readonly TEXT_LINK: "textLink";
|
|
6
|
+
readonly BUTTON_LINK: "buttonLink";
|
|
7
|
+
readonly IMAGE: "image";
|
|
8
|
+
readonly ARTICLE: "article";
|
|
9
|
+
readonly LIST: "list";
|
|
10
|
+
readonly BOX: "box";
|
|
11
|
+
readonly TABLE: "table";
|
|
12
|
+
readonly TABLE2: "table2";
|
|
13
|
+
readonly NOTE: "note";
|
|
14
|
+
readonly ALERT: "alert";
|
|
15
|
+
readonly EC_BUTTONS: "ecButtons";
|
|
16
|
+
readonly SPEECH_BUBBLE_IMAGE: "speechBubbleImage";
|
|
17
|
+
readonly DETAILS: "details";
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;CAgBlB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const ARGUMENT_DIVIDER = '|';
|
|
2
|
+
export const CONTAINER_TYPES = {
|
|
3
|
+
TOC: 'toc',
|
|
4
|
+
SOCIAL_EMBED: 'socialEmbed',
|
|
5
|
+
TEXT_LINK: 'textLink',
|
|
6
|
+
BUTTON_LINK: 'buttonLink',
|
|
7
|
+
IMAGE: 'image',
|
|
8
|
+
ARTICLE: 'article',
|
|
9
|
+
LIST: 'list',
|
|
10
|
+
BOX: 'box',
|
|
11
|
+
TABLE: 'table',
|
|
12
|
+
TABLE2: 'table2',
|
|
13
|
+
NOTE: 'note',
|
|
14
|
+
ALERT: 'alert',
|
|
15
|
+
EC_BUTTONS: 'ecButtons',
|
|
16
|
+
SPEECH_BUBBLE_IMAGE: 'speechBubbleImage',
|
|
17
|
+
DETAILS: 'details'
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAa1C,eAAO,MAAM,QAAQ,GACnB,UAAU,MAAM,EAChB,UAAU,eAAe,KACxB,MA2BF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import MarkdownIt from 'markdown-it';
|
|
3
|
+
import { sanitize } from './sanitizer';
|
|
4
|
+
import { boxOptions, detailsOptions } from './utils/md-container';
|
|
5
|
+
import { mdRendererFence } from './utils/md-renderer-fence';
|
|
6
|
+
import { CONTAINER_TYPES } from './constants';
|
|
7
|
+
|
|
8
|
+
// plugins
|
|
9
|
+
const MdItImSize = require('@steelydylan/markdown-it-imsize').default;
|
|
10
|
+
const MdItInlineComments = require('markdown-it-inline-comments');
|
|
11
|
+
const MdItContainer = require('markdown-it-container');
|
|
12
|
+
const MdItTaskLists = require('markdown-it-task-lists');
|
|
13
|
+
export const mdToHtml = (markdown, options) => {
|
|
14
|
+
const {
|
|
15
|
+
codeHighlight
|
|
16
|
+
} = options || {};
|
|
17
|
+
if (!(markdown && markdown.length)) return '';
|
|
18
|
+
const md = MarkdownIt({
|
|
19
|
+
breaks: true,
|
|
20
|
+
linkify: true
|
|
21
|
+
});
|
|
22
|
+
md.linkify.set({
|
|
23
|
+
fuzzyLink: false
|
|
24
|
+
});
|
|
25
|
+
md.linkify.set({
|
|
26
|
+
fuzzyEmail: false
|
|
27
|
+
});
|
|
28
|
+
md.use(MdItInlineComments).use(MdItImSize).use(MdItTaskLists, {
|
|
29
|
+
enabled: true
|
|
30
|
+
}).use(MdItContainer, CONTAINER_TYPES.DETAILS, detailsOptions).use(MdItContainer, CONTAINER_TYPES.BOX, boxOptions);
|
|
31
|
+
if (codeHighlight) {
|
|
32
|
+
md.use(mdRendererFence);
|
|
33
|
+
}
|
|
34
|
+
return sanitize(md.render(markdown));
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizer.d.ts","sourceRoot":"","sources":["../../src/sanitizer.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,MA8BpC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// sanitizer.ts
|
|
2
|
+
import sanitizeHtml, { defaults } from 'sanitize-html';
|
|
3
|
+
const extendedTags = ['iframe', 'code', 'details', 'summary', 'circle', 'img', 'input', 'pre', 'span'];
|
|
4
|
+
const extendedAttributes = {
|
|
5
|
+
a: [...(defaults.allowedAttributes.a || []), 'id', 'class', 'data-line'],
|
|
6
|
+
iframe: ['src', 'width', 'height', 'allow', 'sandbox', 'frameborder'],
|
|
7
|
+
input: ['type', 'checked', 'disabled', 'readonly', 'value', 'class'],
|
|
8
|
+
ul: ['class'],
|
|
9
|
+
ol: ['class'],
|
|
10
|
+
li: ['class'],
|
|
11
|
+
div: ['class'],
|
|
12
|
+
pre: ['class'],
|
|
13
|
+
code: [...(defaults.allowedAttributes.code || []), 'class'],
|
|
14
|
+
span: ['class']
|
|
15
|
+
};
|
|
16
|
+
export const sanitize = html => sanitizeHtml(html, {
|
|
17
|
+
allowedTags: [...defaults.allowedTags, ...extendedTags],
|
|
18
|
+
allowedAttributes: {
|
|
19
|
+
...defaults.allowedAttributes,
|
|
20
|
+
...extendedAttributes
|
|
21
|
+
},
|
|
22
|
+
allowedSchemes: ['http', 'https', 'mailto', 'tel'],
|
|
23
|
+
allowedSchemesByTag: {
|
|
24
|
+
iframe: ['https'],
|
|
25
|
+
img: ['http', 'https', 'data']
|
|
26
|
+
},
|
|
27
|
+
allowedStyles: {
|
|
28
|
+
'*': {
|
|
29
|
+
width: [/^\d+(?:px|%)$/],
|
|
30
|
+
height: [/^\d+(?:px|%)$/],
|
|
31
|
+
'text-align': [/^(?:left|right|center|justify)$/]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
transformTags: {
|
|
35
|
+
a: sanitizeHtml.simpleTransform('a', {
|
|
36
|
+
target: '_blank',
|
|
37
|
+
rel: 'noopener noreferrer'
|
|
38
|
+
})
|
|
39
|
+
},
|
|
40
|
+
disallowedTagsMode: 'discard'
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../../src/utils/highlight.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIhE"}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import Prism from "prismjs/components/prism-core";
|
|
2
|
+
import "prismjs/components/prism-markup";
|
|
3
|
+
import "prismjs/components/prism-css";
|
|
4
|
+
import "prismjs/components/prism-clike";
|
|
5
|
+
import "prismjs/components/prism-regex";
|
|
6
|
+
import "prismjs/components/prism-javascript";
|
|
7
|
+
import "prismjs/components/prism-abap";
|
|
8
|
+
import "prismjs/components/prism-abnf";
|
|
9
|
+
import "prismjs/components/prism-actionscript";
|
|
10
|
+
import "prismjs/components/prism-ada";
|
|
11
|
+
import "prismjs/components/prism-agda";
|
|
12
|
+
import "prismjs/components/prism-al";
|
|
13
|
+
import "prismjs/components/prism-antlr4";
|
|
14
|
+
import "prismjs/components/prism-apacheconf";
|
|
15
|
+
import "prismjs/components/prism-sql";
|
|
16
|
+
import "prismjs/components/prism-apex";
|
|
17
|
+
import "prismjs/components/prism-apl";
|
|
18
|
+
import "prismjs/components/prism-applescript";
|
|
19
|
+
import "prismjs/components/prism-aql";
|
|
20
|
+
import "prismjs/components/prism-c";
|
|
21
|
+
import "prismjs/components/prism-cpp";
|
|
22
|
+
import "prismjs/components/prism-arduino";
|
|
23
|
+
import "prismjs/components/prism-arff";
|
|
24
|
+
import "prismjs/components/prism-armasm";
|
|
25
|
+
import "prismjs/components/prism-bash";
|
|
26
|
+
import "prismjs/components/prism-yaml";
|
|
27
|
+
import "prismjs/components/prism-markdown";
|
|
28
|
+
import "prismjs/components/prism-arturo";
|
|
29
|
+
import "prismjs/components/prism-asciidoc";
|
|
30
|
+
import "prismjs/components/prism-csharp";
|
|
31
|
+
import "prismjs/components/prism-aspnet";
|
|
32
|
+
import "prismjs/components/prism-asm6502";
|
|
33
|
+
import "prismjs/components/prism-asmatmel";
|
|
34
|
+
import "prismjs/components/prism-autohotkey";
|
|
35
|
+
import "prismjs/components/prism-autoit";
|
|
36
|
+
import "prismjs/components/prism-avisynth";
|
|
37
|
+
import "prismjs/components/prism-avro-idl";
|
|
38
|
+
import "prismjs/components/prism-awk";
|
|
39
|
+
import "prismjs/components/prism-basic";
|
|
40
|
+
import "prismjs/components/prism-batch";
|
|
41
|
+
import "prismjs/components/prism-bbcode";
|
|
42
|
+
import "prismjs/components/prism-bbj";
|
|
43
|
+
import "prismjs/components/prism-bicep";
|
|
44
|
+
import "prismjs/components/prism-birb";
|
|
45
|
+
import "prismjs/components/prism-bison";
|
|
46
|
+
import "prismjs/components/prism-bnf";
|
|
47
|
+
import "prismjs/components/prism-bqn";
|
|
48
|
+
import "prismjs/components/prism-brainfuck";
|
|
49
|
+
import "prismjs/components/prism-brightscript";
|
|
50
|
+
import "prismjs/components/prism-bro";
|
|
51
|
+
import "prismjs/components/prism-bsl";
|
|
52
|
+
import "prismjs/components/prism-cfscript";
|
|
53
|
+
import "prismjs/components/prism-chaiscript";
|
|
54
|
+
import "prismjs/components/prism-cil";
|
|
55
|
+
import "prismjs/components/prism-cilkc";
|
|
56
|
+
import "prismjs/components/prism-cilkcpp";
|
|
57
|
+
import "prismjs/components/prism-clojure";
|
|
58
|
+
import "prismjs/components/prism-cmake";
|
|
59
|
+
import "prismjs/components/prism-cobol";
|
|
60
|
+
import "prismjs/components/prism-coffeescript";
|
|
61
|
+
import "prismjs/components/prism-concurnas";
|
|
62
|
+
import "prismjs/components/prism-csp";
|
|
63
|
+
import "prismjs/components/prism-cooklang";
|
|
64
|
+
import "prismjs/components/prism-coq";
|
|
65
|
+
import "prismjs/components/prism-ruby";
|
|
66
|
+
import "prismjs/components/prism-crystal";
|
|
67
|
+
import "prismjs/components/prism-css-extras";
|
|
68
|
+
import "prismjs/components/prism-csv";
|
|
69
|
+
import "prismjs/components/prism-cue";
|
|
70
|
+
import "prismjs/components/prism-cypher";
|
|
71
|
+
import "prismjs/components/prism-d";
|
|
72
|
+
import "prismjs/components/prism-dart";
|
|
73
|
+
import "prismjs/components/prism-dataweave";
|
|
74
|
+
import "prismjs/components/prism-dax";
|
|
75
|
+
import "prismjs/components/prism-dhall";
|
|
76
|
+
import "prismjs/components/prism-diff";
|
|
77
|
+
import "prismjs/components/prism-markup-templating";
|
|
78
|
+
import "prismjs/components/prism-django";
|
|
79
|
+
import "prismjs/components/prism-dns-zone-file";
|
|
80
|
+
import "prismjs/components/prism-docker";
|
|
81
|
+
import "prismjs/components/prism-dot";
|
|
82
|
+
import "prismjs/components/prism-ebnf";
|
|
83
|
+
import "prismjs/components/prism-editorconfig";
|
|
84
|
+
import "prismjs/components/prism-eiffel";
|
|
85
|
+
import "prismjs/components/prism-ejs";
|
|
86
|
+
import "prismjs/components/prism-elixir";
|
|
87
|
+
import "prismjs/components/prism-elm";
|
|
88
|
+
import "prismjs/components/prism-lua";
|
|
89
|
+
import "prismjs/components/prism-etlua";
|
|
90
|
+
import "prismjs/components/prism-erb";
|
|
91
|
+
import "prismjs/components/prism-erlang";
|
|
92
|
+
import "prismjs/components/prism-excel-formula";
|
|
93
|
+
import "prismjs/components/prism-fsharp";
|
|
94
|
+
import "prismjs/components/prism-factor";
|
|
95
|
+
import "prismjs/components/prism-false";
|
|
96
|
+
import "prismjs/components/prism-firestore-security-rules";
|
|
97
|
+
import "prismjs/components/prism-flow";
|
|
98
|
+
import "prismjs/components/prism-fortran";
|
|
99
|
+
import "prismjs/components/prism-ftl";
|
|
100
|
+
import "prismjs/components/prism-gml";
|
|
101
|
+
import "prismjs/components/prism-gap";
|
|
102
|
+
import "prismjs/components/prism-gcode";
|
|
103
|
+
import "prismjs/components/prism-gdscript";
|
|
104
|
+
import "prismjs/components/prism-gedcom";
|
|
105
|
+
import "prismjs/components/prism-gettext";
|
|
106
|
+
import "prismjs/components/prism-gherkin";
|
|
107
|
+
import "prismjs/components/prism-git";
|
|
108
|
+
import "prismjs/components/prism-glsl";
|
|
109
|
+
import "prismjs/components/prism-gn";
|
|
110
|
+
import "prismjs/components/prism-linker-script";
|
|
111
|
+
import "prismjs/components/prism-go";
|
|
112
|
+
import "prismjs/components/prism-go-module";
|
|
113
|
+
import "prismjs/components/prism-gradle";
|
|
114
|
+
import "prismjs/components/prism-graphql";
|
|
115
|
+
import "prismjs/components/prism-groovy";
|
|
116
|
+
import "prismjs/components/prism-less";
|
|
117
|
+
import "prismjs/components/prism-scss";
|
|
118
|
+
import "prismjs/components/prism-textile";
|
|
119
|
+
import "prismjs/components/prism-haml";
|
|
120
|
+
import "prismjs/components/prism-handlebars";
|
|
121
|
+
import "prismjs/components/prism-haskell";
|
|
122
|
+
import "prismjs/components/prism-haxe";
|
|
123
|
+
import "prismjs/components/prism-hcl";
|
|
124
|
+
import "prismjs/components/prism-hlsl";
|
|
125
|
+
import "prismjs/components/prism-hoon";
|
|
126
|
+
import "prismjs/components/prism-hpkp";
|
|
127
|
+
import "prismjs/components/prism-hsts";
|
|
128
|
+
import "prismjs/components/prism-json";
|
|
129
|
+
import "prismjs/components/prism-uri";
|
|
130
|
+
import "prismjs/components/prism-http";
|
|
131
|
+
import "prismjs/components/prism-ichigojam";
|
|
132
|
+
import "prismjs/components/prism-icon";
|
|
133
|
+
import "prismjs/components/prism-icu-message-format";
|
|
134
|
+
import "prismjs/components/prism-idris";
|
|
135
|
+
import "prismjs/components/prism-ignore";
|
|
136
|
+
import "prismjs/components/prism-inform7";
|
|
137
|
+
import "prismjs/components/prism-ini";
|
|
138
|
+
import "prismjs/components/prism-io";
|
|
139
|
+
import "prismjs/components/prism-j";
|
|
140
|
+
import "prismjs/components/prism-java";
|
|
141
|
+
import "prismjs/components/prism-php";
|
|
142
|
+
import "prismjs/components/prism-javadoclike";
|
|
143
|
+
import "prismjs/components/prism-scala";
|
|
144
|
+
import "prismjs/components/prism-javadoc";
|
|
145
|
+
import "prismjs/components/prism-javastacktrace";
|
|
146
|
+
import "prismjs/components/prism-jexl";
|
|
147
|
+
import "prismjs/components/prism-jolie";
|
|
148
|
+
import "prismjs/components/prism-jq";
|
|
149
|
+
import "prismjs/components/prism-js-templates";
|
|
150
|
+
import "prismjs/components/prism-typescript";
|
|
151
|
+
import "prismjs/components/prism-jsdoc";
|
|
152
|
+
import "prismjs/components/prism-n4js";
|
|
153
|
+
import "prismjs/components/prism-js-extras";
|
|
154
|
+
import "prismjs/components/prism-json5";
|
|
155
|
+
import "prismjs/components/prism-jsonp";
|
|
156
|
+
import "prismjs/components/prism-jsstacktrace";
|
|
157
|
+
import "prismjs/components/prism-julia";
|
|
158
|
+
import "prismjs/components/prism-keepalived";
|
|
159
|
+
import "prismjs/components/prism-keyman";
|
|
160
|
+
import "prismjs/components/prism-kotlin";
|
|
161
|
+
import "prismjs/components/prism-kumir";
|
|
162
|
+
import "prismjs/components/prism-kusto";
|
|
163
|
+
import "prismjs/components/prism-latex";
|
|
164
|
+
import "prismjs/components/prism-latte";
|
|
165
|
+
import "prismjs/components/prism-scheme";
|
|
166
|
+
import "prismjs/components/prism-lilypond";
|
|
167
|
+
import "prismjs/components/prism-liquid";
|
|
168
|
+
import "prismjs/components/prism-lisp";
|
|
169
|
+
import "prismjs/components/prism-livescript";
|
|
170
|
+
import "prismjs/components/prism-llvm";
|
|
171
|
+
import "prismjs/components/prism-log";
|
|
172
|
+
import "prismjs/components/prism-lolcode";
|
|
173
|
+
import "prismjs/components/prism-magma";
|
|
174
|
+
import "prismjs/components/prism-makefile";
|
|
175
|
+
import "prismjs/components/prism-mata";
|
|
176
|
+
import "prismjs/components/prism-matlab";
|
|
177
|
+
import "prismjs/components/prism-maxscript";
|
|
178
|
+
import "prismjs/components/prism-mel";
|
|
179
|
+
import "prismjs/components/prism-mermaid";
|
|
180
|
+
import "prismjs/components/prism-metafont";
|
|
181
|
+
import "prismjs/components/prism-mizar";
|
|
182
|
+
import "prismjs/components/prism-mongodb";
|
|
183
|
+
import "prismjs/components/prism-monkey";
|
|
184
|
+
import "prismjs/components/prism-moonscript";
|
|
185
|
+
import "prismjs/components/prism-n1ql";
|
|
186
|
+
import "prismjs/components/prism-nand2tetris-hdl";
|
|
187
|
+
import "prismjs/components/prism-naniscript";
|
|
188
|
+
import "prismjs/components/prism-nasm";
|
|
189
|
+
import "prismjs/components/prism-neon";
|
|
190
|
+
import "prismjs/components/prism-nevod";
|
|
191
|
+
import "prismjs/components/prism-nginx";
|
|
192
|
+
import "prismjs/components/prism-nim";
|
|
193
|
+
import "prismjs/components/prism-nix";
|
|
194
|
+
import "prismjs/components/prism-nsis";
|
|
195
|
+
import "prismjs/components/prism-objectivec";
|
|
196
|
+
import "prismjs/components/prism-ocaml";
|
|
197
|
+
import "prismjs/components/prism-odin";
|
|
198
|
+
import "prismjs/components/prism-opencl";
|
|
199
|
+
import "prismjs/components/prism-openqasm";
|
|
200
|
+
import "prismjs/components/prism-oz";
|
|
201
|
+
import "prismjs/components/prism-parigp";
|
|
202
|
+
import "prismjs/components/prism-parser";
|
|
203
|
+
import "prismjs/components/prism-pascal";
|
|
204
|
+
import "prismjs/components/prism-pascaligo";
|
|
205
|
+
import "prismjs/components/prism-psl";
|
|
206
|
+
import "prismjs/components/prism-pcaxis";
|
|
207
|
+
import "prismjs/components/prism-peoplecode";
|
|
208
|
+
import "prismjs/components/prism-perl";
|
|
209
|
+
import "prismjs/components/prism-phpdoc";
|
|
210
|
+
import "prismjs/components/prism-php-extras";
|
|
211
|
+
import "prismjs/components/prism-plant-uml";
|
|
212
|
+
import "prismjs/components/prism-plsql";
|
|
213
|
+
import "prismjs/components/prism-powerquery";
|
|
214
|
+
import "prismjs/components/prism-powershell";
|
|
215
|
+
import "prismjs/components/prism-processing";
|
|
216
|
+
import "prismjs/components/prism-prolog";
|
|
217
|
+
import "prismjs/components/prism-promql";
|
|
218
|
+
import "prismjs/components/prism-properties";
|
|
219
|
+
import "prismjs/components/prism-protobuf";
|
|
220
|
+
import "prismjs/components/prism-stylus";
|
|
221
|
+
import "prismjs/components/prism-twig";
|
|
222
|
+
import "prismjs/components/prism-pug";
|
|
223
|
+
import "prismjs/components/prism-puppet";
|
|
224
|
+
import "prismjs/components/prism-pure";
|
|
225
|
+
import "prismjs/components/prism-purebasic";
|
|
226
|
+
import "prismjs/components/prism-purescript";
|
|
227
|
+
import "prismjs/components/prism-python";
|
|
228
|
+
import "prismjs/components/prism-qsharp";
|
|
229
|
+
import "prismjs/components/prism-q";
|
|
230
|
+
import "prismjs/components/prism-qml";
|
|
231
|
+
import "prismjs/components/prism-qore";
|
|
232
|
+
import "prismjs/components/prism-r";
|
|
233
|
+
import "prismjs/components/prism-racket";
|
|
234
|
+
import "prismjs/components/prism-cshtml";
|
|
235
|
+
import "prismjs/components/prism-jsx";
|
|
236
|
+
import "prismjs/components/prism-tsx";
|
|
237
|
+
import "prismjs/components/prism-reason";
|
|
238
|
+
import "prismjs/components/prism-rego";
|
|
239
|
+
import "prismjs/components/prism-renpy";
|
|
240
|
+
import "prismjs/components/prism-rescript";
|
|
241
|
+
import "prismjs/components/prism-rest";
|
|
242
|
+
import "prismjs/components/prism-rip";
|
|
243
|
+
import "prismjs/components/prism-roboconf";
|
|
244
|
+
import "prismjs/components/prism-robotframework";
|
|
245
|
+
import "prismjs/components/prism-rust";
|
|
246
|
+
import "prismjs/components/prism-sas";
|
|
247
|
+
import "prismjs/components/prism-sass";
|
|
248
|
+
import "prismjs/components/prism-shell-session";
|
|
249
|
+
import "prismjs/components/prism-smali";
|
|
250
|
+
import "prismjs/components/prism-smalltalk";
|
|
251
|
+
import "prismjs/components/prism-smarty";
|
|
252
|
+
import "prismjs/components/prism-sml";
|
|
253
|
+
import "prismjs/components/prism-solidity";
|
|
254
|
+
import "prismjs/components/prism-solution-file";
|
|
255
|
+
import "prismjs/components/prism-soy";
|
|
256
|
+
import "prismjs/components/prism-turtle";
|
|
257
|
+
import "prismjs/components/prism-sparql";
|
|
258
|
+
import "prismjs/components/prism-splunk-spl";
|
|
259
|
+
import "prismjs/components/prism-sqf";
|
|
260
|
+
import "prismjs/components/prism-squirrel";
|
|
261
|
+
import "prismjs/components/prism-stan";
|
|
262
|
+
import "prismjs/components/prism-stata";
|
|
263
|
+
import "prismjs/components/prism-iecst";
|
|
264
|
+
import "prismjs/components/prism-supercollider";
|
|
265
|
+
import "prismjs/components/prism-swift";
|
|
266
|
+
import "prismjs/components/prism-systemd";
|
|
267
|
+
import "prismjs/components/prism-t4-templating";
|
|
268
|
+
import "prismjs/components/prism-t4-cs";
|
|
269
|
+
import "prismjs/components/prism-vbnet";
|
|
270
|
+
import "prismjs/components/prism-t4-vb";
|
|
271
|
+
import "prismjs/components/prism-tap";
|
|
272
|
+
import "prismjs/components/prism-tcl";
|
|
273
|
+
import "prismjs/components/prism-tt2";
|
|
274
|
+
import "prismjs/components/prism-toml";
|
|
275
|
+
import "prismjs/components/prism-tremor";
|
|
276
|
+
import "prismjs/components/prism-typoscript";
|
|
277
|
+
import "prismjs/components/prism-unrealscript";
|
|
278
|
+
import "prismjs/components/prism-uorazor";
|
|
279
|
+
import "prismjs/components/prism-v";
|
|
280
|
+
import "prismjs/components/prism-vala";
|
|
281
|
+
import "prismjs/components/prism-velocity";
|
|
282
|
+
import "prismjs/components/prism-verilog";
|
|
283
|
+
import "prismjs/components/prism-vhdl";
|
|
284
|
+
import "prismjs/components/prism-vim";
|
|
285
|
+
import "prismjs/components/prism-visual-basic";
|
|
286
|
+
import "prismjs/components/prism-warpscript";
|
|
287
|
+
import "prismjs/components/prism-wasm";
|
|
288
|
+
import "prismjs/components/prism-web-idl";
|
|
289
|
+
import "prismjs/components/prism-wgsl";
|
|
290
|
+
import "prismjs/components/prism-wiki";
|
|
291
|
+
import "prismjs/components/prism-wolfram";
|
|
292
|
+
import "prismjs/components/prism-wren";
|
|
293
|
+
import "prismjs/components/prism-xeora";
|
|
294
|
+
import "prismjs/components/prism-xml-doc";
|
|
295
|
+
import "prismjs/components/prism-xojo";
|
|
296
|
+
import "prismjs/components/prism-xquery";
|
|
297
|
+
import "prismjs/components/prism-yang";
|
|
298
|
+
import "prismjs/components/prism-zig";
|
|
299
|
+
import { escapeHtml } from 'markdown-it/lib/common/utils';
|
|
300
|
+
export function highlightCode(text, lang) {
|
|
301
|
+
const grammar = Prism.languages[lang];
|
|
302
|
+
if (!grammar) return escapeHtml(text);
|
|
303
|
+
return Prism.highlight(text, grammar, lang);
|
|
304
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type Token from 'markdown-it/lib/token';
|
|
2
|
+
export declare const detailsOptions: {
|
|
3
|
+
validate: (params: string) => boolean;
|
|
4
|
+
render: (tokens: Token[], idx: number) => string;
|
|
5
|
+
};
|
|
6
|
+
export declare const boxOptions: {
|
|
7
|
+
validate: (params: string) => boolean;
|
|
8
|
+
render: (tokens: Token[], idx: number) => string;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=md-container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md-container.d.ts","sourceRoot":"","sources":["../../../src/utils/md-container.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAK/C,eAAO,MAAM,cAAc;uBACG,MAAM;qBAGR,KAAK,EAAE,OAAO,MAAM;CAc/C,CAAC;AAOF,eAAO,MAAM,UAAU;uBACO,MAAM;qBAGR,KAAK,EAAE,OAAO,MAAM;CAc/C,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { escapeHtml } from 'markdown-it/lib/common/utils';
|
|
2
|
+
// ::: details Detail
|
|
3
|
+
// summary here
|
|
4
|
+
// :::
|
|
5
|
+
export const detailsOptions = {
|
|
6
|
+
validate: function (params) {
|
|
7
|
+
return /^details\s+(.*)$/.test(params.trim());
|
|
8
|
+
},
|
|
9
|
+
render: function (tokens, idx) {
|
|
10
|
+
const isOpeningTag = tokens[idx].nesting === 1;
|
|
11
|
+
const m = tokens[idx].info.trim().match(/^details\s+(.*)$/);
|
|
12
|
+
const summary = (m === null || m === void 0 ? void 0 : m[1]) || '';
|
|
13
|
+
if (isOpeningTag) {
|
|
14
|
+
return '<details><summary>' + escapeHtml(summary) + '</summary><div class="details-content">';
|
|
15
|
+
} else {
|
|
16
|
+
return '</div></details>\n';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Box
|
|
22
|
+
// ::: box1 title
|
|
23
|
+
// markdown
|
|
24
|
+
// :::
|
|
25
|
+
//
|
|
26
|
+
export const boxOptions = {
|
|
27
|
+
validate: function (params) {
|
|
28
|
+
return /^(box[1-6])(?:\s+(.*))?$/.test(params.trim());
|
|
29
|
+
},
|
|
30
|
+
render: function (tokens, idx) {
|
|
31
|
+
const isOpeningTag = tokens[idx].nesting === 1;
|
|
32
|
+
if (isOpeningTag) {
|
|
33
|
+
const m = tokens[idx].info.trim().match(/^(box[1-6])(?:\s+(.*))?$/);
|
|
34
|
+
if (!m) return '';
|
|
35
|
+
const boxType = m[1]; // box1, box2, etc.
|
|
36
|
+
const boxTitle = m[2] || ''; // title (optional)
|
|
37
|
+
return boxHtml(boxType, boxTitle);
|
|
38
|
+
} else {
|
|
39
|
+
return '</div>\n';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const boxHtml = (boxType, boxTitle) => {
|
|
44
|
+
switch (boxType) {
|
|
45
|
+
case 'box1':
|
|
46
|
+
return `<div class="box ${boxType}">${boxTitle ? `<span>${boxTitle}</span>` : ''}`;
|
|
47
|
+
case 'box2':
|
|
48
|
+
return `<div class="box ${boxType}">`;
|
|
49
|
+
case 'box3':
|
|
50
|
+
return `<div class="box ${boxType}"><div class="msg-container"><span class="icon"></span>${`<span>${boxTitle ? boxTitle : 'Note'}</span>`}</div>`;
|
|
51
|
+
case 'box4':
|
|
52
|
+
return `<div class="box ${boxType}"><div class="msg-container"><span class="icon"></span>${`<span>${boxTitle ? boxTitle : 'Alert'}</span>`}</div>`;
|
|
53
|
+
case 'box5':
|
|
54
|
+
case 'box6':
|
|
55
|
+
return `<div class="box ${boxType}"><div class="msg-container"><span class="icon"></span>${boxTitle ? `<span>${boxTitle}</span>` : ''}</div>`;
|
|
56
|
+
default:
|
|
57
|
+
return `<div class="box ${boxType}">${boxTitle ? `<span>${boxTitle}</span>` : ''}`;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md-renderer-fence.d.ts","sourceRoot":"","sources":["../../../src/utils/md-renderer-fence.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AAsDrC,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAkBA;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,UAAU,QAoB7C"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { escapeHtml } from 'markdown-it/lib/common/utils';
|
|
2
|
+
import { highlightCode } from './highlight';
|
|
3
|
+
function getHtml({
|
|
4
|
+
content,
|
|
5
|
+
className,
|
|
6
|
+
fileName,
|
|
7
|
+
line
|
|
8
|
+
}) {
|
|
9
|
+
const escapedClass = escapeHtml(className);
|
|
10
|
+
return `<div class="code-container">${fileName ? `<div class="code-filename-container"><span class="code-filename">${escapeHtml(fileName)}</span></div>` : ''}<pre class="${escapedClass}"><code class="${escapedClass !== '' ? `${escapedClass} code-line` : 'code-line'}" ${line !== undefined ? `data-line="${line}"` : ''}>${content}</code></pre></div>`;
|
|
11
|
+
}
|
|
12
|
+
function getClassName({
|
|
13
|
+
lang = ''
|
|
14
|
+
}) {
|
|
15
|
+
const isSafe = /^[\w-]{0,30}$/.test(lang);
|
|
16
|
+
if (!isSafe) return '';
|
|
17
|
+
return lang ? `language-${lang}` : '';
|
|
18
|
+
}
|
|
19
|
+
const fallbackLanguages = {
|
|
20
|
+
vue: 'html',
|
|
21
|
+
react: 'jsx',
|
|
22
|
+
fish: 'shell',
|
|
23
|
+
sh: 'shell',
|
|
24
|
+
cwl: 'yaml',
|
|
25
|
+
tf: 'hcl' // ref: https://github.com/PrismJS/prism/issues/1252
|
|
26
|
+
};
|
|
27
|
+
function normalizeLangName(str) {
|
|
28
|
+
if (!(str !== null && str !== void 0 && str.length)) return '';
|
|
29
|
+
const langName = str.toLocaleLowerCase();
|
|
30
|
+
return fallbackLanguages[langName] ?? langName;
|
|
31
|
+
}
|
|
32
|
+
export function parseInfo(str) {
|
|
33
|
+
if (str.trim() === '') {
|
|
34
|
+
return {
|
|
35
|
+
lang: '',
|
|
36
|
+
fileName: undefined
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// NOTE: javascript:index.js => ["javascript", "index.js"]
|
|
41
|
+
const [langInfo, fileName] = str.split(':');
|
|
42
|
+
const langNames = langInfo.split(' ');
|
|
43
|
+
const langName = langNames[0];
|
|
44
|
+
return {
|
|
45
|
+
lang: normalizeLangName(langName),
|
|
46
|
+
fileName
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function mdRendererFence(md) {
|
|
50
|
+
// override fence
|
|
51
|
+
md.renderer.rules.fence = function (...args) {
|
|
52
|
+
var _tokens$idx$map;
|
|
53
|
+
const [tokens, idx] = args;
|
|
54
|
+
const {
|
|
55
|
+
info,
|
|
56
|
+
content
|
|
57
|
+
} = tokens[idx];
|
|
58
|
+
const {
|
|
59
|
+
lang,
|
|
60
|
+
fileName
|
|
61
|
+
} = parseInfo(info);
|
|
62
|
+
const className = getClassName({
|
|
63
|
+
lang
|
|
64
|
+
});
|
|
65
|
+
const highlightedContent = highlightCode(content, lang);
|
|
66
|
+
const fenceStart = (_tokens$idx$map = tokens[idx].map) === null || _tokens$idx$map === void 0 ? void 0 : _tokens$idx$map[0];
|
|
67
|
+
return getHtml({
|
|
68
|
+
content: highlightedContent,
|
|
69
|
+
className,
|
|
70
|
+
fileName,
|
|
71
|
+
line: fenceStart
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@media screen and (max-width: 576px){pre>code{padding:1rem .8rem;font-size:.85em}}details{font-size:.95em;margin:1rem 0;line-height:1.7}summary{cursor:pointer;outline:0;padding:.7em .7em .7em .9em;border:solid 1px var(--border);color:var(--primary);font-size:.9em;border-radius:var(--rounded-sm);background:var(--background)}summary::-webkit-details-marker{color:var(--muted-foreground)}details[open]>summary{border-radius:var(--rounded-sm) var(--rounded-sm) 0 0;box-shadow:none;background:var(--background);border-bottom:none}.details-content{padding:.5em .9em;border:solid 1px var(--border);border-radius:0 0 var(--rounded-lg) var(--rounded-lg);background:var(--background)}.details-content>*{margin:.5em 0}.box{margin:1.2rem 0}.box.box1{position:relative;border:1px solid var(--border);border-radius:var(--rounded-sm);padding:1rem}.box.box1 span{position:absolute;top:0;left:1rem;font-size:1.2em;color:var(--foreground);background-color:var(--background);padding:0 .5em;transform:translateY(-50%)}.box.box2{position:relative;border-radius:var(--rounded-sm);padding:1rem;background-color:var(--secondary)}.box.box3{position:relative;border-radius:var(--rounded-sm);padding:1rem;background-color:var(--background);border:2px solid var(--warning-foreground)}.box.box3 .msg-container{position:absolute;top:0;left:1rem;background-color:var(--background);padding:0 .5rem;transform:translateY(-50%);display:flex;flex-direction:row;align-items:center;gap:.3rem;color:var(--warning-foreground);font-weight:bold}.box.box3 .icon{box-sizing:border-box;position:relative;width:20px;height:20px;border:2px solid var(--warning-foreground);background-color:var(--warning-foreground);border-radius:50%}.box.box3 .icon::before,.box.box3 .icon::after{content:"";position:absolute;border-radius:3px;width:2px;background:#fff;left:7px}.box.box3 .icon::before{top:2px;height:2px}.box.box3 .icon::after{height:8px;bottom:2px}.box.box4{position:relative;border-radius:var(--rounded-sm);padding:1rem;background-color:var(--background);border:2px solid var(--danger-foreground)}.box.box4 .msg-container{position:absolute;top:0;left:1rem;background-color:var(--background);padding:0 .5rem;transform:translateY(-50%);display:flex;flex-direction:row;align-items:center;gap:.3rem;color:var(--danger-foreground);font-weight:bold}.box.box4 .icon{box-sizing:border-box;position:relative;width:20px;height:20px;border:2px solid var(--danger-foreground);background-color:var(--danger-foreground);border-radius:50%}.box.box4 .icon::before,.box.box4 .icon::after{content:"";position:absolute;border-radius:3px;width:2px;background:#fff;left:7px}.box.box4 .icon::before{top:2px;height:2px}.box.box4 .icon::after{height:8px;bottom:2px}.box.box5{position:relative;border-radius:var(--rounded-sm);padding:1rem;background-color:var(--warning)}.box.box5 .msg-container{display:flex;flex-direction:row;align-items:center;gap:.3rem;color:var(--warning-foreground);font-weight:bold}.box.box5 .icon{box-sizing:border-box;position:relative;width:20px;height:20px;border:2px solid var(--warning-foreground);background-color:var(--warning-foreground);border-radius:50%}.box.box5 .icon::before,.box.box5 .icon::after{content:"";position:absolute;border-radius:3px;width:2px;background:#fff;left:7px}.box.box5 .icon::before{top:2px;height:2px}.box.box5 .icon::after{height:8px;bottom:2px}.box.box6{position:relative;border-radius:var(--rounded-sm);padding:1rem;background-color:var(--danger)}.box.box6 .msg-container{display:flex;flex-direction:row;align-items:center;gap:.3rem;color:var(--danger-foreground);font-weight:bold}.box.box6 .icon{box-sizing:border-box;position:relative;width:20px;height:20px;border:2px solid var(--danger-foreground);background-color:var(--danger-foreground);border-radius:50%}.box.box6 .icon::before,.box.box6 .icon::after{content:"";position:absolute;border-radius:3px;width:2px;background:#fff;left:7px}.box.box6 .icon::before{top:2px;height:2px}.box.box6 .icon::after{height:8px;bottom:2px}.nbcontent{--background: oklch(100% 0 0deg);--foreground: oklch(14.1% 0.005 285.823deg);--primary: oklch(21% 0.006 285.885deg);--primary-foreground: oklch(98.5% 0 0deg);--secondary: oklch(96.7% 0.001 286.375deg);--secondary-foreground: oklch(21% 0.006 285.885deg);--muted: oklch(96.7% 0.001 286.375deg);--muted-foreground: oklch(55.2% 0.016 285.938deg);--accent: oklch(96.7% 0.001 286.375deg);--accent-foreground: oklch(21% 0.006 285.885deg);--destructive: oklch(57.7% 0.245 27.325deg);--border: oklch(92% 0.004 286.32deg);--input: oklch(92% 0.004 286.32deg);--ring: oklch(70.5% 0.015 286.067deg);--link: oklch(45.2% 0.313214 264.052deg);--warning: oklch(97.54% 0.025552 84.593deg);--warning-foreground: oklch(83.04% 0.1459 74.36deg);--danger: oklch(96.56% 0.0177 4.51deg);--danger-foreground: oklch(72.71% 0.1684 24.66deg);--rounded-xs: 4px;--rounded-sm: 7px;--rounded-md: 10px;--rounded-lg: 14px;--rounded-full: 99rem;line-height:1.8;background-color:var(--background);color:var(--foreground)}.nbcontent>*:first-child{margin-top:0}.nbcontent i,.nbcontent cite,.nbcontent em,.nbcontent var{font-style:italic}.nbcontent strong{font-weight:bold}.nbcontent a{color:var(--link)}.nbcontent a:hover{text-decoration:underline}.nbcontent p+p{margin-top:1.2em}.nbcontent h1,.nbcontent h2,.nbcontent h3,.nbcontent h4,.nbcontent h5,.nbcontent h6{font-weight:bold}.nbcontent h1+p,.nbcontent h2+p,.nbcontent h3+p,.nbcontent h4+p,.nbcontent h5+p,.nbcontent h6+p{margin-top:.2em}.nbcontent h1,.nbcontent h2{margin-top:1.9em;margin-bottom:.3em;padding-bottom:.1em;border-bottom:solid 1px var(--border)}.nbcontent h3,.nbcontent h4,.nbcontent h5,.nbcontent h6{margin-top:1.8em;margin-bottom:.3em}.nbcontent h1{font-size:1.7em}.nbcontent h2{font-size:1.5em}.nbcontent h3{font-size:1.3em}.nbcontent h4{font-size:1.1em}.nbcontent h5{font-size:1em}.nbcontent h6{font-size:.9em}@media screen and (max-width: 576px){.nbcontent h1{font-size:1.6em}.nbcontent h2{font-size:1.4em}.nbcontent h3{font-size:1.2em}.nbcontent h4{font-size:1.1em}.nbcontent h5{font-size:1em}.nbcontent h6{font-size:.85em}}.nbcontent ul,.nbcontent ol{margin:1.4rem 0;line-height:1.6}.nbcontent ul>li,.nbcontent ol>li{margin:.4rem 0}.nbcontent ul ul,.nbcontent ul ol,.nbcontent ol ul,.nbcontent ol ol{margin:.2em 0}.nbcontent ul p,.nbcontent ol p{margin:0}.nbcontent ul{padding-left:1.8em}.nbcontent ul>li{list-style:disc}.nbcontent ul>li::marker{font-size:1.1em}.nbcontent ol{padding-left:1.7em}.nbcontent ol>li{list-style:decimal;padding-left:.2em}.nbcontent ol>li::marker{font-weight:600;letter-spacing:-0.05em}.nbcontent .contains-task-list .task-list-item{list-style:none}.nbcontent .task-list-item-checkbox{margin-left:-1.5em;font-size:1em;pointer-events:none}.nbcontent code{padding:.2em .4em;background:var(--secondary);font-size:.85em;border-radius:var(--rounded-xs);vertical-align:.08em}.nbcontent code,.nbcontent .code-filename{font-family:"JetBrains Mono","Fira Code","SFMono-Regular",Consolas,"Liberation Mono",Menlo,"Cascadia Code","Source Code Pro",monospace,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";-webkit-font-smoothing:antialiased}.nbcontent .code-container{position:relative;margin:1.3rem 0}.nbcontent .code-filename{display:table;max-width:100%;background:var(--primary);color:var(--primary-foreground);font-size:12px;line-height:1.3;border-radius:var(--rounded-xs) var(--rounded-xs) 0 0;padding:6px 12px 20px;margin-bottom:-24px}.nbcontent .code-filename-container+pre{border-top-left-radius:0}.nbcontent pre{margin:1.3rem 0;background:var(--primary);overflow-x:auto;-webkit-overflow-scrolling:touch;border-radius:var(--rounded-md);word-break:normal;word-wrap:normal;display:flex}.nbcontent pre:after{content:"";width:8px;flex-shrink:0}.nbcontent pre code{margin:0;padding:0;background:rgba(0,0,0,0);font-size:.9em}.nbcontent pre>code{display:block;padding:1.1rem}.nbcontent table{margin:1.2rem auto;width:auto;border-collapse:collapse;font-size:.95em;line-height:1.5;word-break:normal;display:block;overflow:auto;-webkit-overflow-scrolling:touch}.nbcontent th,.nbcontent td{padding:.6rem;border:solid 1px var(--border);background:var(--background)}.nbcontent th{font-weight:700;background:var(--secondary)}.nbcontent img:not(.emoji){margin:1.5rem auto;display:table;max-width:100%;height:auto}.nbcontent img+br{display:none}.nbcontent img~em{display:block;margin:-1rem auto 0;line-height:1.3;text-align:center;color:var(--muted-foreground);font-size:.92em}.nbcontent a:has(img){display:table;margin:0 auto}.nbcontent hr{border-top:2px solid var(--border);margin:2.5rem 0}.nbcontent blockquote{font-size:.97em;margin:1.4rem 0;border-left:solid 3px var(--border);padding:2px 0 2px .7em;color:var(--muted-foreground)}.nbcontent blockquote p{margin:1rem 0}.nbcontent blockquote>:first-child{margin-top:0}.nbcontent blockquote>:last-child{margin-bottom:0}.nbcontent blockquote.twitter-tweet{display:none}.dark .nbcontent{--background: oklch(14.1% 0.005 285.823deg);--foreground: oklch(98.5% 0 0deg);--primary: oklch(92% 0.004 286.32deg);--primary-foreground: oklch(21% 0.006 285.885deg);--secondary: oklch(27.4% 0.006 286.033deg);--secondary-foreground: oklch(98.5% 0 0deg);--muted: oklch(27.4% 0.006 286.033deg);--muted-foreground: oklch(70.5% 0.015 286.067deg);--accent: oklch(27.4% 0.006 286.033deg);--accent-foreground: oklch(98.5% 0 0deg);--destructive: oklch(70.4% 0.191 22.216deg);--border: oklch(100% 0 0deg / 0.1);--input: oklch(100% 0 0deg / 0.15);--ring: oklch(55.2% 0.016 285.938deg);--link: oklch(45.2% 0.313214 264.052deg);--warning: oklch(97.54% 0.025552 84.593deg);--warning-foreground: oklch(83.04% 0.1459 74.36deg);--danger: oklch(96.56% 0.0177 4.51deg);--danger-foreground: oklch(72.71% 0.1684 24.66deg);--rounded-xs: 4px;--rounded-sm: 7px;--rounded-md: 10px;--rounded-lg: 14px;--rounded-full: 99rem}
|
package/package.json
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nakobase/nakobase-md-html",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Convert Markdown to **sanitized HTML** and apply consistent styles – simple, secure, and styled.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"bin": "./dist/esm/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/esm/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./styles/style.css": {
|
|
14
|
+
"import": "./dist/styles/style.css"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/esm",
|
|
19
|
+
"dist/styles",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"workspaces": [
|
|
24
|
+
"test-app"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"clean": "rimraf dist",
|
|
28
|
+
"build:types": "tsc --project tsconfig.esm.json",
|
|
29
|
+
"build:js": "babel src --extensions .ts,.tsx --ignore **/*.d.ts --out-dir dist/esm",
|
|
30
|
+
"build:styles": "sass src/styles/style.scss:dist/styles/style.css --no-source-map --style compressed",
|
|
31
|
+
"build": "pnpm run clean && pnpm run build:types && pnpm run build:styles && pnpm run build:js",
|
|
32
|
+
"start": "pnpm run build && node dist/esm/index.js",
|
|
33
|
+
"test": "jest",
|
|
34
|
+
"test:watch": "jest --watch",
|
|
35
|
+
"test:coverage": "jest --coverage",
|
|
36
|
+
"prepare": "husky"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/nakobase/nakobase-md-html.git"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/nakobase/nakobase-md-html#readme",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/nakobase/nakobase-md-html/issues"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public",
|
|
48
|
+
"registry": "https://registry.npmjs.org/"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"github",
|
|
52
|
+
"cli",
|
|
53
|
+
"nakobase",
|
|
54
|
+
"markdown",
|
|
55
|
+
"html",
|
|
56
|
+
"nodejs"
|
|
57
|
+
],
|
|
58
|
+
"author": "NakoBase",
|
|
59
|
+
"license": "MIT",
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@babel/cli": "^7.20.7",
|
|
62
|
+
"@babel/core": "^7.20.12",
|
|
63
|
+
"@babel/preset-env": "^7.20.2",
|
|
64
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
65
|
+
"@commitlint/cli": "^19.4.0",
|
|
66
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
67
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
68
|
+
"@semantic-release/git": "^10.0.1",
|
|
69
|
+
"@semantic-release/github": "^10.1.7",
|
|
70
|
+
"@semantic-release/npm": "^12.0.1",
|
|
71
|
+
"@types/jest": "^29.5.14",
|
|
72
|
+
"@types/markdown-it": "^12.2.3",
|
|
73
|
+
"@types/markdown-it-container": "^2.0.10",
|
|
74
|
+
"@types/node": "^22.4.2",
|
|
75
|
+
"@types/prismjs": "^1.26.5",
|
|
76
|
+
"@types/sanitize-html": "^2.15.0",
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "^8.2.0",
|
|
78
|
+
"@typescript-eslint/parser": "^8.2.0",
|
|
79
|
+
"babel-plugin-prismjs": "^2.1.0",
|
|
80
|
+
"cpx": "^1.5.0",
|
|
81
|
+
"eslint": "^9.9.0",
|
|
82
|
+
"eslint-config-prettier": "^9.1.0",
|
|
83
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
84
|
+
"husky": "^9.1.5",
|
|
85
|
+
"jest": "^29.7.0",
|
|
86
|
+
"prettier": "^3.3.3",
|
|
87
|
+
"rimraf": "^6.0.1",
|
|
88
|
+
"sass": "^1.89.0",
|
|
89
|
+
"semantic-release": "^24.1.0",
|
|
90
|
+
"ts-jest": "^29.3.2",
|
|
91
|
+
"ts-node": "^10.9.2",
|
|
92
|
+
"typescript": "^5.5.4"
|
|
93
|
+
},
|
|
94
|
+
"dependencies": {
|
|
95
|
+
"@steelydylan/markdown-it-imsize": "^1.0.2",
|
|
96
|
+
"markdown-it": "^12.3.2",
|
|
97
|
+
"markdown-it-container": "^2.0.0",
|
|
98
|
+
"markdown-it-custom-block": "^1.0.0",
|
|
99
|
+
"markdown-it-inline-comments": "^1.0.1",
|
|
100
|
+
"markdown-it-task-lists": "^2.1.1",
|
|
101
|
+
"prismjs": "^1.30.0",
|
|
102
|
+
"sanitize-html": "^2.16.0"
|
|
103
|
+
}
|
|
104
|
+
}
|