@mdit-vue/shared 0.12.0 → 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/dist/index.d.cts +69 -0
- package/dist/index.d.mts +69 -0
- package/dist/index.d.ts +1 -1
- package/package.json +12 -7
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { MarkdownItHeader } from '@mdit-vue/types';
|
|
2
|
+
import Token from 'markdown-it/lib/token.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Escape html chars
|
|
6
|
+
*/
|
|
7
|
+
declare const htmlEscape: (str: string) => string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Unescape html chars
|
|
11
|
+
*/
|
|
12
|
+
declare const htmlUnescape: (str: string) => string;
|
|
13
|
+
|
|
14
|
+
interface ResolveTitleOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Should allow inline HTML tags or not.
|
|
17
|
+
*
|
|
18
|
+
* If the result is going to be used as Vue template, it should allow inline
|
|
19
|
+
* HTML tags so that Vue custom components would be kept.
|
|
20
|
+
*/
|
|
21
|
+
shouldAllowHtml: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Should escape the text content or not.
|
|
24
|
+
*
|
|
25
|
+
* If the result is going to be used in HTML directly, it should be escaped
|
|
26
|
+
* so that the text content won't be wrongly treated as HTML tags.
|
|
27
|
+
*/
|
|
28
|
+
shouldEscapeText: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolve header title from markdown-it token
|
|
32
|
+
*
|
|
33
|
+
* Typically using the next token of `heading_open` token
|
|
34
|
+
*/
|
|
35
|
+
declare const resolveTitleFromToken: (token: Token, { shouldAllowHtml, shouldEscapeText }: ResolveTitleOptions) => string;
|
|
36
|
+
|
|
37
|
+
interface ResolveHeadersOptions extends ResolveTitleOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Heading level that going to be resolved
|
|
40
|
+
*/
|
|
41
|
+
level: number[];
|
|
42
|
+
/**
|
|
43
|
+
* Should allow headers inside nested blocks or not
|
|
44
|
+
*
|
|
45
|
+
* If set to `true`, headers inside blockquote, list, etc. would also be resolved.
|
|
46
|
+
*/
|
|
47
|
+
shouldAllowNested: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* A custom slugification function
|
|
50
|
+
*
|
|
51
|
+
* Would be ignored if the `id` attr of the token is set.
|
|
52
|
+
*/
|
|
53
|
+
slugify: (str: string) => string;
|
|
54
|
+
/**
|
|
55
|
+
* A function for formatting headings
|
|
56
|
+
*/
|
|
57
|
+
format?: (str: string) => string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolve headers from markdown-it tokens
|
|
61
|
+
*/
|
|
62
|
+
declare const resolveHeadersFromTokens: (tokens: Token[], { level, shouldAllowHtml, shouldAllowNested, shouldEscapeText, slugify, format, }: ResolveHeadersOptions) => MarkdownItHeader[];
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Default slugification function
|
|
66
|
+
*/
|
|
67
|
+
declare const slugify: (str: string) => string;
|
|
68
|
+
|
|
69
|
+
export { type ResolveHeadersOptions, type ResolveTitleOptions, htmlEscape, htmlUnescape, resolveHeadersFromTokens, resolveTitleFromToken, slugify };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { MarkdownItHeader } from '@mdit-vue/types';
|
|
2
|
+
import Token from 'markdown-it/lib/token.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Escape html chars
|
|
6
|
+
*/
|
|
7
|
+
declare const htmlEscape: (str: string) => string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Unescape html chars
|
|
11
|
+
*/
|
|
12
|
+
declare const htmlUnescape: (str: string) => string;
|
|
13
|
+
|
|
14
|
+
interface ResolveTitleOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Should allow inline HTML tags or not.
|
|
17
|
+
*
|
|
18
|
+
* If the result is going to be used as Vue template, it should allow inline
|
|
19
|
+
* HTML tags so that Vue custom components would be kept.
|
|
20
|
+
*/
|
|
21
|
+
shouldAllowHtml: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Should escape the text content or not.
|
|
24
|
+
*
|
|
25
|
+
* If the result is going to be used in HTML directly, it should be escaped
|
|
26
|
+
* so that the text content won't be wrongly treated as HTML tags.
|
|
27
|
+
*/
|
|
28
|
+
shouldEscapeText: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolve header title from markdown-it token
|
|
32
|
+
*
|
|
33
|
+
* Typically using the next token of `heading_open` token
|
|
34
|
+
*/
|
|
35
|
+
declare const resolveTitleFromToken: (token: Token, { shouldAllowHtml, shouldEscapeText }: ResolveTitleOptions) => string;
|
|
36
|
+
|
|
37
|
+
interface ResolveHeadersOptions extends ResolveTitleOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Heading level that going to be resolved
|
|
40
|
+
*/
|
|
41
|
+
level: number[];
|
|
42
|
+
/**
|
|
43
|
+
* Should allow headers inside nested blocks or not
|
|
44
|
+
*
|
|
45
|
+
* If set to `true`, headers inside blockquote, list, etc. would also be resolved.
|
|
46
|
+
*/
|
|
47
|
+
shouldAllowNested: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* A custom slugification function
|
|
50
|
+
*
|
|
51
|
+
* Would be ignored if the `id` attr of the token is set.
|
|
52
|
+
*/
|
|
53
|
+
slugify: (str: string) => string;
|
|
54
|
+
/**
|
|
55
|
+
* A function for formatting headings
|
|
56
|
+
*/
|
|
57
|
+
format?: (str: string) => string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolve headers from markdown-it tokens
|
|
61
|
+
*/
|
|
62
|
+
declare const resolveHeadersFromTokens: (tokens: Token[], { level, shouldAllowHtml, shouldAllowNested, shouldEscapeText, slugify, format, }: ResolveHeadersOptions) => MarkdownItHeader[];
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Default slugification function
|
|
66
|
+
*/
|
|
67
|
+
declare const slugify: (str: string) => string;
|
|
68
|
+
|
|
69
|
+
export { type ResolveHeadersOptions, type ResolveTitleOptions, htmlEscape, htmlUnescape, resolveHeadersFromTokens, resolveTitleFromToken, slugify };
|
package/dist/index.d.ts
CHANGED
|
@@ -66,4 +66,4 @@ declare const resolveHeadersFromTokens: (tokens: Token[], { level, shouldAllowHt
|
|
|
66
66
|
*/
|
|
67
67
|
declare const slugify: (str: string) => string;
|
|
68
68
|
|
|
69
|
-
export { ResolveHeadersOptions, ResolveTitleOptions, htmlEscape, htmlUnescape, resolveHeadersFromTokens, resolveTitleFromToken, slugify };
|
|
69
|
+
export { type ResolveHeadersOptions, type ResolveTitleOptions, htmlEscape, htmlUnescape, resolveHeadersFromTokens, resolveTitleFromToken, slugify };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit-vue/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Shared utils and types of mdit-vue",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -20,9 +20,14 @@
|
|
|
20
20
|
"type": "module",
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./dist/index.d.mts",
|
|
25
|
+
"default": "./dist/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"require": {
|
|
28
|
+
"types": "./dist/index.d.cts",
|
|
29
|
+
"default": "./dist/index.cjs"
|
|
30
|
+
}
|
|
26
31
|
}
|
|
27
32
|
},
|
|
28
33
|
"main": "./dist/index.cjs",
|
|
@@ -36,12 +41,12 @@
|
|
|
36
41
|
"test": "vitest"
|
|
37
42
|
},
|
|
38
43
|
"dependencies": {
|
|
39
|
-
"@mdit-vue/types": "0.
|
|
40
|
-
"@types/markdown-it": "^
|
|
44
|
+
"@mdit-vue/types": "1.0.0",
|
|
45
|
+
"@types/markdown-it": "^13.0.1",
|
|
41
46
|
"markdown-it": "^13.0.1"
|
|
42
47
|
},
|
|
43
48
|
"publishConfig": {
|
|
44
49
|
"access": "public"
|
|
45
50
|
},
|
|
46
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "d5388b9a8ec1e9075c41587410151ec2a6bc0df1"
|
|
47
52
|
}
|