Ghost icon indicating copy to clipboard operation
Ghost copied to clipboard

Ghost incorrectly renders carriage returns in an HTML `<table>` as `<br/>` elements.

Open GregBrant opened this issue 10 years ago • 4 comments

I think I've found a bug in Ghost whereby it's rendering carriage returns in an html <table> as <br> elements, directly before the table.

The following snippet of markdown:

This is a paragraph.

<table>
<tr>
<th>Table Head</th>
</tr>
<tr>
<td>Table Cell</td>
</tr>
<table>

This is another paragraph.

... should result in the following HTML:

<p>This is a paragraph.</p>

<table>
<tr>
<th>Table Head</th>
</tr>
<tr>
<td>Table Cell</td>
</tr>
<table>

</p>This is another paragraph.</p>

... but instead you end up with this.

<p>This is a paragraph.</p>
<p></p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<table>
<tr>
<th>Table Head</th>
</tr>
<tr>
<td>Table Cell</td>
</tr>
<table>

</p>This is another paragraph.</p>

There appears to be one <br> for each carriage return in the <table>.

I've put together a working repro on my blog at http://greg-brant.ghost.io/2015/12/10/ghost-blog-table-rendering-issue/

Tested in Chrome 47 on Ubuntu 15.10. Safari on iOS 9.

GregBrant avatar Dec 10 '15 22:12 GregBrant

ghost-table-render-issue

Here's a screen grab of the Chrome DOM inspector.

GregBrant avatar Dec 10 '15 22:12 GregBrant

Hi @GregBrant, thanks for contributing :smile: . Unfortunately this appears to be a bug in Ghost's markdown parser showdown. There are currently a number of standing issues regarding the parser, which will hopefully be addressed soon.

acburdine avatar Dec 10 '15 23:12 acburdine

Hi I think this issue generated by wrong html code. we can view table tag not closing properly that's why rendering carriage returns. I was facing same issue but after change html code it's working fine.

narayand4 avatar Jan 14 '16 08:01 narayand4

@narayand4 good catch :+1: - there's very little we can do to recover from invalid HTML, which is in fact the issue here.

@GregBrant if you change <table> to </table> at the end of your HTML block, you'll find this issue goes away.

ErisDS avatar Jan 25 '16 13:01 ErisDS