@hawkeyexl/manni 2.7.0 → 2.7.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 CHANGED
@@ -98,7 +98,7 @@ actually reads rather than hand-written:
98
98
  ```yaml
99
99
  repos:
100
100
  - repo: https://github.com/hawkeyexl/manni
101
- rev: v2.7.0
101
+ rev: v2.7.1
102
102
  hooks:
103
103
  - id: manni-meta
104
104
  ```
@@ -71,7 +71,7 @@ import {
71
71
  withValueAt,
72
72
  writeEncryptionKey,
73
73
  writeFileAtomic
74
- } from "./chunk-2672QGFM.js";
74
+ } from "./chunk-PRCLNOMG.js";
75
75
 
76
76
  // src/meta/core/reencrypt.ts
77
77
  import { extname } from "node:path";
@@ -229,6 +229,7 @@ __export(cite_exports, {
229
229
  isBoundLine: () => isBoundLine,
230
230
  isCiteRule: () => isCiteRule,
231
231
  isKeyedPin: () => isKeyedPin,
232
+ isTableRow: () => isTableRow,
232
233
  isUnitText: () => isUnitText,
233
234
  itemLine: () => itemLine,
234
235
  lineAt: () => lineAt,
@@ -245,6 +246,7 @@ __export(cite_exports, {
245
246
  misplacedMessageFor: () => misplacedMessageFor,
246
247
  movedUnit: () => movedUnit,
247
248
  noGit: () => noGit,
249
+ noUnitAt: () => noUnitAt,
248
250
  normalizeText: () => normalizeText,
249
251
  normalizeWhitespace: () => normalizeWhitespace,
250
252
  offsetOfLine: () => offsetOfLine,
@@ -849,6 +851,10 @@ var ATX_HEADING = /^[ \t]*#{1,6}([ \t]|$)/;
849
851
  var ASCIIDOC_TITLE = /^={1,6}[ \t]/;
850
852
  var ADORNMENT = /^[ \t]*([-=~^"'*+#_:<>])(?:[ \t]*\1){2,}[ \t]*$/;
851
853
  var TAG_LINE = /^[ \t]*<\/?[A-Za-z][^<>]*>[ \t]*$/;
854
+ var TABLE_ROW = /^[ \t]*\|/;
855
+ function isTableRow(line) {
856
+ return TABLE_ROW.test(line);
857
+ }
852
858
  function isBoundLine(line, format) {
853
859
  if (ADORNMENT.test(line)) return true;
854
860
  switch (format) {
@@ -1691,19 +1697,38 @@ function claimEnd(page, entry, lines, misplaced) {
1691
1697
  }
1692
1698
  return { status: "changed" };
1693
1699
  }
1694
- function unitAt(page, line, lines) {
1695
- if (line < page.bodyLine || line > lines.length) return void 0;
1696
- if ((lines[line - 1] ?? "").trim() === "") return void 0;
1700
+ function rowsAt(line, lines, recorded) {
1701
+ const width = recorded === void 0 ? 1 : Math.max(1, recorded.end - recorded.start + 1);
1702
+ const end = line + width - 1;
1703
+ if (end > lines.length) return "table-short";
1704
+ for (let n = line; n <= end; n++) {
1705
+ if (!isTableRow(lines[n - 1] ?? "")) return "table-short";
1706
+ }
1707
+ return { lines: { start: line, end }, kind: "paragraph", text: lines.slice(line - 1, end) };
1708
+ }
1709
+ function unitOrWhy(page, line, lines, recorded) {
1710
+ if (line < page.bodyLine || line > lines.length) return "outside";
1711
+ const own = lines[line - 1] ?? "";
1712
+ if (own.trim() === "") return "blank";
1697
1713
  const block = fenceSpanAt(page.content, line, page.format);
1698
1714
  if (block !== void 0) {
1699
1715
  return { lines: block, kind: "block", text: lines.slice(block.start - 1, block.end) };
1700
1716
  }
1701
- if (insideFence(page.content, page.bodyOffset, line, page.format)) return void 0;
1717
+ if (insideFence(page.content, page.bodyOffset, line, page.format)) return "fenced";
1718
+ if (isTableRow(own)) return rowsAt(line, lines, recorded);
1702
1719
  const paragraph = paragraphAfter(page.content, offsetOfLine(page.content, line));
1703
- if (paragraph === void 0 || paragraph.line !== line) return void 0;
1720
+ if (paragraph === void 0 || paragraph.line !== line) return "not-a-paragraph";
1704
1721
  const span = { start: line, end: lineAt(page.content, paragraph.end) };
1705
1722
  return { lines: span, kind: "paragraph", text: lines.slice(span.start - 1, span.end) };
1706
1723
  }
1724
+ function unitAt(page, line, lines, recorded) {
1725
+ const found = unitOrWhy(page, line, lines, recorded);
1726
+ return typeof found === "string" ? void 0 : found;
1727
+ }
1728
+ function noUnitAt(page, line, lines, recorded) {
1729
+ const found = unitOrWhy(page, line, lines, recorded);
1730
+ return typeof found === "string" ? found : void 0;
1731
+ }
1707
1732
  function markerUnit(page, entry, lines) {
1708
1733
  const { marker, citation } = entry;
1709
1734
  if (marker === void 0) return void 0;
@@ -4078,6 +4103,20 @@ async function runRemove(opts) {
4078
4103
 
4079
4104
  // src/cite/commands/update.ts
4080
4105
  import { resolve as resolve6 } from "node:path";
4106
+ function sayNoUnit(reason) {
4107
+ switch (reason) {
4108
+ case "outside":
4109
+ return "the line is outside the page body";
4110
+ case "blank":
4111
+ return "the line is blank";
4112
+ case "fenced":
4113
+ return "the line sits inside a fenced block";
4114
+ case "not-a-paragraph":
4115
+ return "the line does not start a paragraph";
4116
+ case "table-short":
4117
+ return "the table no longer holds every row the claim covers";
4118
+ }
4119
+ }
4081
4120
  function settles(plan) {
4082
4121
  switch (plan.kind) {
4083
4122
  case "claim-moved":
@@ -4537,10 +4576,9 @@ async function runUpdate(opts) {
4537
4576
  }
4538
4577
  if (!accept) return out;
4539
4578
  if (claim !== null && claim.status === "changed" && entry !== void 0 && result.anchor !== "marker") {
4540
- const unit = (() => {
4541
- const at2 = claimLine(claim);
4542
- return at2 === void 0 ? void 0 : unitAt(page, at2, lines);
4543
- })();
4579
+ const held = claim.fileLines === void 0 ? void 0 : parseLines(claim.fileLines);
4580
+ const at2 = held?.start;
4581
+ const unit = at2 === void 0 ? void 0 : unitAt(page, at2, lines, held);
4544
4582
  const wantsBlock = entry.citation.quote === true;
4545
4583
  const pin = unit === void 0 ? void 0 : pinOfLines(lines, unit.lines);
4546
4584
  const wide = unit === void 0 ? void 0 : tooWide(unit.lines);
@@ -4549,7 +4587,15 @@ async function runUpdate(opts) {
4549
4587
  rule: "claim-changed",
4550
4588
  why: `Not re-pinned: the ${unit.kind} ${wide}.`
4551
4589
  });
4552
- } else if (unit !== void 0 && pin !== void 0 && (!wantsBlock || unit.kind === "block")) {
4590
+ } else if (unit === void 0) {
4591
+ const why = at2 === void 0 ? void 0 : noUnitAt(page, at2, lines, held);
4592
+ if (why !== void 0) {
4593
+ declined.set(result.origin.index, {
4594
+ rule: "claim-changed",
4595
+ why: `Not re-pinned: ${sayNoUnit(why)}.`
4596
+ });
4597
+ }
4598
+ } else if (pin !== void 0 && (!wantsBlock || unit.kind === "block")) {
4553
4599
  const replaced = replacementAt(claim, unit.text, page.format);
4554
4600
  if (replaced !== void 0 && only === void 0) {
4555
4601
  out.push({
@@ -5876,4 +5922,4 @@ export {
5876
5922
  runKeyRotate,
5877
5923
  runKeySet
5878
5924
  };
5879
- //# sourceMappingURL=chunk-ELRE54LH.js.map
5925
+ //# sourceMappingURL=chunk-3WGFQKOP.js.map