@md-plugins/shared 0.1.0-alpha.9 → 0.1.0-beta.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.
- package/README.md +9 -5
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.mjs +11 -4
- package/package.json +14 -16
package/README.md
CHANGED
|
@@ -14,12 +14,12 @@ The `@md-plugins/shared` package provides common utilities, types, and helpers u
|
|
|
14
14
|
Install the plugin via your preferred package manager:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
#
|
|
18
|
-
npm install @md-plugins/shared
|
|
19
|
-
# Or with Yarn:
|
|
20
|
-
yarn add @md-plugins/shared
|
|
21
|
-
# Or with pnpm:
|
|
17
|
+
# with pnpm:
|
|
22
18
|
pnpm add @md-plugins/shared
|
|
19
|
+
# with Yarn:
|
|
20
|
+
yarn add @md-plugins/shared
|
|
21
|
+
# with npm:
|
|
22
|
+
npm install @md-plugins/shared
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Usage
|
|
@@ -98,6 +98,10 @@ function slugify(str: string): string
|
|
|
98
98
|
- Converts a string into a URL-friendly slug.
|
|
99
99
|
- Removes special characters and replaces spaces with hyphens.
|
|
100
100
|
|
|
101
|
+
## Documentation
|
|
102
|
+
|
|
103
|
+
In case this README falls out of date, please refer to the [documentation](https://md-plugins.netlify.app/md-plugins/shared/overview) for the latest information.
|
|
104
|
+
|
|
101
105
|
## License
|
|
102
106
|
|
|
103
107
|
This package is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
|
package/dist/index.d.mts
CHANGED
|
@@ -41,6 +41,9 @@ interface MarkdownItHeader {
|
|
|
41
41
|
*/
|
|
42
42
|
children: MarkdownItHeader[];
|
|
43
43
|
}
|
|
44
|
+
type ResolvePluginOptionsFn = <T extends object, K extends keyof any>(options: T | {
|
|
45
|
+
[P in K]?: T;
|
|
46
|
+
} | undefined, key: K, defaults: T) => T;
|
|
44
47
|
|
|
45
48
|
interface ResolveTitleOptions {
|
|
46
49
|
/**
|
|
@@ -97,4 +100,9 @@ declare const resolveHeadersFromTokens: (tokens: Token[], { level, shouldAllowHt
|
|
|
97
100
|
*/
|
|
98
101
|
declare const slugify: (str: string) => string;
|
|
99
102
|
|
|
100
|
-
|
|
103
|
+
declare function resolvePluginOptions<T extends object, K extends keyof any>(options: T | {
|
|
104
|
+
[key in K]?: T;
|
|
105
|
+
} | undefined, key: K, defaults: T): T;
|
|
106
|
+
|
|
107
|
+
export { htmlEscape, htmlUnescape, resolveHeadersFromTokens, resolvePluginOptions, resolveTitleFromToken, slugify };
|
|
108
|
+
export type { MarkdownItEnv, MarkdownItHeader, ResolveHeadersOptions, ResolvePluginOptionsFn, ResolveTitleOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -41,6 +41,9 @@ interface MarkdownItHeader {
|
|
|
41
41
|
*/
|
|
42
42
|
children: MarkdownItHeader[];
|
|
43
43
|
}
|
|
44
|
+
type ResolvePluginOptionsFn = <T extends object, K extends keyof any>(options: T | {
|
|
45
|
+
[P in K]?: T;
|
|
46
|
+
} | undefined, key: K, defaults: T) => T;
|
|
44
47
|
|
|
45
48
|
interface ResolveTitleOptions {
|
|
46
49
|
/**
|
|
@@ -97,4 +100,9 @@ declare const resolveHeadersFromTokens: (tokens: Token[], { level, shouldAllowHt
|
|
|
97
100
|
*/
|
|
98
101
|
declare const slugify: (str: string) => string;
|
|
99
102
|
|
|
100
|
-
|
|
103
|
+
declare function resolvePluginOptions<T extends object, K extends keyof any>(options: T | {
|
|
104
|
+
[key in K]?: T;
|
|
105
|
+
} | undefined, key: K, defaults: T): T;
|
|
106
|
+
|
|
107
|
+
export { htmlEscape, htmlUnescape, resolveHeadersFromTokens, resolvePluginOptions, resolveTitleFromToken, slugify };
|
|
108
|
+
export type { MarkdownItEnv, MarkdownItHeader, ResolveHeadersOptions, ResolvePluginOptionsFn, ResolveTitleOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -43,11 +43,11 @@ const resolveTitleFromToken = (token, { shouldAllowHtml, shouldEscapeText }) =>
|
|
|
43
43
|
}, "").trim();
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
const andRE = /&/g;
|
|
47
|
+
const rCombining = /[\u0300-\u036F]/g;
|
|
46
48
|
const rControl = /[\u0000-\u001f]/g;
|
|
47
49
|
const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'“”‘’<>,.?/]+/g;
|
|
48
|
-
const
|
|
49
|
-
const andRE = /&/g;
|
|
50
|
-
const slugify = (str) => str.normalize("NFKD").toLowerCase().replace(andRE, "-and-").replace(rCombining, "").replace(rControl, "-").replace(rSpecial, "-").replace(/[^a-z0-9-]+/g, "").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "").replace(/^(\d)/, "_$1");
|
|
50
|
+
const slugify = (str) => str.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase().normalize("NFKD").replace(rCombining, "").replace(andRE, "-and-").replace(rControl, "-").replace(rSpecial, "-").replace(/[^a-z0-9-]+/g, "").replace(/([a-z])(\d)/g, "$1-$2").replace(/(\d)([a-z])/g, "$1-$2").replace(/-{2,}/g, "-").replace(/(^-|-$)/g, "").replace(/^(\d)/, "_$1");
|
|
51
51
|
|
|
52
52
|
const resolveHeadersFromTokens = (tokens, {
|
|
53
53
|
level = [1, 2, 3],
|
|
@@ -93,4 +93,11 @@ const resolveHeadersFromTokens = (tokens, {
|
|
|
93
93
|
return headers;
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
function resolvePluginOptions(options, key, defaults) {
|
|
97
|
+
if (options && typeof options === "object" && key in options) {
|
|
98
|
+
return { ...defaults, ...options[key] };
|
|
99
|
+
}
|
|
100
|
+
return { ...defaults, ...options };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { htmlEscape, htmlUnescape, resolveHeadersFromTokens, resolvePluginOptions, resolveTitleFromToken, slugify };
|
package/package.json
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@md-plugins/shared",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
4
|
"description": "Shared functions and utilities for md-plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
7
7
|
"quasarframework",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"utils",
|
|
9
|
+
"vue"
|
|
10
10
|
],
|
|
11
11
|
"homepage": "https://github.com/md-plugins",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/md-plugins/md-plugins/issues"
|
|
14
14
|
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "hawkeye64 <galbraith64@gmail.com>",
|
|
15
17
|
"repository": {
|
|
16
18
|
"type": "git",
|
|
17
19
|
"url": "git+https://github.com/md-plugins/md-plugins.git"
|
|
18
20
|
},
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
+
"files": [
|
|
22
|
+
"./dist"
|
|
23
|
+
],
|
|
21
24
|
"type": "module",
|
|
25
|
+
"module": "./dist/index.mjs",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
22
27
|
"exports": {
|
|
23
28
|
".": {
|
|
24
29
|
"import": {
|
|
@@ -27,23 +32,16 @@
|
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
},
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
"files": [
|
|
33
|
-
"./dist"
|
|
34
|
-
],
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"markdown-it": "^14.1.0"
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/markdown-it": "^14.1.2"
|
|
39
|
+
"@types/markdown-it": "^14.1.2",
|
|
40
|
+
"markdown-it": "^14.1.1"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
42
43
|
"markdown-it": "^14.1.0"
|
|
43
44
|
},
|
|
44
|
-
"publishConfig": {
|
|
45
|
-
"access": "public"
|
|
46
|
-
},
|
|
47
45
|
"scripts": {
|
|
48
46
|
"build": "unbuild",
|
|
49
47
|
"clean": "rm -rf dist/ node_modules/",
|