Skip to content

feat: details/summary collapsible blocks, line numbers, thematicBreak width#12

Open
skyth-engine wants to merge 1 commit into
mainfrom
feat/details-line-numbers-v2
Open

feat: details/summary collapsible blocks, line numbers, thematicBreak width#12
skyth-engine wants to merge 1 commit into
mainfrom
feat/details-line-numbers-v2

Conversation

@skyth-engine

Copy link
Copy Markdown
Collaborator

Summary

Re-applies the feature set from #1 against the updated main, plus fixes Jules’ broken open.ts.

Bug fix: open.ts (Jules’ mess)

Two PRs (#10, #11) conflicted and left the file broken:

  • async function commandExists was never closed — wrapped the new cached version inside an unclosed body
  • commandExistsCache was referenced but never declared
  • openWithTerminalEditor was missing terminal assignment and guard, with duplicate const args blocks

Fix: rewrite both functions cleanly, keeping the cache (#10), injection-safe args and xfce4 --command fix (#11).

Features

<details>/<summary> collapsible blocks
New remarkMergeBlockHtml plugin merges block-level <details>...</details> sequences into htmlBlock nodes. remarkMergeInlineHtml only handled inline HTML — block-level <details> was landing as raw html nodes and rendering as muted text. New DetailsBlock component handles both paths.

Line numbers + configurable maxHeight via codeOptions

interface CodeOptions {
  lineNumbers?: boolean | { minLines?: number };
  maxHeight?: number;
}

Line numbers auto-show on blocks ≥ minLines (default 6). Gutter width scales with Math.floor(log10(lineCount) + 1). maxHeight replaces the hardcoded MAX_CODE_BLOCK_HEIGHT = 18 constant via the updated getBlockMetrics signature. Both props threaded through all recursive call sites.

thematicBreak uses terminal width
.repeat(40)process.stdout.columns - 2`.

Test

Pre-existing refractor and image-dimensions missing @types errors only. All new code typechecks clean.

@skyth-engine skyth-engine force-pushed the feat/details-line-numbers-v2 branch from 92ec047 to bea3946 Compare June 12, 2026 14:18
… width

- Add remarkMergeBlockHtml plugin: merges block-level <details>...</details>
  sequences (remark type-6 HTML nodes) into htmlBlock nodes so they render
  as interactive components instead of raw text
- New DetailsBlock (src/nodes/details.tsx): click-to-toggle with useState,
  extracts summaryText from opening html chunk (block path) or summary child
  node (inline path), falls back to 'Details' label
- Add CodeOptions interface: lineNumbers (bool | {minLines}) and maxHeight;
  exported from index.tsx and threaded through Walk → BlockNode → CodeBlock
  and all recursive call sites (ListItemNode, DefListBlock, DetailsBlock)
- Line numbers: gutter scales with log10(lineCount), auto-shows on blocks
  >= minLines (default 6), opt-in via codeOptions.lineNumbers
- maxHeight replaces hardcoded MAX_CODE_BLOCK_HEIGHT; getBlockMetrics in
  block-metrics.ts updated to accept optional third param
- thematicBreak uses process.stdout.columns instead of hardcoded 40
- Fix open.ts: remove unclosed async commandExists wrapper, add missing
  commandExistsCache declaration, restore terminal variable assignment
  and guard in openWithTerminalEditor, keep injection-safe args and
  xfce4-terminal --command fix from PRs #10/#11
- Update assets/markdown-test.md with details/summary section and
  line numbers demo; update test-render.tsx to pass codeOptions
@skyth-engine skyth-engine force-pushed the feat/details-line-numbers-v2 branch from bea3946 to b282be0 Compare June 12, 2026 14:19
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