@foldrun/core 24.4.0 → 24.4.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/dist/src/flow-patterns.js +11 -4
- package/package.json +1 -1
- package/src/flow-patterns.ts +9 -3
|
@@ -558,11 +558,18 @@ export function setFrontmatterScalar(raw, key, value) {
|
|
|
558
558
|
return ["---", line, "---", ...lines].join(eol);
|
|
559
559
|
const k = keyLine(lines, b.close, key);
|
|
560
560
|
if (k) {
|
|
561
|
-
const {
|
|
561
|
+
const { comment } = splitComment(k.rest);
|
|
562
|
+
// Every line indented deeper than the key is its value's — a block
|
|
563
|
+
// scalar, a plain scalar folded onto the next lines, blank lines inside
|
|
564
|
+
// either. Trailing blank lines are left where they are (Codex: a value
|
|
565
|
+
// after a blank line survived and joined the new one).
|
|
562
566
|
let end = k.index + 1;
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
567
|
+
for (let i = k.index + 1; i < b.close; i++) {
|
|
568
|
+
if (!/\S/.test(lines[i]))
|
|
569
|
+
continue;
|
|
570
|
+
if ((lines[i].match(/^\s*/)?.[0].length ?? 0) <= k.indent.length)
|
|
571
|
+
break;
|
|
572
|
+
end = i + 1;
|
|
566
573
|
}
|
|
567
574
|
lines.splice(k.index, end - k.index, `${k.indent}${line}${comment}`);
|
|
568
575
|
return lines.join(eol);
|
package/package.json
CHANGED
package/src/flow-patterns.ts
CHANGED
|
@@ -587,10 +587,16 @@ export function setFrontmatterScalar(raw: string, key: string, value: string): s
|
|
|
587
587
|
if (!b) return ["---", line, "---", ...lines].join(eol);
|
|
588
588
|
const k = keyLine(lines, b.close, key);
|
|
589
589
|
if (k) {
|
|
590
|
-
const {
|
|
590
|
+
const { comment } = splitComment(k.rest);
|
|
591
|
+
// Every line indented deeper than the key is its value's — a block
|
|
592
|
+
// scalar, a plain scalar folded onto the next lines, blank lines inside
|
|
593
|
+
// either. Trailing blank lines are left where they are (Codex: a value
|
|
594
|
+
// after a blank line survived and joined the new one).
|
|
591
595
|
let end = k.index + 1;
|
|
592
|
-
|
|
593
|
-
|
|
596
|
+
for (let i = k.index + 1; i < b.close; i++) {
|
|
597
|
+
if (!/\S/.test(lines[i])) continue;
|
|
598
|
+
if ((lines[i].match(/^\s*/)?.[0].length ?? 0) <= k.indent.length) break;
|
|
599
|
+
end = i + 1;
|
|
594
600
|
}
|
|
595
601
|
lines.splice(k.index, end - k.index, `${k.indent}${line}${comment}`);
|
|
596
602
|
return lines.join(eol);
|