@shikijs/transformers 3.14.0 → 3.15.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/dist/index.d.mts CHANGED
@@ -151,7 +151,7 @@ declare function transformerRemoveLineBreak(): ShikiTransformer$1;
151
151
  declare function transformerRemoveNotationEscape(): ShikiTransformer$1;
152
152
 
153
153
  interface TransformerRenderIndentGuidesOptions {
154
- indent?: number;
154
+ indent?: number | false;
155
155
  }
156
156
  /**
157
157
  * Render indentations as separate tokens.
package/dist/index.mjs CHANGED
@@ -489,13 +489,11 @@ function transformerRenderIndentGuides(options = {}) {
489
489
  return {
490
490
  name: "@shikijs/transformers:render-indent-guides",
491
491
  code(hast) {
492
- let { indent = 2 } = options;
493
- const match = this.options.meta?.__raw?.match(/\{indent:(\d+|false)\}/);
494
- if (match) {
495
- if (match[1] === "false") {
496
- return hast;
497
- }
498
- indent = Number(match[1]);
492
+ const indent = Number(
493
+ this.options.meta?.indent ?? this.options.meta?.__raw?.match(/\{indent:(\d+|false)\}/)?.[1] ?? options.indent ?? 2
494
+ );
495
+ if (Number.isNaN(indent) || indent <= 0) {
496
+ return hast;
499
497
  }
500
498
  const indentRegex = new RegExp(` {${indent}}| {0,${indent - 1}} | {1,}$`, "g");
501
499
  const emptyLines = [];
@@ -512,9 +510,9 @@ function transformerRenderIndentGuides(options = {}) {
512
510
  const text = first.children[0];
513
511
  const blanks = text.value.split(/[^ \t]/, 1)[0];
514
512
  const ranges = [];
515
- for (const match2 of blanks.matchAll(indentRegex)) {
516
- const start = match2.index;
517
- const end = start + match2[0].length;
513
+ for (const match of blanks.matchAll(indentRegex)) {
514
+ const start = match.index;
515
+ const end = start + match[0].length;
518
516
  ranges.push([start, end]);
519
517
  }
520
518
  for (const [line2, level2] of emptyLines) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shikijs/transformers",
3
3
  "type": "module",
4
- "version": "3.14.0",
4
+ "version": "3.15.0",
5
5
  "description": "Collective of common transformers transformers for Shiki",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -27,8 +27,8 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "@shikijs/core": "3.14.0",
31
- "@shikijs/types": "3.14.0"
30
+ "@shikijs/core": "3.15.0",
31
+ "@shikijs/types": "3.15.0"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "unbuild",