# TODO: Implement quoting properly function quote_html(s) { return s; } function quote_html_attribute(s) { return gensub("\"", """, "g", s) } BEGIN { FS = ":" num_rows = 0 num_cols = 0 read_header = 1 # h/t https://wabain.github.io/2019/10/13/css-rotated-table-header.html print "" } END { printf "" for (i=0; i < num_cols; i++) { printf "", quote_html_attribute(col_headers[i]), quote_html(col_headers[i]) } print ""; for (i=1*skip_rows; i <= num_rows; i++) { spacer_row = substr(row_headers[i], 1, 1) == "!" row_header = spacer_row ? substr(row_headers[i], 2) : row_headers[i] printf "", quote_html_attribute(row_header), quote_html(row_header) for (j = 0;j < num_cols; j++) { printf "" } print "" } print "
%s
%s" rows[i][j] "
" } { if (/^$/) { read_header = 1 num_rows++ } else { if (read_header) { read_header = 0 row_headers[num_rows] = $0 } else { if (! ($1 in col_index)) { col_headers[num_cols] = $1 col_index[$1] = num_cols++ } rows[num_rows][col_index[$1]] = $2 ? $2 : " " } } }