vuepress-plugin-md-power 1.0.0-rc.159 → 1.0.0-rc.160

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.
@@ -143,4 +143,45 @@ function onCopy(type: 'html' | 'md') {
143
143
  .vp-table .table-content .max-content table {
144
144
  width: max-content;
145
145
  }
146
+
147
+ /* ----- Highlight --------- */
148
+ .vp-table table th.tip,
149
+ .vp-table table td.tip,
150
+ .vp-table table th.note,
151
+ .vp-table table td.note {
152
+ color: var(--vp-c-tip-1);
153
+ background-color: var(--vp-c-tip-soft);
154
+ }
155
+
156
+ .vp-table table th.info,
157
+ .vp-table table td.info {
158
+ color: var(--vp-c-default-1);
159
+ background-color: var(--vp-c-default-soft);
160
+ }
161
+
162
+ .vp-table table th.warning,
163
+ .vp-table table td.warning {
164
+ color: var(--vp-c-warning-1);
165
+ background-color: var(--vp-c-warning-soft);
166
+ }
167
+
168
+ .vp-table table th.danger,
169
+ .vp-table table td.danger,
170
+ .vp-table table th.caution,
171
+ .vp-table table td.caution {
172
+ color: var(--vp-c-danger-1);
173
+ background-color: var(--vp-c-danger-soft);
174
+ }
175
+
176
+ .vp-table table th.success,
177
+ .vp-table table td.success {
178
+ color: var(--vp-c-success-1);
179
+ background-color: var(--vp-c-success-soft);
180
+ }
181
+
182
+ .vp-table table th.important,
183
+ .vp-table table td.important {
184
+ color: var(--vp-c-important-1);
185
+ background-color: var(--vp-c-important-soft);
186
+ }
146
187
  </style>
package/lib/node/index.js CHANGED
@@ -2438,23 +2438,78 @@ function stepsPlugin(md) {
2438
2438
  //#region src/node/container/table.ts
2439
2439
  /**
2440
2440
  * 在不破坏表格语法的前提下,通过容器语法将表格包裹起来,为表格提供增强功能
2441
+ *
2442
+ * @example
2443
+ * ```md
2444
+ * ::: table title="表格标题" max-content copy align="center" hl-rows="warning:1,2,3;error:4,5,6" hl-cols="warning:1;error:2,3" hl-cells="warning:(1,2)(2,3);"
2445
+ *
2446
+ * | xx | xx | xx |
2447
+ * | -- | -- | -- |
2448
+ * | xx | xx | xx |
2449
+ * :::
2450
+ * ```
2441
2451
  */
2442
2452
  function tablePlugin(md, options = {}) {
2443
- createContainerSyntaxPlugin(md, "table", (tokens, index, _, env) => {
2444
- const meta = {
2453
+ createContainerSyntaxPlugin(md, "table", (tokens, index, opt, env) => {
2454
+ const { hlCols = "", hlRows = "", hlCells = "",...meta } = tokens[index].meta;
2455
+ const props = {
2445
2456
  copy: true,
2446
2457
  maxContent: false,
2447
2458
  ...options,
2448
- ...tokens[index].meta
2459
+ ...meta
2449
2460
  };
2450
2461
  const content = tokens[index].content;
2451
- if (meta.copy) {
2452
- meta.copy = meta.copy === true ? "all" : meta.copy;
2453
- if (meta.copy === "all" || meta.copy === "md") meta.markdown = encodeData(content.trim());
2462
+ if (props.copy) {
2463
+ props.copy = props.copy === true ? "all" : props.copy;
2464
+ if (props.copy === "all" || props.copy === "md") props.markdown = encodeData(content.trim());
2465
+ }
2466
+ if (!hlCols && !hlRows && !hlCells) return `<VPTable ${stringifyAttrs(props)}>${md.render(content, env)}</VPTable>`;
2467
+ const rows = parseHl(hlRows);
2468
+ const cols = parseHl(hlCols);
2469
+ const cells = parseHlCells(hlCells);
2470
+ const tableTokens = md.parse(content, env);
2471
+ let isTable = false;
2472
+ let colIndex = 0;
2473
+ let rowIndex = 0;
2474
+ for (const token of tableTokens) {
2475
+ if (token.type === "table_open") isTable = true;
2476
+ if (token.type === "table_close") isTable = false;
2477
+ if (!isTable) continue;
2478
+ if (token.type === "tr_open") {
2479
+ rowIndex++;
2480
+ colIndex = 0;
2481
+ }
2482
+ if (token.type === "th_open" || token.type === "td_open") {
2483
+ colIndex++;
2484
+ const classes = cells[rowIndex]?.[colIndex] || rows[rowIndex] || cols[colIndex];
2485
+ if (classes) token.attrJoin("class", classes);
2486
+ }
2454
2487
  }
2455
- return `<VPTable ${stringifyAttrs(meta)}>${md.render(content, env)}</VPTable>`;
2488
+ return `<VPTable ${stringifyAttrs(props)}>${md.renderer.render(tableTokens, opt, env)}</VPTable>`;
2456
2489
  });
2457
2490
  }
2491
+ function parseHl(hl) {
2492
+ const res = {};
2493
+ if (!hl) return res;
2494
+ hl.split(";").forEach((item) => {
2495
+ const [key, value = "1"] = item.split(":");
2496
+ String(value).split(",").forEach((v) => res[v.trim()] = key.trim());
2497
+ });
2498
+ return res;
2499
+ }
2500
+ function parseHlCells(hl) {
2501
+ const res = {};
2502
+ if (!hl) return res;
2503
+ hl.split(";").forEach((item) => {
2504
+ const [key, value = ""] = item.split(":");
2505
+ value.trim().replace(/\s*\((\d+)\s*,\s*(\d+)\)\s*/g, (_, row, col) => {
2506
+ res[row] ??= {};
2507
+ res[row][col] = key.trim();
2508
+ return "";
2509
+ });
2510
+ });
2511
+ return res;
2512
+ }
2458
2513
 
2459
2514
  //#endregion
2460
2515
  //#region src/node/container/tabs.ts
@@ -3558,10 +3613,9 @@ function checkSupportType(type) {
3558
3613
  name = !installed.hlsjs ? "hls.js" : "";
3559
3614
  break;
3560
3615
  case "flv":
3561
- case "ts": {
3616
+ case "ts":
3562
3617
  name = !installed.mpegtsjs ? "mpegts.js" : "";
3563
3618
  break;
3564
- }
3565
3619
  case "mpd":
3566
3620
  case "dash":
3567
3621
  name = !installed.dashjs ? "dashjs" : "";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vuepress-plugin-md-power",
3
3
  "type": "module",
4
- "version": "1.0.0-rc.159",
4
+ "version": "1.0.0-rc.160",
5
5
  "description": "The Plugin for VuePress 2 - markdown power",
6
6
  "author": "pengzhanbo <volodymyr@foxmail.com>",
7
7
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "lib"
32
32
  ],
33
33
  "peerDependencies": {
34
- "artplayer": "^5.2.3",
34
+ "artplayer": "^5.2.5",
35
35
  "dashjs": "^5.0.3",
36
36
  "esbuild": "^0.25.8",
37
37
  "hls.js": "^1.6.7",
@@ -86,22 +86,22 @@
86
86
  "@mdit/plugin-tasklist": "^0.22.1",
87
87
  "@pengzhanbo/utils": "^2.1.0",
88
88
  "@vuepress/helper": "2.0.0-rc.112",
89
- "@vueuse/core": "^13.5.0",
89
+ "@vueuse/core": "^13.6.0",
90
90
  "chokidar": "4.0.3",
91
91
  "image-size": "^2.0.2",
92
92
  "local-pkg": "^1.1.1",
93
93
  "lru-cache": "^11.1.0",
94
94
  "markdown-it-container": "^4.0.0",
95
95
  "nanoid": "^5.1.5",
96
- "shiki": "^3.8.1",
96
+ "shiki": "^3.9.1",
97
97
  "tinyglobby": "0.2.13",
98
- "tm-grammars": "^1.24.0",
98
+ "tm-grammars": "^1.24.1",
99
99
  "tm-themes": "^1.10.7",
100
100
  "vue": "^3.5.18"
101
101
  },
102
102
  "devDependencies": {
103
103
  "@types/markdown-it": "^14.1.2",
104
- "artplayer": "^5.2.3",
104
+ "artplayer": "^5.2.5",
105
105
  "dashjs": "^5.0.3",
106
106
  "hls.js": "^1.6.7",
107
107
  "mpegts.js": "1.7.3"