@mdit-vue/shared 0.12.0 → 0.12.1

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.
@@ -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 };
@@ -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.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Shared utils and types of mdit-vue",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -37,11 +37,11 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@mdit-vue/types": "0.12.0",
40
- "@types/markdown-it": "^12.2.3",
40
+ "@types/markdown-it": "^13.0.0",
41
41
  "markdown-it": "^13.0.1"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  },
46
- "gitHead": "986b6023d3460cadefd409cd5d4b6445af3a05bd"
46
+ "gitHead": "198a71b2e4175a92843609a63d2a848bddb71740"
47
47
  }