Skip to content

Render support ticket markdown and ASCII tables as HTML in admin#375

Merged
simonhamp merged 1 commit into
mainfrom
support-context-markdown
May 11, 2026
Merged

Render support ticket markdown and ASCII tables as HTML in admin#375
simonhamp merged 1 commit into
mainfrom
support-context-markdown

Conversation

@simonhamp
Copy link
Copy Markdown
Member

@simonhamp simonhamp commented May 11, 2026

Summary

Filament's support ticket Context panel was rendering the message via a bare ->markdown() call, which collapsed single newlines and produced an unreadable run-on paragraph whenever a user pasted artisan output (ASCII tables) into the Environment field of a bug report.

This PR replaces the ->markdown() call on the message TextEntry with a custom renderTicketMessage() helper that:

  • Detects runs of +/| lines and converts them into real HTML <table> elements. If the first row is separator-delimited it becomes a <thead>; otherwise the table is tbody-only so key/value style artisan output stays aligned.
  • Renders the rest of the content through CommonMark with soft_break => "<br />" so single newlines in the original message survive.
  • Applies inline styles (width: auto, padding, borders, zebra striping, paragraph spacing) using semi-transparent neutral colors. This keeps the layout compact (tables don't span the full panel), readable (key sits next to value), and works in both light and dark Filament themes without relying on Tailwind classes (which aren't guaranteed available in this Filament context).

Test plan

  • php artisan test --compact tests/Feature/SupportTicketTest.php (87 passed)
  • Visit /admin/support-tickets/{ticket} for a ticket whose message contains pasted artisan output and confirm: bold labels render, sections have visible spacing, ASCII tables render as proper HTML tables sized to content with zebra stripes.

🤖 Generated with Claude Code

Filament's TextEntry markdown rendering was collapsing single newlines,
which mangled pasted artisan output (ASCII tables) into a single line on
the admin support ticket view. Replace the bare `->markdown()` with a
custom renderer that:

- Detects consecutive `+`/`|` lines and converts them into real HTML
  tables (with a header when separator-delimited, otherwise tbody-only
  so key/value layouts stay aligned)
- Enables soft-break -> `<br />` conversion so other line breaks survive
- Applies inline styles (width: auto, padding, borders, zebra stripes,
  paragraph spacing) using semi-transparent neutrals so the result works
  in both light and dark Filament themes without depending on Tailwind

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@simonhamp simonhamp marked this pull request as ready for review May 11, 2026 12:28
@simonhamp simonhamp merged commit 44fadb8 into main May 11, 2026
2 checks passed
@simonhamp simonhamp deleted the support-context-markdown branch May 11, 2026 22:23
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