fix: render multi-line front matter descriptions as one index line #1131
🦋 Changeset detected
Latest commit: e734f6aa5a0b70a84f98ae7b271e6b6e7fef8dc8
The changes in this PR will be included in the next version bump.
<details><summary>This PR includes changesets to release 1 package</summary>
| Name | Type |
| -------- | ----- |
| openwiki | Patch |
</details>
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Collapsing YAML block-scalar whitespace in usableString is the right fix: a | / > description must not split an index list item. The test with an injected - [Injected](...) line and a folded > description covers both scalar styles, and treating an all-whitespace value as missing keeps the missing-description report unchanged.
One residual: the extra line is no longer a separate list item, but it is still Markdown on the same index line. The new assertion expects - [Literal](literal.md) - First line. - [Injected](elsewhere.md), so [Injected](elsewhere.md) will still render as a link in the index. If the goal was only "don't split the entry," this is fine. If the goal was also to stop front matter from injecting index links, the collapsed string still needs escaping (backslashes on [ ], or stripping list markers).
The u flag on \s+ is appropriate for Unicode whitespace in titles and descriptions.
mangeshraut712
Yashwanth-Kumar-Kotla
Description
Fixes #1130
A front matter
description(ortitle) written as a YAML block scalar contains newlines. The index generator put it into a list item unchanged, so the entry split and extra lines showed up as separate list content. This collapses whitespace to single spaces before the value is used in an index.Changes Made
usableStringinsrc/okf/index-sync.tsnow collapses runs of whitespace (including newlines) to one space and trims the result. A value that is empty after that is still treated as missing, so the missing-description report is unchanged.test/agent/index-middleware.test.tsthat indexes a|page and a>page and checks each renders as one list line.Testing
npx vitest run test/agent/index-middleware.test.ts: 36 passed.pnpm run format:check,pnpm run lint:checkandpnpm testall pass (241 test files passed, 2 skipped).