TinyMCE tables adds line breaks

SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
When creating tables in TinyMCE they look fine in the editor window, but on the front end many line breaks are inserted both before the opening table tag and within the table cells.

Does anyone else see this happening?

Reference to this:
https://www.jamroom.net/the-jamroom-network/forum/using-jamroom/28889/creating-a-table-in-a-blog-post




--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 07/08/15 08:27:43AM
michael
@michael
10 years ago
7,793 posts
When your outputting whatever it is that the table is being saved to, you could blacklist the nl2br function

{$blog_description|jrCore_format_string:$item.profile_quota_id:false:"nl2br"}
function smarty_modifier_jrCore_format_string($string, $quota_id = 0, $whitelist = null, $blacklist = null)

as I suspect its the structure of the table being kept rather than compressed thats causing the default nl2br to be active on the table.

check to see if your table looks like this:
<tr><br>
<td></td><br>
<td></td><br>
....
SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
Yes, the table looks a bit like that like that. The br tags are inserted before the opening table tag though rather than as part of the table. It also contains h4 tags which have line breaks inserted before and after each one as well.

If I blacklist nl2br for all the text areas in the site, do you know what that is likely to do to the rest of the formatting of the tinymce input (ie things other than tables)?

The forum here wont let me post the output table code - looks like br tags are not allowed.

Thanks




--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 06/04/15 08:06:13AM
SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
With the h1 - h6 tags removed the table is output ok, but with one br per table cell inserted before the opening table tag. So the result is a large white space before each table.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
michael
@michael
10 years ago
7,793 posts
If you know the input for any location was put there by tinymce then using nl2br is safe and desired (I thought it was in by default, this happens all the time?).

Because tinymce will give the appropriate formatting. If the input box is NOT using tinymce, like the post box here doesn't then you will want to have nl2br ON because a new line should be re-formatted to a BR so the breaks stay in.

Depends on how your setup is setup.

I'll go check out adding a table and look for why BR's are turning up.

--edit--
seeing it, will get it sorted. Thanks.
updated by @michael: 06/04/15 07:58:14PM
michael
@michael
10 years ago
7,793 posts
This will be sorted automatically in the next jrCore release.

Thanks.

Tags