Item12230: WysiwygPlugin: tml2html: introduces spurious hidden whitespace in HTML table cells that contain blank lines

Priority: Normal
Current State: Waiting for Release
Released In: 2.2.0
Target Release: minor
Applies To: Extension
Component: WysiwygPlugin
Reported By: JanKrueger
Waiting For:
Last Change By: CrawfordCurrie
Put this into a topic in wikitext mode:

<table id="prevent_conversion_to_tml"><tr><td>

*should be bold*

plain text</td></tr></table>

When you go back to WYSIWYG mode, you see this:

*should be bold*

plain text

What's going on? Well, whenever tml2html encounters a line that doesn't look like anything special (blank line, list item, TML table, ...), it inserts a hidden newline tag into that line, unless we had an opening P tag at the end of the previous line. However, multi-paragraph DIVs and tables are currently encoded like this by tml2html (this example is before whitespace mangling and text style conversion):

<table id="prevent_conversion_to_tml"><tr><td>
<p class='WYSIWYG_NBNL'></p>
*should be bold*
plain text</td></tr></table>

So, as you can see, both lines of text are not immediately preceded by an opening P tag, which makes the code insert these problematic spans:

<table id="prevent_conversion_to_tml"><tr><td>
<p class='WYSIWYG_NBNL'></p>
<span style="{encoded:'n'}" class="WYSIWYG_HIDDENWHITESPACE">&nbsp;</span>*should be bold*
<span style="{encoded:'n'}" class="WYSIWYG_HIDDENWHITESPACE">&nbsp;</span>plain text</td></tr></table>

(Line breaks inserted for easier reading)

Now, after the SPANs have been inserted, text styles are applied. Bold formatting (*foo*), however, requires that the asterisk is preceded by whitespace (or a line break). This is now no longer the case. Therefore, the asterisks are not converted into HTML formatting.

I would propose changing the way paragraph tags are generated within tables and DIVs (I'm not even sure whether the current markup is valid; is it permissible to nest P tags? This appears to happen in DIVs to some extent...). In short, just use normal paragraph tags (assuming TinyMCE can deal with that; I don't know because I really only use CKEditor). Maybe the output would look like this:

<table id="prevent_conversion_to_tml"><tr><td>
<p class='WYSIWYG_NBNL'>
<strong>should be bold</strong>
plain text</p></td></tr></table>

The only real difficulty here is patching the final closing P tag into the last line. The code can't currently recognize the right place reliably because it only notices that the table is over when it spots the closing TABLE tag – the closing TD tag might have been on a previous line which we have already added to the output queue.

I'm not implementing a fix for now because I don't know whether the current output (the <p></p> combos) is intentional. I'd like some feedback before I try anything. Which isn't to say that someone else can't fix it. wink

-- JanKrueger - 08 Nov 2012

I'm pretty sure the <p></p> output for blank lines is intentional. Trying to keep paragraphs open results in issues when render inserts elements into paragraph blocks that are not legal inside the block. It was quite a battle to convince the TML2HTML process not to create illegal HTML structure. TMCE is a strict editor, so any illegal structure is simply removed by the editor. IIRC, some of the previous "disappearing whitespace" issues were caused because the special whitespace preserving divs were generated inside a paragraph, A <div> inside a paragraph tag is illegal. so any attempt at keeping paragraphs open needs to make sure that no div's are generated internal to them.

-- GeorgeClark - 08 Nov 2012

Looks to me like this is working sensibly in the latest code in Item14323 branch.

-- Main.CrawfordCurrie - 10 Mar 2017 - 14:32


ItemTemplate edit

Summary WysiwygPlugin: tml2html: introduces spurious hidden whitespace in HTML table cells that contain blank lines
ReportedBy JanKrueger
Codebase 1.1.6 dev, 1.1.5, trunk
SVN Range
AppliesTo Extension
Component WysiwygPlugin
Priority Normal
CurrentState Waiting for Release
TargetRelease minor
ReleasedIn 2.2.0
Topic revision: r5 - 28 Mar 2017, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy