aboutsummaryrefslogtreecommitdiff
path: root/.ai/scripts/tests/test-lint-org.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-11 14:25:55 -0500
committerCraig Jennings <c@cjennings.net>2026-06-11 14:25:55 -0500
commit8d790f371e54a8cc3e79a5ce72cd4dd5b3fa4513 (patch)
treeff6c1a496c4e7727bd823979a582dc21ef25b811 /.ai/scripts/tests/test-lint-org.el
parentbdc9a5d6e1320032770f54c747c210e4f465c399 (diff)
downloadrulesets-8d790f371e54a8cc3e79a5ce72cd4dd5b3fa4513.tar.gz
rulesets-8d790f371e54a8cc3e79a5ce72cd4dd5b3fa4513.zip
feat(org): table standard as a rule, reflow helper, and lint check
Wide org tables overflow the page in exported PDF/docx, and hand-wrapping a cell into continuation rows is tedious and error-prone. The standard existed only as a work-project convention with nothing enforcing it. claude-rules/org-tables.md carries the generalized standard: 120-column budget measured at render width (a link counts as its visible label and is never split), over-budget cells wrap onto continuation rows, and a rule sits under the header and every logical row. wrap-org-table.el reflows a table to that shape mechanically. Columns shrink from natural width toward a floor of their widest atomic token, cells wrap link-safe, and rule-delimited continuation groups merge back into their logical row before re-wrapping, which makes the reflow idempotent. A table whose floors still exceed the budget reflows best-effort and stays flagged for restructuring. lint-org.el gains an org-table-standard judgment check: width overruns and missing rules surface during the sweep with a pointer to the helper. Conformant wrapped tables don't false-flag, since the check reuses the helper's continuation-group reading. The check is judgment-only by design: reflowing is a visible layout change the sweep shouldn't make silently.
Diffstat (limited to '.ai/scripts/tests/test-lint-org.el')
-rw-r--r--.ai/scripts/tests/test-lint-org.el42
1 files changed, 42 insertions, 0 deletions
diff --git a/.ai/scripts/tests/test-lint-org.el b/.ai/scripts/tests/test-lint-org.el
index 60deb8c..d4b3ba0 100644
--- a/.ai/scripts/tests/test-lint-org.el
+++ b/.ai/scripts/tests/test-lint-org.el
@@ -599,5 +599,47 @@ followups file on the next run."
(lo-test--drop-buffer file)
(when (file-exists-p file) (delete-file file)))))
+;;; ---------------------------------------------------------------------------
+;;; org-table-standard check (width budget + rules between rows)
+
+(ert-deftest lo-table-over-budget-emits-judgment ()
+ "A table line rendering wider than 120 surfaces as an org-table-standard judgment."
+ (let* ((wide (make-string 130 ?x))
+ (run (lo-test--run (format "* H\n\n| a |\n|---|\n| %s |\n|---|\n" wide)))
+ (judgments (lo-test--judgments (plist-get run :issues))))
+ (should (memq 'org-table-standard (lo-test--checkers judgments)))
+ (should (cl-some (lambda (i) (lo-test--has (plist-get i :msg) "120"))
+ judgments))))
+
+(ert-deftest lo-table-compliant-not-flagged ()
+ "A narrow table with rules under header and every row passes silently."
+ (let* ((run (lo-test--run "* H\n\n| a |\n|---|\n| ok |\n|---|\n"))
+ (judgments (lo-test--judgments (plist-get run :issues))))
+ (should-not (memq 'org-table-standard (lo-test--checkers judgments)))))
+
+(ert-deftest lo-table-missing-interrow-rules-emits-judgment ()
+ "Data rows without a rule between them violate the standard."
+ (let* ((run (lo-test--run "* H\n\n| a | b |\n|---+---|\n| 1 | 2 |\n| 3 | 4 |\n"))
+ (judgments (lo-test--judgments (plist-get run :issues))))
+ (should (memq 'org-table-standard (lo-test--checkers judgments)))
+ (should (cl-some (lambda (i) (lo-test--has (plist-get i :msg) "rule"))
+ judgments))))
+
+(ert-deftest lo-table-wide-link-source-measures-render-width ()
+ "A long link target doesn't trip the budget — width is render-measured."
+ (let* ((target (concat "https://example.com/" (make-string 120 ?p)))
+ (run (lo-test--run
+ (format "* H\n\n| [[%s][ok]] |\n|---|\n| x |\n|---|\n" target)))
+ (judgments (lo-test--judgments (plist-get run :issues))))
+ (should-not (memq 'org-table-standard (lo-test--checkers judgments)))))
+
+(ert-deftest lo-table-conformant-wrapped-table-not-flagged ()
+ "Continuation rows inside a rule-delimited group are one logical row, not a
+missing-rules violation."
+ (let* ((run (lo-test--run
+ "* H\n\n| Name | Notes |\n|-------+-------------------|\n| alpha | wrapped text that |\n| | continues here |\n|-------+-------------------|\n"))
+ (judgments (lo-test--judgments (plist-get run :issues))))
+ (should-not (memq 'org-table-standard (lo-test--checkers judgments)))))
+
(provide 'test-lint-org)
;;; test-lint-org.el ends here