@velvetmonkey/flywheel-crank 0.7.2 → 0.7.3
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.js +24 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -179,7 +179,29 @@ function insertInSection(content, section, newContent, position, options) {
|
|
|
179
179
|
const lines = content.split("\n");
|
|
180
180
|
const formattedContent = newContent.trim();
|
|
181
181
|
if (position === "prepend") {
|
|
182
|
-
|
|
182
|
+
if (options?.preserveListNesting) {
|
|
183
|
+
let indent = "";
|
|
184
|
+
for (let i = section.contentStartLine; i <= section.endLine; i++) {
|
|
185
|
+
const line = lines[i];
|
|
186
|
+
const trimmed = line.trim();
|
|
187
|
+
if (trimmed === "")
|
|
188
|
+
continue;
|
|
189
|
+
const listMatch = line.match(/^(\s*)[-*+]\s|^(\s*)\d+\.\s|^(\s*)[-*+]\s*\[[ xX]\]/);
|
|
190
|
+
if (listMatch) {
|
|
191
|
+
indent = listMatch[1] || listMatch[2] || listMatch[3] || "";
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
if (indent) {
|
|
197
|
+
const indentedContent = formattedContent.split("\n").map((line) => indent + line).join("\n");
|
|
198
|
+
lines.splice(section.contentStartLine, 0, indentedContent);
|
|
199
|
+
} else {
|
|
200
|
+
lines.splice(section.contentStartLine, 0, formattedContent);
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
lines.splice(section.contentStartLine, 0, formattedContent);
|
|
204
|
+
}
|
|
183
205
|
} else {
|
|
184
206
|
let lastContentLineIdx = -1;
|
|
185
207
|
for (let i = section.endLine; i >= section.contentStartLine; i--) {
|
|
@@ -1248,7 +1270,7 @@ function registerMutationTools(server2, vaultPath2) {
|
|
|
1248
1270
|
format: z.enum(["plain", "bullet", "task", "numbered", "timestamp-bullet"]).default("plain").describe("How to format the content"),
|
|
1249
1271
|
commit: z.boolean().default(false).describe("If true, commit this change to git (creates undo point)"),
|
|
1250
1272
|
skipWikilinks: z.boolean().default(false).describe("If true, skip auto-wikilink application (wikilinks are applied by default)"),
|
|
1251
|
-
preserveListNesting: z.boolean().default(
|
|
1273
|
+
preserveListNesting: z.boolean().default(true).describe("Detect and preserve the indentation level of surrounding list items. Set false to disable."),
|
|
1252
1274
|
suggestOutgoingLinks: z.boolean().default(true).describe('Append suggested outgoing wikilinks based on content (e.g., "\u2192 [[AI]] [[Philosophy]]"). Set false to disable.')
|
|
1253
1275
|
},
|
|
1254
1276
|
async ({ path: notePath, section, content, position, format, commit, skipWikilinks, preserveListNesting, suggestOutgoingLinks }) => {
|