Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,23 @@
def html_row:
"<tr>",
" \(.[] | "<td>\(.)</td>")",
"</tr>";
def html_header:
"<thead align = 'right'>",
" \(html_row)",
"</thead>";
def html_table(header):
"<table>",
" \(header | html_header)",
" <tbody align = 'right'>",
" \(.[] | html_row)",
" </tbody",
"</table>";
# Prepend the sequence number
def html_table_with_sequence(header):
length as $length
| . as $in
| [range(0;length) | [.+1] + $in[.]] | html_table(header);

View file

@ -0,0 +1,7 @@
def data:
[ [4,5,6],
[41, 51, 61],
[401, 501, 601] ];
# The first column has no header
data | html_table_with_sequence( ["", "X", "Y", "Z"] )

View file

@ -0,0 +1,31 @@
$ jq -r -n -f Create_an_HTML_table.jq
<table>
<thead align = 'right'>
<tr>
<td></td>
<td>X</td>
<td>Y</td>
<td>Z</td>
</tr>
</thead>
<tbody align = 'right'>
<tr>
<td>1</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>2</td>
<td>41</td>
<td>51</td>
<td>61</td>
</tr>
<tr>
<td>3</td>
<td>401</td>
<td>501</td>
<td>601</td>
</tr>
</tbody
</table>