Skip to content

Commit 061b6c7

Browse files
authored
Merge pull request #141 from kolyshkin/fix-long-tables
Table rendering fix
2 parents 75548be + dcb0114 commit 061b6c7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

md2man/roff.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const (
4747
tableStart = "\n.TS\nallbox;\n"
4848
tableEnd = ".TE\n"
4949
tableCellStart = "T{\n"
50-
tableCellEnd = "\nT}\n"
50+
tableCellEnd = "\nT}"
5151
tablePreprocessor = `'\" t`
5252
)
5353

@@ -316,9 +316,8 @@ func (r *roffRenderer) handleTableCell(w io.Writer, node *blackfriday.Node, ente
316316
} else if nodeLiteralSize(node) > 30 {
317317
end = tableCellEnd
318318
}
319-
if node.Next == nil && end != tableCellEnd {
320-
// Last cell: need to carriage return if we are at the end of the
321-
// header row and content isn't wrapped in a "tablecell"
319+
if node.Next == nil {
320+
// Last cell: need to carriage return if we are at the end of the header row.
322321
end += crTag
323322
}
324323
out(w, end)

md2man/roff_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ func TestTable(t *testing.T) {
276276
| wombat | No idea. |
277277
| zebra | Sometimes black and sometimes white, depending on the stripe. |
278278
| robin | red. |
279+
| Meerschweinchen a.k.a. guinea pig | Varies. |
279280
`,
280281
`'\" t
281282
.nh
@@ -293,6 +294,9 @@ zebra T{
293294
Sometimes black and sometimes white, depending on the stripe.
294295
T}
295296
robin red.
297+
T{
298+
Meerschweinchen a.k.a. guinea pig
299+
T} Varies.
296300
.TE
297301
`,
298302
}

0 commit comments

Comments
 (0)