Feature Proposal: Do not use self-closing P tag for a blank line
Motivation
TwistyPlugin fails to work on Firefox and Google Chrome (and probably other WebKit based browsers) under certain circumstances.
Description and Documentation
This is to propose to put <p></p> instead of <p /> for a blank line in
TML (TWiki Markup Language).
This is because a <p /> messes up
DOM structure and makes
TwistyPlugin not work.
A self-closing tag like <p/> is valid in
XHTML and TWiki generates
HTML pages declaring
XHTML.
However, Firefox, IE 9, Chrome doesn't recognize a page is in
XHTML unless the page's content type is text/xml or application/xml, which is not the case on TWiki.
Consequently, <p/ > is recognized as unclosed <p>, and those browsers handle it in a way you don't expect. When we insert a blank line before a twisty control, twisty control doesn't work because its
DOM structure is messed up by that unclosed P tag.
Examples
The following reproduces the symptom.
---++ leave an empty line before twisty control
%TWISTY%
<div>This twisty control doesn't work.</div>
%ENDTWISTY%
leave an empty line before twisty control
More... Close
This twisty control doesn't work.
On Firefox, IE 9, Google Chrome, you find the twisty control doesn't work unless you remove the blank line above it or replace the blank line with <P></P>.
Impact
Implementation
--
Contributors:
Yaojun Fei - 2013-03-22
Discussion
Isn't the reason for the not working TWISTY due to block elements vs inline elements? Your example has a
div, e.g. you
have to specify block mode:
%TWISTY{ mode="div" }%. See details in
TwistyPlugin.
Test:
This twisty control works now due to mode="div" parameter.
It is easy to miss this detail. That is why I proposed
NewAutoModeForTwisty. It just needs to be implemented.
--
Peter Thoeny - 2013-03-23
Thank you for your correction, Peter. AutoMode proposal makes more sense. Let's close this one.
--
Yaojun Fei - 2013-03-25
Agreed. For now I updated the
TwistyPlugin to point out the "gotcha".
--
Peter Thoeny - 2013-03-25
We have seen some issues/complaints after upgrading about 30 webs (out of 4000 webs pending!), where there have been a lot of TWISTY used for block parts without
mode="div".
There are two reasons: (1) we have fixed
<p /> tags locally and supported it for years, and (2) TWISTY has worked with IE8 or older without problems. For us, the easiest fix seems to be to convert
<p /> into
<p></p> which is equally valid
XHTML.
As a bonus, it would fix a minor semantics issue where
<p /> is misinterpreted by browsers. (Looks like
<p /> is misinterpreted as an opening tag if Content-Type is text/html, despite twiki's intention.)
For example, if you write:
line 1
line 2
line 3
line2 and line3 are unexpectedly inside <p> tags while line1 is not, which may have some stylesheet impact.
How does it sound to convert <p /> tags?
--
Mahiro Ando - 2013-04-10
I do not see an issue in converting self closing p tags into proper paragraphs. Needs to be tested well, such as p tag before/after a block element, bullet, table, etc.
However, I do not understand how this fixes the twisty issue. A twisty that spans multiple blocks
has to be of type div in order to get valid
XHTML. So, I think the intelligent
NewAutoModeForTwisty is a proper fix.
--
Peter Thoeny - 2013-04-10
Thanks Peter for the comment. I thought mode="auto" was something we needed to add explicitly (to our thousands of topics), but never mind - it will be the default, which will solve the problem in a better way. (Just to clarify,
<p></p> would certainly make twisty appear to work, but probably in a non-XHTML-compliant way, as you mention.) Now I don't think we need to modify
<p /> just for twisty.
It seems you are the committed developer for
NewAutoModeForTwisty, but it was updated more than a year ago. Are you still willing to implement it, or would you like to hand it over to us? We'd like to have the feature soon, if that is possible.
--
Mahiro Ando - 2013-04-10
I have so many pending things, and am falling behind on the important
TWikiAppInstaller feature. By all means, please take ownership of
NewAutoModeForTwisty.
--
Peter Thoeny - 2013-04-10
Sounds great. I have updated
NewAutoModeForTwisty and will work on the implementation.
--
Mahiro Ando - 2013-04-10
This issue is revisited on
OpenAndClosePTags.
--
Hideyo Imazu - 2013-07-05