@md-plugins/md-plugin-title 0.1.0-alpha.8 → 0.1.0-beta.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/README.md +9 -5
- package/dist/index.mjs +11 -1
- package/package.json +15 -17
package/README.md
CHANGED
|
@@ -14,12 +14,12 @@ A **Markdown-It** plugin that extracts the first `<h1>` title from Markdown cont
|
|
|
14
14
|
Install the plugin via your preferred package manager:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
#
|
|
18
|
-
npm install @md-plugins/md-plugin-title
|
|
19
|
-
# Or with Yarn:
|
|
20
|
-
yarn add @md-plugins/md-plugin-title
|
|
21
|
-
# Or with pnpm:
|
|
17
|
+
# with pnpm:
|
|
22
18
|
pnpm add @md-plugins/md-plugin-title
|
|
19
|
+
# with Yarn:
|
|
20
|
+
yarn add @md-plugins/md-plugin-title
|
|
21
|
+
# with npm:
|
|
22
|
+
npm install @md-plugins/md-plugin-title
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Usage
|
|
@@ -80,6 +80,10 @@ Run the tests to ensure the plugin behaves as expected:
|
|
|
80
80
|
pnpm test
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
## Documentation
|
|
84
|
+
|
|
85
|
+
In case this README falls out of date, please refer to the [documentation](https://md-plugins.netlify.app/md-plugins/title/overview) for the latest information.
|
|
86
|
+
|
|
83
87
|
## License
|
|
84
88
|
|
|
85
89
|
This project is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
const resolveTitleFromToken = (token, { shouldAllowHtml, shouldEscapeText }) => {
|
|
2
|
+
const children = token.children ?? [];
|
|
3
|
+
const titleTokenTypes = ["text", "emoji", "code_inline"];
|
|
4
|
+
const titleTokens = children.filter(
|
|
5
|
+
(item) => titleTokenTypes.includes(item.type) && // filter permalink symbol that generated by markdown-it-anchor
|
|
6
|
+
!item.meta?.isPermalinkSymbol
|
|
7
|
+
);
|
|
8
|
+
return titleTokens.reduce((result, item) => {
|
|
9
|
+
return `${result}${item.content}`;
|
|
10
|
+
}, "").trim();
|
|
11
|
+
};
|
|
2
12
|
|
|
3
13
|
const titlePlugin = (md) => {
|
|
4
14
|
const render = md.renderer.render.bind(md.renderer);
|
package/package.json
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@md-plugins/md-plugin-title",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
4
|
"description": "A markdown-it plugin for getting Title information.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
7
7
|
"quasarframework",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"types",
|
|
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,24 +32,17 @@
|
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
},
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
"files": [
|
|
33
|
-
"./dist"
|
|
34
|
-
],
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"markdown-it": "^14.1.0",
|
|
37
|
-
"@md-plugins/shared": "0.1.0-alpha.8"
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
|
-
"@types/markdown-it": "^14.1.2"
|
|
39
|
+
"@types/markdown-it": "^14.1.2",
|
|
40
|
+
"markdown-it": "^14.1.1",
|
|
41
|
+
"@md-plugins/shared": "0.1.0-beta.0"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"markdown-it": "^14.1.0"
|
|
44
45
|
},
|
|
45
|
-
"publishConfig": {
|
|
46
|
-
"access": "public"
|
|
47
|
-
},
|
|
48
46
|
"scripts": {
|
|
49
47
|
"build": "unbuild",
|
|
50
48
|
"clean": "rm -rf dist/ node_modules/",
|