@md-plugins/md-plugin-table 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 CHANGED
@@ -14,12 +14,12 @@ A **Markdown-It** plugin that customizes the rendering of tables in Markdown. Th
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-table
19
- # Or with Yarn:
20
- yarn add @md-plugins/md-plugin-table
21
- # Or with pnpm:
17
+ # with pnpm:
22
18
  pnpm add @md-plugins/md-plugin-table
19
+ # with Yarn:
20
+ yarn add @md-plugins/md-plugin-table
21
+ # with npm:
22
+ npm install @md-plugins/md-plugin-table
23
23
  ```
24
24
 
25
25
  ## Usage
@@ -151,6 +151,10 @@ Run the unit tests to ensure the plugin behaves as expected:
151
151
  pnpm test
152
152
  ```
153
153
 
154
+ ## Documentation
155
+
156
+ In case this README falls out of date, please refer to the [documentation](https://md-plugins.netlify.app/md-plugins/table/overview) for the latest information.
157
+
154
158
  ## License
155
159
 
156
160
  This project is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.
package/dist/index.d.mts CHANGED
@@ -41,4 +41,5 @@ interface TablePluginOptions {
41
41
 
42
42
  declare const tablePlugin: PluginWithOptions<TablePluginOptions>;
43
43
 
44
- export { type TablePluginOptions, tablePlugin };
44
+ export { tablePlugin };
45
+ export type { TablePluginOptions };
package/dist/index.d.ts CHANGED
@@ -41,4 +41,5 @@ interface TablePluginOptions {
41
41
 
42
42
  declare const tablePlugin: PluginWithOptions<TablePluginOptions>;
43
43
 
44
- export { type TablePluginOptions, tablePlugin };
44
+ export { tablePlugin };
45
+ export type { TablePluginOptions };
package/dist/index.mjs CHANGED
@@ -1,28 +1,46 @@
1
- const tablePlugin = (md, {
2
- tableClass = "markdown-table",
3
- tableHeaderClass = "text-left",
4
- tableRowClass = "",
5
- tableCellClass = "",
6
- tableToken = "q-markup-table",
7
- tableAttributes = []
8
- } = {}) => {
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_TABLE_PLUGIN_OPTIONS = {
9
+ tableClass: "markdown-table",
10
+ tableHeaderClass: "text-left",
11
+ tableRowClass: "",
12
+ tableCellClass: "",
13
+ tableToken: "q-markup-table",
14
+ tableAttributes: []
15
+ };
16
+ const tablePlugin = (md, options) => {
17
+ const {
18
+ tableClass = DEFAULT_TABLE_PLUGIN_OPTIONS.tableClass,
19
+ tableHeaderClass = DEFAULT_TABLE_PLUGIN_OPTIONS.tableHeaderClass,
20
+ tableRowClass = DEFAULT_TABLE_PLUGIN_OPTIONS.tableRowClass,
21
+ tableCellClass = DEFAULT_TABLE_PLUGIN_OPTIONS.tableCellClass,
22
+ tableToken = DEFAULT_TABLE_PLUGIN_OPTIONS.tableToken,
23
+ tableAttributes = DEFAULT_TABLE_PLUGIN_OPTIONS.tableAttributes
24
+ } = resolvePluginOptions(
25
+ options,
26
+ "tablePlugin",
27
+ DEFAULT_TABLE_PLUGIN_OPTIONS
28
+ );
9
29
  const render = md.renderer.render.bind(md.renderer);
10
- md.renderer.render = (tokens, options, env) => {
30
+ md.renderer.render = (tokens, options2, env) => {
11
31
  for (let i = 0; i < tokens.length; i++) {
12
32
  const token = tokens[i];
13
- if (!token) {
14
- continue;
15
- }
33
+ if (!token) continue;
16
34
  switch (token.type) {
17
35
  case "table_open":
18
- token.tag = tableToken;
19
- token.attrSet("class", tableClass);
20
- for (const [attrName, attrValue] of tableAttributes) {
36
+ token.tag = tableToken ?? DEFAULT_TABLE_PLUGIN_OPTIONS.tableToken;
37
+ token.attrSet("class", tableClass ?? DEFAULT_TABLE_PLUGIN_OPTIONS.tableClass);
38
+ for (const [attrName, attrValue] of tableAttributes ?? []) {
21
39
  token.attrSet(attrName, String(attrValue));
22
40
  }
23
41
  break;
24
42
  case "table_close":
25
- token.tag = tableToken;
43
+ token.tag = tableToken ?? DEFAULT_TABLE_PLUGIN_OPTIONS.tableToken;
26
44
  break;
27
45
  case "th_open":
28
46
  if (tableHeaderClass) {
@@ -41,7 +59,7 @@ const tablePlugin = (md, {
41
59
  break;
42
60
  }
43
61
  }
44
- return render(tokens, options, env);
62
+ return render(tokens, options2, env);
45
63
  };
46
64
  };
47
65
 
package/package.json CHANGED
@@ -1,24 +1,29 @@
1
1
  {
2
2
  "name": "@md-plugins/md-plugin-table",
3
- "version": "0.1.0-alpha.9",
3
+ "version": "0.1.0-beta.1",
4
4
  "description": "A markdown-it plugin for handling tables with custom tag and styles.",
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.1"
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/",