diff --git a/md2man/roff.go b/md2man/roff.go index eefec1a..c5061a7 100644 --- a/md2man/roff.go +++ b/md2man/roff.go @@ -177,7 +177,7 @@ func (r *roffRenderer) handleText(w io.Writer, node *blackfriday.Node, entering end = tableCellEnd } else { // end rows that aren't terminated by "tableCellEnd" with a cr if end of row - if node.Parent.Next == nil && !node.Parent.IsHeader { + if node.Parent.Next == nil && node.Next == nil && !node.Parent.IsHeader { end = crTag } } diff --git a/md2man/roff_test.go b/md2man/roff_test.go index 2dfc422..0121f56 100644 --- a/md2man/roff_test.go +++ b/md2man/roff_test.go @@ -295,6 +295,39 @@ row two x doTestsInlineParam(t, tests, TestParams{blackfriday.Tables}) } +func TestTableWrapping(t *testing.T) { + var tests = []string{ + ` +| Col1 | Col2 | +| ----------- | ----------------------------------------- | +| row one | This is a short line. | +| row\|two | Col1 should not wrap. | +| row three | no\|wrap | +| row four | Inline _cursive_ should not wrap. | +| row five | Inline ` + "`code`" + ` should not wrap. | +| row six | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu ipsum eget tortor aliquam accumsan. Quisque ac turpis convallis, sagittis urna ac, tempor est. Mauris nibh arcu, hendrerit id eros sed, sodales lacinia ex. Suspendisse sed condimentum urna, vitae mattis lectus. Mauris imperdiet magna vel purus pretium, id interdum libero. | +`, + `.nh + +.TS +allbox; +l l +l l . +\fB\fCCol1\fR \fB\fCCol2\fR +row one This is a short line. +row|two Col1 should not wrap. +row three no|wrap +row four Inline \fIcursive\fP should not wrap. +row five Inline \fB\fCcode\fR should not wrap. +row six T{ +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu ipsum eget tortor aliquam accumsan. Quisque ac turpis convallis, sagittis urna ac, tempor est. Mauris nibh arcu, hendrerit id eros sed, sodales lacinia ex. Suspendisse sed condimentum urna, vitae mattis lectus. Mauris imperdiet magna vel purus pretium, id interdum libero. +T} +.TE +`, + } + doTestsInlineParam(t, tests, TestParams{blackfriday.Tables}) +} + func TestLinks(t *testing.T) { var tests = []string{ "See [docs](https://docs.docker.com/) for\nmore",