@hawkeyexl/manni 2.3.0 → 2.3.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/README.md +1 -1
- package/dist/{chunk-ZWPVZUJI.js → chunk-CD3LHG26.js} +98 -15
- package/dist/chunk-CD3LHG26.js.map +1 -0
- package/dist/{chunk-7QVYG66K.js → chunk-ESOEJTV2.js} +2 -2
- package/dist/{chunk-UCLMW3RE.js → chunk-HUHERW7E.js} +2 -2
- package/dist/{chunk-UCLMW3RE.js.map → chunk-HUHERW7E.js.map} +1 -1
- package/dist/cli.js +5 -5
- package/dist/cli.js.map +1 -1
- package/dist/docmeta.js +2 -2
- package/dist/index.d.ts +7 -4
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-ZWPVZUJI.js.map +0 -1
- /package/dist/{chunk-7QVYG66K.js.map → chunk-ESOEJTV2.js.map} +0 -0
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
withValueAt,
|
|
70
70
|
writeEncryptionKey,
|
|
71
71
|
writeFileAtomic
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-HUHERW7E.js";
|
|
73
73
|
|
|
74
74
|
// src/meta/core/reencrypt.ts
|
|
75
75
|
import { extname } from "node:path";
|
|
@@ -644,6 +644,19 @@ function payloadOf(payload) {
|
|
|
644
644
|
if (ID.test(payload)) return { kind: "ref", id: payload };
|
|
645
645
|
return { kind: "bad", reason: "payload is not an id" };
|
|
646
646
|
}
|
|
647
|
+
function isCite(inner) {
|
|
648
|
+
return inner === "cite" || inner.startsWith("cite") && /\s/.test(inner.charAt(4));
|
|
649
|
+
}
|
|
650
|
+
function isMarkerLine(line, format) {
|
|
651
|
+
const text = line.trim();
|
|
652
|
+
return statementForms(format).some((form) => {
|
|
653
|
+
if (text.length < form.open.length + form.close.length) return false;
|
|
654
|
+
if (!text.startsWith(form.open)) return false;
|
|
655
|
+
const closeAt = text.indexOf(form.close, form.open.length);
|
|
656
|
+
if (closeAt !== text.length - form.close.length) return false;
|
|
657
|
+
return isCite(text.slice(form.open.length, closeAt).trim());
|
|
658
|
+
});
|
|
659
|
+
}
|
|
647
660
|
function parseStatements(body, format, from = { offset: 0, line: 1 }) {
|
|
648
661
|
const out = [];
|
|
649
662
|
const fileLine = (bodyOffset) => from.line + lineAt(body, bodyOffset) - 1;
|
|
@@ -663,9 +676,7 @@ function parseStatements(body, format, from = { offset: 0, line: 1 }) {
|
|
|
663
676
|
const end = closeAt + form.close.length;
|
|
664
677
|
cursor = end;
|
|
665
678
|
const inner = body.slice(at2 + form.open.length, closeAt).trim();
|
|
666
|
-
if (!(inner
|
|
667
|
-
continue;
|
|
668
|
-
}
|
|
679
|
+
if (!isCite(inner)) continue;
|
|
669
680
|
const payload = inner.slice(4).trim();
|
|
670
681
|
const unit = anchoredLines(body, end, format);
|
|
671
682
|
const anchorLine = unit === void 0 ? void 0 : from.line + unit.start - 1;
|
|
@@ -686,14 +697,15 @@ function detectEol(text) {
|
|
|
686
697
|
const nl = text.indexOf("\n");
|
|
687
698
|
return nl > 0 && text.charCodeAt(nl - 1) === 13 ? "\r\n" : "\n";
|
|
688
699
|
}
|
|
689
|
-
function paragraphAfter(content, offset) {
|
|
700
|
+
function paragraphAfter(content, offset, format) {
|
|
701
|
+
const marker = (text) => format !== void 0 && isMarkerLine(text, format);
|
|
690
702
|
let pos = offset;
|
|
691
703
|
const firstEnd = lineEnd(content, pos);
|
|
692
704
|
if (lineText(content, pos, firstEnd).trim() === "") pos = firstEnd + 1;
|
|
693
705
|
while (pos < content.length) {
|
|
694
706
|
const end = lineEnd(content, pos);
|
|
695
707
|
const text = lineText(content, pos, end);
|
|
696
|
-
if (text.trim() === "") {
|
|
708
|
+
if (text.trim() === "" || marker(text)) {
|
|
697
709
|
pos = end + 1;
|
|
698
710
|
continue;
|
|
699
711
|
}
|
|
@@ -704,7 +716,7 @@ function paragraphAfter(content, offset) {
|
|
|
704
716
|
while (cursor < content.length) {
|
|
705
717
|
const e = lineEnd(content, cursor);
|
|
706
718
|
const t = lineText(content, cursor, e);
|
|
707
|
-
if (t.trim() === "" || ANY_FENCE.test(t)) break;
|
|
719
|
+
if (t.trim() === "" || ANY_FENCE.test(t) || marker(t)) break;
|
|
708
720
|
last = e;
|
|
709
721
|
cursor = e + 1;
|
|
710
722
|
}
|
|
@@ -785,11 +797,12 @@ function formatStatement(format, payload) {
|
|
|
785
797
|
const pad = form.open.endsWith("(") ? "" : " ";
|
|
786
798
|
return `${form.open}${pad}cite ${payload.id}${pad}${form.close}`;
|
|
787
799
|
}
|
|
788
|
-
function
|
|
800
|
+
function nextTextLine(text, offset, format) {
|
|
789
801
|
let pos = nextLineStart(text, offset);
|
|
790
802
|
while (pos < text.length) {
|
|
791
803
|
const end = lineEnd(text, pos);
|
|
792
|
-
|
|
804
|
+
const line = lineText(text, pos, end);
|
|
805
|
+
if (line.trim() !== "" && !isMarkerLine(line, format)) return lineAt(text, pos);
|
|
793
806
|
pos = end + 1;
|
|
794
807
|
}
|
|
795
808
|
return void 0;
|
|
@@ -806,6 +819,27 @@ function insideFence(text, bodyOffset, line, format) {
|
|
|
806
819
|
(block) => line > block.line && line <= lineAt(text, block.end)
|
|
807
820
|
);
|
|
808
821
|
}
|
|
822
|
+
function unitHolding(text, line, format, body) {
|
|
823
|
+
const textOf = (n) => lineText(text, offsetOfLine(text, n), lineEnd(text, offsetOfLine(text, n)));
|
|
824
|
+
const own = textOf(line);
|
|
825
|
+
if (own.trim() === "" || isMarkerLine(own, format)) return void 0;
|
|
826
|
+
const block = fencedBlocks(text, body.offset, format).find(
|
|
827
|
+
(b) => line >= b.line && line <= lineAt(text, b.end)
|
|
828
|
+
);
|
|
829
|
+
if (block !== void 0) {
|
|
830
|
+
return { start: block.line, end: lineAt(text, block.end), kind: "block" };
|
|
831
|
+
}
|
|
832
|
+
if (ANY_FENCE.test(own)) return void 0;
|
|
833
|
+
let start = line;
|
|
834
|
+
while (start - 1 >= body.line) {
|
|
835
|
+
const above = textOf(start - 1);
|
|
836
|
+
if (above.trim() === "" || ANY_FENCE.test(above) || isMarkerLine(above, format)) break;
|
|
837
|
+
start--;
|
|
838
|
+
}
|
|
839
|
+
const paragraph = paragraphAfter(text, offsetOfLine(text, start), format);
|
|
840
|
+
if (paragraph?.line !== start) return void 0;
|
|
841
|
+
return { start, end: lineAt(text, paragraph.end), kind: "paragraph" };
|
|
842
|
+
}
|
|
809
843
|
function anchoredLines(text, after, format, quote = false) {
|
|
810
844
|
if (quote) {
|
|
811
845
|
const block = fencedBlockAfter(text, after, format);
|
|
@@ -816,11 +850,11 @@ function anchoredLines(text, after, format, quote = false) {
|
|
|
816
850
|
const line2 = lineAt(text, after);
|
|
817
851
|
return { start: line2, end: line2 };
|
|
818
852
|
}
|
|
819
|
-
const paragraph = paragraphAfter(text, after);
|
|
853
|
+
const paragraph = paragraphAfter(text, after, format);
|
|
820
854
|
if (paragraph !== void 0) {
|
|
821
855
|
return { start: paragraph.line, end: lineAt(text, paragraph.end) };
|
|
822
856
|
}
|
|
823
|
-
const line =
|
|
857
|
+
const line = nextTextLine(text, after, format);
|
|
824
858
|
return line === void 0 ? void 0 : fenceSpanAt(text, line, format);
|
|
825
859
|
}
|
|
826
860
|
function lineAt(content, offset) {
|
|
@@ -2754,6 +2788,35 @@ async function citedText(root, index, src, key) {
|
|
|
2754
2788
|
}
|
|
2755
2789
|
return sliceLines2(splitLines(source.text), range, range.path);
|
|
2756
2790
|
}
|
|
2791
|
+
function spellAt(lines) {
|
|
2792
|
+
return lines.start === lines.end ? `line ${String(lines.start)}` : `lines ${String(lines.start)}-${String(lines.end)}`;
|
|
2793
|
+
}
|
|
2794
|
+
function shiftedEntries(citations, insertLine, bodyLine, label) {
|
|
2795
|
+
const out = { frontmatter: [], manifest: /* @__PURE__ */ new Map() };
|
|
2796
|
+
for (const { citation, origin } of citations) {
|
|
2797
|
+
const spec = citation.claim?.lines;
|
|
2798
|
+
const recorded = spec === void 0 ? void 0 : parseLines(spec);
|
|
2799
|
+
if (recorded === void 0) continue;
|
|
2800
|
+
const file = toFileLines(recorded, bodyLine);
|
|
2801
|
+
if (file.start < insertLine) {
|
|
2802
|
+
if (file.end < insertLine) continue;
|
|
2803
|
+
const whose = citation.id === void 0 ? `the claim at ${spellAt(file)}` : `the claim of ${citation.id} (${spellAt(file)})`;
|
|
2804
|
+
throw new CiteError(
|
|
2805
|
+
`${label}:${String(insertLine)} is inside ${whose}. A marker there would change its pin.`
|
|
2806
|
+
);
|
|
2807
|
+
}
|
|
2808
|
+
const moved = lineSpec({ start: recorded.start + 1, end: recorded.end + 1 });
|
|
2809
|
+
if (origin.kind === "manifest") out.manifest.set(origin.index, moved);
|
|
2810
|
+
else out.frontmatter.push({ index: origin.index, lines: moved });
|
|
2811
|
+
}
|
|
2812
|
+
return out;
|
|
2813
|
+
}
|
|
2814
|
+
function withClaimLines(entry, lines) {
|
|
2815
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return entry;
|
|
2816
|
+
const claim = entry.claim;
|
|
2817
|
+
if (typeof claim !== "object" || claim === null || Array.isArray(claim)) return entry;
|
|
2818
|
+
return { ...entry, claim: { ...claim, lines } };
|
|
2819
|
+
}
|
|
2757
2820
|
async function runAdd(opts) {
|
|
2758
2821
|
const cwd = resolve4(opts.cwd ?? process.cwd());
|
|
2759
2822
|
const run3 = await resolveCiteRun({
|
|
@@ -2845,16 +2908,33 @@ async function runAdd(opts) {
|
|
|
2845
2908
|
let markerAt;
|
|
2846
2909
|
let claimSpan;
|
|
2847
2910
|
let claim;
|
|
2911
|
+
let shifted = { frontmatter: [], manifest: /* @__PURE__ */ new Map() };
|
|
2848
2912
|
if (marker && pageLines !== void 0) {
|
|
2913
|
+
const holding = unitHolding(content, pageLines.start, format, {
|
|
2914
|
+
offset: page.bodyOffset,
|
|
2915
|
+
line: page.bodyLine
|
|
2916
|
+
});
|
|
2917
|
+
if (holding === void 0) {
|
|
2918
|
+
throw new CiteError(`${at2} has no paragraph or block for a marker to anchor.`);
|
|
2919
|
+
}
|
|
2920
|
+
if (pageLines.end > holding.end) {
|
|
2921
|
+
throw new CiteError(
|
|
2922
|
+
`${at2} runs past the ${holding.kind} at ${spellAt(holding)}. A marker anchors one paragraph.`
|
|
2923
|
+
);
|
|
2924
|
+
}
|
|
2925
|
+
shifted = shiftedEntries(page.citations, holding.start, page.bodyLine, label);
|
|
2849
2926
|
const statement = formatStatement(format, { kind: "ref", id: opts.id ?? "" });
|
|
2850
|
-
const insertAt = offsetOfLine(content,
|
|
2927
|
+
const insertAt = offsetOfLine(content, holding.start);
|
|
2851
2928
|
body = insertStatementBefore(content, insertAt, statement);
|
|
2852
|
-
markerAt =
|
|
2929
|
+
markerAt = holding.start;
|
|
2853
2930
|
const unit = anchoredLines(body, insertAt + statement.length, format, quote);
|
|
2854
2931
|
const pin = unit === void 0 ? void 0 : pinOfLines(splitLines(body), unit);
|
|
2855
2932
|
if (unit === void 0 || pin === void 0) {
|
|
2856
2933
|
throw new CiteError(`${at2} has no paragraph or block for a marker to anchor.`);
|
|
2857
2934
|
}
|
|
2935
|
+
for (const { index, lines: moved } of shifted.frontmatter) {
|
|
2936
|
+
body = spliceEntryField(body, format, index, ["claim", "lines"], moved);
|
|
2937
|
+
}
|
|
2858
2938
|
claimSpan = unit;
|
|
2859
2939
|
claim = { integrity: pin };
|
|
2860
2940
|
} else if (pageLines !== void 0) {
|
|
@@ -2908,7 +2988,10 @@ async function runAdd(opts) {
|
|
|
2908
2988
|
`${label} carries no ${owner.join}: value, so its citations cannot be keyed in ${owner.file}.`
|
|
2909
2989
|
);
|
|
2910
2990
|
}
|
|
2911
|
-
const existing = (sidecar.citations ?? []).map((input) =>
|
|
2991
|
+
const existing = (sidecar.citations ?? []).map((input, index) => {
|
|
2992
|
+
const moved = shifted.manifest.get(index);
|
|
2993
|
+
return moved === void 0 ? input.entry : withClaimLines(input.entry, moved);
|
|
2994
|
+
});
|
|
2912
2995
|
const list = [...existing, entryObject(citation)];
|
|
2913
2996
|
const at3 = await manifests.write(owner, sidecar.entry, list, list.length - 1);
|
|
2914
2997
|
const [changed] = manifests.changed();
|
|
@@ -4107,4 +4190,4 @@ export {
|
|
|
4107
4190
|
runKeyRotate,
|
|
4108
4191
|
runKeySet
|
|
4109
4192
|
};
|
|
4110
|
-
//# sourceMappingURL=chunk-
|
|
4193
|
+
//# sourceMappingURL=chunk-CD3LHG26.js.map
|