Skip to content

Add HTML table output format (-O html) #173

@vmvarela

Description

@vmvarela

Description

Add html to the output format list. Render SQL query results as an HTML <table> element.

sql-pipe data.csv -O html 'SELECT * FROM t LIMIT 5'
# <table>
# <thead><tr><th>name</th><th>age</th></tr></thead>
# <tbody>
# <tr><td>Alice</td><td>30</td></tr>
# <tr><td>Bob</td><td>25</td></tr>
# </tbody>
# </table>

Motivation

HTML tables are useful for embedding query results in web pages, email reports, and internal dashboards. The existing XML escaping infrastructure (writeXmlEscaped in xml.zig) can be reused for HTML entity escaping.

Acceptance Criteria

  • Add html to the OutputFormat enum in src/format.zig
  • Implement HTML table writer with <table>, <thead>, <tbody>, <tr>, <th>, <td> tags
  • HTML-escape all cell values (reuse writeXmlEscaped pattern)
  • NULL values render as empty cells
  • Compatible with --header (controls <thead> vs <tbody> separation)
  • Optional --html-class <class> flag for CSS class on the <table> element
  • Integration tests cover the new format
  • Help text updated

Implementation Notes

  • Follow the same pattern as the XML output writer (format.zig lines 97-211)
  • begin(): write <table>\n<thead><tr> + <th> for each column
  • writeRow(): write <tr> + <td> for each value
  • end(): write </tbody></table>\n
  • About 40 lines of new code

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:mediumShould be done soonsize:sSmall — 1 to 4 hoursstatus:readyRefined and ready for sprint selectiontype:featureNew functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions