Skip to content

Comments

feat: add configurable table styles (markdown, boxDrawing, doublePipe)#8

Open
bquenin wants to merge 1 commit intofranlol:mainfrom
bquenin:feature/box-drawing
Open

feat: add configurable table styles (markdown, boxDrawing, doublePipe)#8
bquenin wants to merge 1 commit intofranlol:mainfrom
bquenin:feature/box-drawing

Conversation

@bquenin
Copy link

@bquenin bquenin commented Feb 8, 2026

Summary

Adds configurable table styles, addressing review feedback to not make box-drawing the only option.

  • Strategy pattern: Each style provides a renderTable() function, cleanly separating parsing from rendering
  • createBorderedStyle(chars) factory: All bordered variants (boxDrawing, doublePipe) are generated from a character map — adding a new bordered style is a single function call
  • Default to standard markdown: Existing behavior is preserved out of the box
  • OPENCODE_TABLE_STYLE env var: Set to markdown (default), boxDrawing, or doublePipe
  • Shared parseTable(): Style-independent parsing extracted into its own function
  • formatSeparatorCell restored: Markdown style uses the original separator logic from main

Available styles

markdown (default):

| Name   | Age | City     |
| ------ | --- | -------- |
| Alice  | 30  | New York |
| Bob    | 25  | London   |

boxDrawing:

┌────────┬─────┬──────────┐
│ Name   │ Age │ City     │
├────────┼─────┼──────────┤
│ Alice  │ 30  │ New York │
│ Bob    │ 25  │ London   │
└────────┴─────┴──────────┘

doublePipe:

╔════════╦═════╦══════════╗
║ Name   ║ Age ║ City     ║
╠════════╬═════╬══════════╣
║ Alice  ║ 30  ║ New York ║
║ Bob    ║ 25  ║ London   ║
╚════════╩═════╩══════════╝

Extensibility

Adding a new bordered style is a one-liner:

myStyle: createBorderedStyle({ topLeft: "╭", horizontal: "─", ... })

Closes #7

bquenin added a commit to bquenin/opencode-md-table-formatter that referenced this pull request Feb 8, 2026
Remove accidentally committed package-lock.json (Bun project),
add it to .gitignore, and bump version to 0.1.0 for breaking change.
@bquenin bquenin marked this pull request as ready for review February 8, 2026 21:02
@franlol
Copy link
Owner

franlol commented Feb 20, 2026

Love the idea, this makes the tables look much nicer!

I agree that we shouldn’t force a single style by default, instead, a configuration option would be so good.

But the implementation should be scalable, so adding more styles later (like a "doublePipe" option using double‑line box characters) is straightforward:

╔═══════╦═════╦══════════╗
║ Name  ║ Age ║ City     ║
╠═══════╬═════╬══════════╣
║ Alice ║ 30  ║ New York ║
║ Bob   ║ 25  ║ San Diego║
╚═══════╩═════╩══════════╝

Can you adjust the PR to add this as a style option , with the default one set to the standard markdown, and with a structure that makes extending it easy? That’ll give us flexibility without locking in one aesthetic.

Thanks!

Refactor table rendering to use a strategy pattern with pluggable styles.
Default to standard markdown tables; box-drawing and double-pipe styles
are available via the OPENCODE_TABLE_STYLE environment variable.

- Extract shared parseTable() for style-independent parsing
- Add createBorderedStyle() factory for bordered variants
- Restore markdown style with formatSeparatorCell from main
- Add TABLE_STYLES registry for easy extensibility
- Document configuration in README
@bquenin bquenin force-pushed the feature/box-drawing branch from 07155ee to 814306a Compare February 21, 2026 02:54
@bquenin bquenin changed the title feat: use box-drawing characters for table formatting feat: add configurable table styles (markdown, boxDrawing, doublePipe) Feb 21, 2026
@bquenin
Copy link
Author

bquenin commented Feb 21, 2026

Hey @franlol — I've reworked this based on your feedback. Here's what changed:

  • Default is now standard markdown (| --- | tables), so existing behavior is preserved
  • Style is configurable via the OPENCODE_TABLE_STYLE env var (markdown, boxDrawing, doublePipe)
  • Extensible structure — adding a new bordered style is a single createBorderedStyle({ ... }) call
  • Parsing is separated from rendering via a strategy pattern, so styles don't leak into each other

Let me know what you think!

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.

Feature request: Box-drawing character borders for table rendering

2 participants