@md-plugins/md-plugin-link 0.1.0-alpha.9 → 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 CHANGED
@@ -14,12 +14,12 @@ A **Markdown-It** plugin that customizes the rendering of links in Markdown cont
14
14
  Install the plugin via your preferred package manager:
15
15
 
16
16
  ```bash
17
- # With npm:
18
- npm install @md-plugins/md-plugin-link
19
- # Or with Yarn:
20
- yarn add @md-plugins/md-plugin-link
21
- # Or with pnpm:
17
+ # with pnpm:
22
18
  pnpm add @md-plugins/md-plugin-link
19
+ # with Yarn:
20
+ yarn add @md-plugins/md-plugin-link
21
+ # with npm:
22
+ npm install @md-plugins/md-plugin-link
23
23
  ```
24
24
 
25
25
  ## Usage
@@ -85,6 +85,10 @@ Run the tests to ensure the plugin behaves as expected:
85
85
  pnpm test
86
86
  ```
87
87
 
88
+ ## Documentation
89
+
90
+ In case this README falls out of date, please refer to the [documentation](https://md-plugins.netlify.app/md-plugins/link/overview) for the latest information.
91
+
88
92
  ## License
89
93
 
90
94
  This project is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.
package/dist/index.d.mts CHANGED
@@ -30,4 +30,5 @@ declare module '@md-plugins/shared' {
30
30
 
31
31
  declare const linkPlugin: PluginWithOptions<LinkPluginOptions>;
32
32
 
33
- export { type LinkPluginOptions, linkPlugin };
33
+ export { linkPlugin };
34
+ export type { LinkPluginOptions };
package/dist/index.d.ts CHANGED
@@ -30,4 +30,5 @@ declare module '@md-plugins/shared' {
30
30
 
31
31
  declare const linkPlugin: PluginWithOptions<LinkPluginOptions>;
32
32
 
33
- export { type LinkPluginOptions, linkPlugin };
33
+ export { linkPlugin };
34
+ export type { LinkPluginOptions };
package/dist/index.mjs CHANGED
@@ -1,16 +1,33 @@
1
- const linkPlugin = (md, {
2
- linkTag = "MarkdownLink",
3
- linkToKeyword = "to",
4
- pageScript = 'import MarkdownLink from "src/.q-press/components/MarkdownLink.vue"'
5
- } = {}) => {
6
- md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
1
+ function resolvePluginOptions(options, key, defaults) {
2
+ if (options && typeof options === "object" && key in options) {
3
+ return { ...defaults, ...options[key] };
4
+ }
5
+ return { ...defaults, ...options };
6
+ }
7
+
8
+ const DEFAULT_LINK_PLUGIN_OPTIONS = {
9
+ linkTag: "MarkdownLink",
10
+ linkToKeyword: "to",
11
+ pageScript: 'import MarkdownLink from "src/.q-press/components/MarkdownLink.vue"'
12
+ };
13
+ const linkPlugin = (md, options) => {
14
+ const {
15
+ linkTag = "MarkdownLink",
16
+ linkToKeyword = "to",
17
+ pageScript
18
+ } = resolvePluginOptions(
19
+ options,
20
+ "linkPlugin",
21
+ DEFAULT_LINK_PLUGIN_OPTIONS
22
+ );
23
+ md.renderer.rules.link_open = (tokens, idx, options2, env, self) => {
7
24
  const token = tokens[idx];
8
25
  if (!token) {
9
26
  return "";
10
27
  }
11
28
  const hrefIndex = token.attrIndex("href");
12
29
  if (hrefIndex < 0 || !token.attrs) {
13
- return self.renderToken(tokens, idx, options);
30
+ return self.renderToken(tokens, idx, options2);
14
31
  }
15
32
  const link = token.attrs[hrefIndex];
16
33
  const url = link[1];
@@ -21,9 +38,9 @@ const linkPlugin = (md, {
21
38
  env.pageScripts = env.pageScripts || /* @__PURE__ */ new Set();
22
39
  env.pageScripts.add(pageScript);
23
40
  }
24
- return self.renderToken(tokens, idx, options);
41
+ return self.renderToken(tokens, idx, options2);
25
42
  };
26
- md.renderer.rules.link_close = (tokens, idx, options, env, self) => {
43
+ md.renderer.rules.link_close = (tokens, idx, options2, env, self) => {
27
44
  const token = tokens[idx];
28
45
  if (!token) {
29
46
  return "";
@@ -36,7 +53,7 @@ const linkPlugin = (md, {
36
53
  if (openingToken && openingToken.tag) {
37
54
  token.tag = openingToken.tag;
38
55
  }
39
- return self.renderToken(tokens, idx, options);
56
+ return self.renderToken(tokens, idx, options2);
40
57
  };
41
58
  };
42
59
 
package/package.json CHANGED
@@ -1,24 +1,29 @@
1
1
  {
2
2
  "name": "@md-plugins/md-plugin-link",
3
- "version": "0.1.0-alpha.9",
3
+ "version": "0.1.0-beta.0",
4
4
  "description": "A markdown-it plugin for handling links.",
5
5
  "keywords": [
6
6
  "markdown-it",
7
7
  "quasarframework",
8
- "vue",
9
- "types"
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
- "license": "MIT",
20
- "author": "hawkeye64 <galbraith64@gmail.com>",
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
- "module": "./dist/index.mjs",
31
- "types": "./dist/index.d.ts",
32
- "files": [
33
- "./dist"
34
- ],
35
- "dependencies": {
36
- "markdown-it": "^14.1.0",
37
- "@md-plugins/shared": "0.1.0-alpha.9"
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/",