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
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
Description
Add
htmlto the output format list. Render SQL query results as an HTML<table>element.Motivation
HTML tables are useful for embedding query results in web pages, email reports, and internal dashboards. The existing XML escaping infrastructure (
writeXmlEscapedinxml.zig) can be reused for HTML entity escaping.Acceptance Criteria
htmlto theOutputFormatenum insrc/format.zig<table>,<thead>,<tbody>,<tr>,<th>,<td>tagswriteXmlEscapedpattern)--header(controls<thead>vs<tbody>separation)--html-class <class>flag for CSS class on the<table>elementImplementation Notes
format.ziglines 97-211)begin(): write<table>\n<thead><tr>+<th>for each columnwriteRow(): write<tr>+<td>for each valueend(): write</tbody></table>\n