@mintlify/cli 4.0.1677 → 4.0.1678

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.
@@ -14051,7 +14051,7 @@ var SerializerState = class {
14051
14051
  this.nodePath.pop();
14052
14052
  }
14053
14053
  }
14054
- recordLiteralTextRange(path, start, end) {
14054
+ recordLiteralTextRange(path, start, end, pmStart = 0) {
14055
14055
  if (!this.sourceMap || this.inTable)
14056
14056
  return;
14057
14057
  this.sourceMap.push({
@@ -14059,8 +14059,8 @@ var SerializerState = class {
14059
14059
  start,
14060
14060
  end,
14061
14061
  kind: "text",
14062
- pmStart: 0,
14063
- pmEnd: end - start,
14062
+ pmStart,
14063
+ pmEnd: pmStart + end - start,
14064
14064
  offsetEncoding: "identity"
14065
14065
  });
14066
14066
  }
@@ -14922,7 +14922,16 @@ function renderSingleLineImgTag(attrs2) {
14922
14922
  const parts = Object.entries(attrs2).filter(([key, value]) => value !== null && value !== void 0 && !HIDDEN_NODE_ATTRS.has(key)).map(([key, value]) => serializeJsxAttribute(attrs2, key, value)).filter(Boolean);
14923
14923
  return parts.length > 0 ? `<img ${parts.join(" ")} />` : "<img />";
14924
14924
  }
14925
- function renderCodeBlock(state, node) {
14925
+ function recordCodeLines(state, textPath, content, start) {
14926
+ let output = start;
14927
+ let pmStart = 0;
14928
+ for (const line of content.split("\n")) {
14929
+ state.recordLiteralTextRange(textPath, output, output + line.length, pmStart);
14930
+ output += line.length + 1 + state.delim.length;
14931
+ pmStart += line.length + 1;
14932
+ }
14933
+ }
14934
+ function renderCodeBlock(state, node, textPath) {
14926
14935
  state.inCodeSection = true;
14927
14936
  let content = getTextContent(node);
14928
14937
  const lang = node.attrs.language || DEFAULT_CODE_BLOCK_LANGUAGE;
@@ -14982,6 +14991,10 @@ function renderCodeBlock(state, node) {
14982
14991
  state.write(fence + lang + metaString + "\n");
14983
14992
  const indentedContent = state.delim ? content.replace(/\n/g, "\n" + state.delim) : content;
14984
14993
  state.write(indentedContent);
14994
+ const hidesTrailingNewline = content.endsWith("\n");
14995
+ if (textPath && node.childCount === 1 && parsedAdd.length === 0 && parsedRemove.length === 0 && !hidesTrailingNewline) {
14996
+ recordCodeLines(state, textPath, content, state.length - indentedContent.length);
14997
+ }
14985
14998
  state.ensureNewLine();
14986
14999
  state.write(fence);
14987
15000
  state.closeBlock();
@@ -15079,7 +15092,7 @@ function renderCodeGroup(state, node, name) {
15079
15092
  for (let i = 0; i < node.childCount; i++) {
15080
15093
  const child = node.child(i);
15081
15094
  if (child.type.name === BLOCK_TYPES.codeBlock) {
15082
- renderCodeBlock(state, child);
15095
+ renderCodeBlock(state, child, [i, 0]);
15083
15096
  if (i < node.childCount - 1) {
15084
15097
  state.ensureNewLine();
15085
15098
  }
@@ -15656,7 +15669,7 @@ function renderNode(state, node, _parent, _index) {
15656
15669
  renderTable(state, node, boundRenderInline, renderNode);
15657
15670
  break;
15658
15671
  case BLOCK_TYPES.codeBlock:
15659
- renderCodeBlock(state, node);
15672
+ renderCodeBlock(state, node, [0]);
15660
15673
  break;
15661
15674
  case "image":
15662
15675
  case BLOCK_TYPES.image:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/cli",
3
- "version": "4.0.1677",
3
+ "version": "4.0.1678",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -82,7 +82,7 @@
82
82
  "keytar": "7.9.0"
83
83
  },
84
84
  "devDependencies": {
85
- "@mintlify/editor": "0.0.532",
85
+ "@mintlify/editor": "0.0.533",
86
86
  "@mintlify/ts-config": "2.0.2",
87
87
  "@tsconfig/recommended": "1.0.2",
88
88
  "@types/detect-port": "1.3.2",
@@ -101,5 +101,5 @@
101
101
  "vitest": "2.1.9",
102
102
  "vitest-mock-process": "1.0.4"
103
103
  },
104
- "gitHead": "99d46ff365b7dfa156c3c6f1c28ba1c1f0b629e8"
104
+ "gitHead": "64ecc388380eeb947450683a4545c692dca691ab"
105
105
  }