Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m1s
Read-side companion to doc-find-deep + reparent: ancestor-section chain (root-first) for a block id, nil if absent (distinct from () top-level path); block-depth is the path length. For breadcrumbs / scoping. New suite +13. Probe this pass found no bugs: clone/remap tree-wide, all block types have asMarkdown:. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
60 lines
1.7 KiB
Plaintext
60 lines
1.7 KiB
Plaintext
;; Extension — locate a block in the tree (ancestor section path).
|
|
|
|
(st-bootstrap-classes!)
|
|
(content/bootstrap!)
|
|
(content-bootstrap-section!)
|
|
|
|
;; doc: top-level "a", section "s" containing "x" and nested section "i"
|
|
;; containing "z".
|
|
(define
|
|
d
|
|
(doc-append
|
|
(doc-append (doc-empty "d") (mk-text "a" "A"))
|
|
(mk-section
|
|
"s"
|
|
(list (mk-text "x" "X") (mk-section "i" (list (mk-text "z" "Z")))))))
|
|
|
|
;; ── block-path ──
|
|
(content-test
|
|
"top-level block has empty path"
|
|
(content/block-path d "a")
|
|
(list))
|
|
(content-test "one-deep block path" (content/block-path d "x") (list "s"))
|
|
(content-test
|
|
"two-deep block path"
|
|
(content/block-path d "z")
|
|
(list "s" "i"))
|
|
(content-test "section's own path" (content/block-path d "i") (list "s"))
|
|
(content-test "missing id path nil" (content/block-path d "zzz") nil)
|
|
|
|
;; nil (absent) is distinct from () (present top-level)
|
|
(content-test
|
|
"absent vs top-level distinguishable"
|
|
(if (= (content/block-path d "a") nil) "nil" "list")
|
|
"list")
|
|
|
|
;; ── block-depth ──
|
|
(content-test "depth top-level" (content/block-depth d "a") 0)
|
|
(content-test "depth one" (content/block-depth d "x") 1)
|
|
(content-test "depth two" (content/block-depth d "z") 2)
|
|
(content-test "depth section" (content/block-depth d "i") 1)
|
|
(content-test "depth absent" (content/block-depth d "zzz") -1)
|
|
|
|
;; ── path tracks reparenting (composes with move.sx) ──
|
|
;; (rebuild expectation directly; move tested elsewhere)
|
|
(define
|
|
flat
|
|
(doc-append
|
|
(doc-append (doc-empty "d") (mk-section "sec" (list)))
|
|
(mk-text "p" "P")))
|
|
(content-test
|
|
"before: p at top level"
|
|
(content/block-depth flat "p")
|
|
0)
|
|
|
|
;; ── empty doc ──
|
|
(content-test
|
|
"empty doc path nil"
|
|
(content/block-path (doc-empty "e") "x")
|
|
nil)
|