Skip to content

feat(surface-render): render single newlines as line breaks (breaks: true default) - #199

Merged
unforced merged 2 commits into
mainfrom
ag-unforced-dev
Jul 17, 2026
Merged

feat(surface-render): render single newlines as line breaks (breaks: true default)#199
unforced merged 2 commits into
mainfrom
ag-unforced-dev

Conversation

@unforced

Copy link
Copy Markdown
Contributor

Summary

Parachute renders markdown the way Obsidian/GitHub-comments do: a single \n inside a paragraph now renders as a visible line break, not collapsed to a space (strict CommonMark soft-break behavior). Enter=paragraph / Shift+Enter=newline only feels right if the newline actually shows. Markdown files stay clean — no trailing-two-spaces hacks needed.

  • Wires remark-breaks into MarkdownView's remark pipeline, positioned before remarkWikilinks — it only ever sees plain paragraph text this way, and can't re-split the wikilink plugin's styled inert-unresolved <span> text node (which mdast-util-find-and-replace, the mechanism both plugins share, treats generically by node type).
  • New breaks?: boolean prop on <MarkdownView>, default true. <NoteRenderer> forwards it straight through to the markdown branch (added to its Pick<MarkdownViewProps, …>).
  • remark-breaks joins remark-gfm as a required peer dependency (imported unconditionally, same idiom).
  • Fenced code blocks and inline code are unaffected — remark-breaks/mdast-util-find-and-replace only rewrites text mdast nodes, and code/inlineCode are distinct node types. Verified with a dedicated test.
  • Version 0.2.0 → 0.3.0 (behavior-change default = minor bump) + CHANGELOG entry. 0.x caret semantics mean notes-ui (pinned ^0.2.0) does not auto-resolve to this — checked, it's not affected until it deliberately bumps.
  • README: peer-dep install line + a new "Line breaks" section documenting the default/opt-out.

Where it landed

  • packages/surface-render/src/markdown/MarkdownView.tsx — the breaks prop + remark pipeline wiring
  • packages/surface-render/src/note/NoteRenderer.tsx — threads breaks through
  • packages/surface-render/package.json — version bump + remark-breaks peer/dev dep
  • packages/surface-render/CHANGELOG.md, README.md — docs
  • packages/surface-render/src/__tests__/MarkdownView.test.tsx — 8 new tests

Test plan

All gates run locally in packages/surface-render, literal counts:

  • bun run test69/69 passed (8 test files, including 8 new breaks tests: default <br>, paragraph-split preserved, breaks={false} strict-CommonMark collapse, trailing-two-spaces hard break, backslash hard break, fenced-code non-interference, inline-code non-interference, wikilink-adjacent text run)
  • bun run typecheck — clean (tsc --noEmit && tsc -p tsconfig.test.json)
  • bun run lint — clean (biome check ., 39 files)
  • bun run build — clean (tsc, version.ts regenerated to 0.3.0)

Not merged, not tagged/published — reviewer to dispatch next.

🤖 Generated with Claude Code

unforced added 2 commits July 16, 2026 22:22
…true default)

Parachute renders markdown the way Obsidian/GitHub-comments do — a single
internal \n renders as a visible line break, not collapsed to a space per
strict CommonMark. Enter=paragraph / Shift+Enter=newline only feels right if
the newline actually shows.

Wires remark-breaks into MarkdownView's remark pipeline (before
remarkWikilinks, so it only ever sees plain text and can't re-split the
wikilink plugin's styled inert-unresolved span). New `breaks` prop on
MarkdownView/NoteRenderer, default true, opt-out for strict-CommonMark
consumers. remark-breaks joins remark-gfm as a required peer dependency.

0.2.0 -> 0.3.0 (behavior-change default = minor bump; 0.x caret semantics
mean consumers pinned to ^0.2.0, e.g. notes-ui, do not auto-resolve — a
deliberate per-consumer opt-in).
…der matters only for literal newline inside wikilink syntax)
@unforced
unforced merged commit 306813f into main Jul 17, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant