You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(guide): reflow hard-wrapped markdown in human guide output - #132
guide <topic> human output now joins hard-wrapped paragraph and list-item lines into single lines before handing the markdown to termimad, so text fills the terminal width no matter how the guide source was wrapped.
The pass is conservative: anything it doesn't positively recognize as flowing prose keeps its authored line breaks. That covers fenced/indented code (including fences opened on a list-marker line), headings and setext underlines, thematic breaks, tables, block quotes, HTML blocks (<pre>/<script>/<style>/comments run to their closing delimiter, blank lines included), link reference definitions (compact and multi-line), empty list items, and explicit hard breaks (trailing \ or two spaces).
--output json / --output toon still return the raw markdown byte-for-byte.
docs/concepts.md ("Guides → Rendering and authoring") previously told authors to write one line per paragraph; it now describes the reflow and its edge cases.
The logic lives in the new cli-engine/src/guide/reflow.rs and is applied in render_guide_human.
Test plan
25 unit tests for the reflow rules, including idempotence and a regression case for each review finding (refined during review)
End-to-end Cli::run test: human output joins wrapped paragraphs and keeps code block breaks; json output stays verbatim
cargo fmt --all --check, cargo clippy --all-targets -- -D warnings, cargo doc, cargo test --all-targets, cargo test --doc, check-module-size.sh
Guide source that is wrapped at a fixed column used to keep its authored
line breaks, because the terminal renderer preserves every source newline.
Join the lines of each paragraph and list item before rendering so text
fills the reader's terminal regardless of how the source was wrapped.
Fenced and indented code, headings, rules, tables, block quotes, HTML
blocks, link reference definitions and explicit hard breaks are left
as authored. json/toon output still returns the raw markdown verbatim.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This PR adds Markdown preprocessing to human-readable guide output so hard-wrapped prose can fill the terminal width, while leaving JSON and TOON output unchanged.
Changes:
Join paragraph and list-item continuation lines before rendering with termimad.
Add unit and integration tests for reflow and raw-output preservation.
Update guide-authoring documentation to describe reflow behavior and exceptions.
File
Description
cli-engine/tests/foundation.rs
Tests human reflow, code-line preservation, and unchanged JSON output.
cli-engine/src/guide/reflow.rs
Implements Markdown reflow and focused unit tests.
cli-engine/src/guide.rs
Applies preprocessing to human guide rendering and updates rustdoc.
* HTML blocks (<pre>, <script>, <style>, comments, ...) now run to their
closing delimiter instead of the first blank line.
* Empty list items stay on their own line instead of being appended to
the previous item.
* A closing code fence may only be indented 3 columns past its opener.
* Link reference definitions may omit the space after the colon, may
carry a destination/title on following lines, and cannot interrupt a
paragraph.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…arkers
* A code fence opened on a list marker's line (`- ```sh`) is now a fence,
closed relative to the item's content column.
* Setext underlines may be one or two characters or carry trailing
whitespace, so the heading boundary survives.
* A tab after a list marker starts an item like a space does.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Unresolved list-container and fence-indentation handling can merge code or preformatted lines in human guide output.
No open issues 🎉
3 previously missed issues
In code that hasn't changed since last review
Preserve indented code immediately after list markers
cli-engine/src/guide/reflow.rs:101
A list item can begin directly with indented code, but this branch queues it as prose. For example, * echo first\n echo second\n echo third\n becomes * echo first echo second echo third\n, merging separate code lines before human rendering. Detect code indentation relative to the list item's content column, including the five-spaces-after-marker form, and preserve the code lines verbatim. Add a regression test that also checks ordinary wrapped list prose still joins.
Preserve HTML blocks opened within list items
cli-engine/src/guide/reflow.rs:101
HTML blocks opened after a list marker enter this branch as prose because raw-block detection examines the whole line. For example, * <pre>\n first\n\n second\n third\n </pre>\n becomes * <pre> first\n\n second third\n </pre>\n, removing preformatted line breaks. Recognize HTML block openers in the list item's content and preserve them through their closing delimiter, including internal blank lines. Add regression coverage for this form while keeping HTML-like text inside indented code verbatim.
Limit closing fence indentation relative to container
cli-engine/src/guide/reflow.rs:262
With a top-level opener indented three spaces, this limit becomes six, so a four-space fence-like code line is accepted as a closer. For example, ```\n ```\necho first\necho second\n ```\n has its two echo lines joined even though both are inside the original code block. Closing-fence indentation is limited to three spaces relative to the enclosing container, not three additional spaces beyond the opener. Track container indentation separately and add a regression test with an indented opener and a four-space fence-like line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
guide <topic>human output now joins hard-wrapped paragraph and list-item lines into single lines before handing the markdown to termimad, so text fills the terminal width no matter how the guide source was wrapped.<pre>/<script>/<style>/comments run to their closing delimiter, blank lines included), link reference definitions (compact and multi-line), empty list items, and explicit hard breaks (trailing\or two spaces).--output json/--output toonstill return the raw markdown byte-for-byte.docs/concepts.md("Guides → Rendering and authoring") previously told authors to write one line per paragraph; it now describes the reflow and its edge cases.The logic lives in the new
cli-engine/src/guide/reflow.rsand is applied inrender_guide_human.Test plan
Cli::runtest: human output joins wrapped paragraphs and keeps code block breaks; json output stays verbatimcargo fmt --all --check,cargo clippy --all-targets -- -D warnings,cargo doc,cargo test --all-targets,cargo test --doc,check-module-size.sh🤖 Generated with Claude Code