diff --git a/org/html_writer.go b/org/html_writer.go index bfc002a..7c5c6d3 100644 --- a/org/html_writer.go +++ b/org/html_writer.go @@ -459,23 +459,31 @@ func (w *HTMLWriter) WriteNodeWithName(n NodeWithName) { func (w *HTMLWriter) WriteTable(t Table) { w.WriteString("\n") - beforeFirstContentRow := true + inHead := len(t.SeparatorIndices) > 0 && + t.SeparatorIndices[0] != len(t.Rows)-1 && + (t.SeparatorIndices[0] != 0 || len(t.SeparatorIndices) > 1 && t.SeparatorIndices[len(t.SeparatorIndices)-1] != len(t.Rows)-1) + if inHead { + w.WriteString("\n") + } else { + w.WriteString("\n") + } for i, row := range t.Rows { - if row.IsSpecial || len(row.Columns) == 0 { - continue - } - if beforeFirstContentRow { - beforeFirstContentRow = false - if i+1 < len(t.Rows) && len(t.Rows[i+1].Columns) == 0 { - w.WriteString("\n") - w.writeTableColumns(row.Columns, "th") + if len(row.Columns) == 0 && i != 0 && i != len(t.Rows)-1 { + if inHead { w.WriteString("\n\n") - continue + inHead = false } else { - w.WriteString("\n") + w.WriteString("\n\n") } } - w.writeTableColumns(row.Columns, "td") + if row.IsSpecial { + continue + } + if inHead { + w.writeTableColumns(row.Columns, "th") + } else { + w.writeTableColumns(row.Columns, "td") + } } w.WriteString("\n
\n") } diff --git a/org/testdata/options.html b/org/testdata/options.html index bdf6c50..f003629 100644 --- a/org/testdata/options.html +++ b/org/testdata/options.html @@ -29,6 +29,8 @@ As buffer options are merged with the defaults, the above headline will be expor toc Include table of contents (outline) + + pri Include priority [#A], [#B], [#C] in headline title diff --git a/org/testdata/tables.html b/org/testdata/tables.html index f31e84d..14729a0 100644 --- a/org/testdata/tables.html +++ b/org/testdata/tables.html @@ -151,3 +151,43 @@ table with aligned and sized columns table with right aligned columns (because numbers) +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
abc
123
...
123
123
+
+table with multiple separators (~ multiple tbodies) +
+
diff --git a/org/testdata/tables.org b/org/testdata/tables.org index 215c540..271c259 100644 --- a/org/testdata/tables.org +++ b/org/testdata/tables.org @@ -36,3 +36,13 @@ | long column a | long column b | long column c | |---------------+---------------+---------------| | 1 | 2 | 3 | + +#+CAPTION: table with multiple separators (~ multiple tbodies) +| a | b | c | +|---+---+---| +| 1 | 2 | 3 | +| . | . | . | +|---+---+---| +| 1 | 2 | 3 | +|---+---+---| +| 1 | 2 | 3 | diff --git a/org/testdata/tables.pretty_org b/org/testdata/tables.pretty_org index 215c540..271c259 100644 --- a/org/testdata/tables.pretty_org +++ b/org/testdata/tables.pretty_org @@ -36,3 +36,13 @@ | long column a | long column b | long column c | |---------------+---------------+---------------| | 1 | 2 | 3 | + +#+CAPTION: table with multiple separators (~ multiple tbodies) +| a | b | c | +|---+---+---| +| 1 | 2 | 3 | +| . | . | . | +|---+---+---| +| 1 | 2 | 3 | +|---+---+---| +| 1 | 2 | 3 |