Tags:
create new tag
, view all tags

Bug: \n between DOCTYPE and html need not to be translated

DEVELOP BRANCH ONLY

any amount of \n characters in the twiki.pattern.tmpl between the <!DOCTYPE> and the <html> get translated into one <p /> element. if you validate the result with the w3.org validator you will get a 'document type does not allow element "p" here' error.

for the time being, on my system, I've removed the \n between the elements, but my opinion is that the best way to solve this is to limit the translation of \n characters to the body element (this is where they are allowed).

Test case

update to svn 3807, browse to any page and have a look at the html source.

Environment

TWiki version: TWikiAlphaRelease
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Debian GNU/Linux unstable on ppc
Web server: Apache/1.3.33
Perl version: This is perl, v5.8.4 built for powerpc-linux-thread-multi
Client OS: same as server
Web Browser: Mozilla/5.0 (X11; U; Linux ppc; en-US; rv:1.7.5) Gecko/20050210 Firefox/1.0 (Debian package 1.0+dfsg.1-6)

-- MarioFrasca - 13 Mar 2005

Impact and Available Solutions

Fix record

very very quick fix:

--- templates/twiki.pattern.tmpl   (revision 3807)
+++ templates/twiki.pattern.tmpl   (working copy)
@@ -8,8 +8,8 @@
 
 %TMPL:DEF{"htmldoctype"}%
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">%TMPL:END%
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
+> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">%TMPL:END%

Discussion

Hmm, that was a can of worms! Bug not in Cairo. The reason the gap appeared was because I was removing the DOCTYPE tag to prevent it getting damaged during rendering. Becuae it was on a line of it's own that left a blank line in the template, and hence the p tag. I fixed to removal so it takes bordering space with the tag, and it works as expected now. I also discovered it was rendering the template multiple times, so I trimmed that back to once. r3810

-- CrawfordCurrie - 14 Mar 2005

about the empty lines being replaced by a <p /> tag, notice that in the branches/DEVELOP/templates/Main/view.pattern.tmpl the %TEXT% is separated by the rest of the template by two empty lines. in particular the one preceding it seems to me out of place. for simmetry, on my system, I removed both.

-- MarioFrasca - 14 Mar 2005

Strange, these empty lines are not in the Cairo release.

-- ArthurClemens - 15 Mar 2005

I think the best solution is to replace empty lines by <p /> only in the $text variable before replace/matching the %TEXT% in the template. I did not find where this happens, this is why I did not post a patch.

-- MarioFrasca - 15 Mar 2005

I have the feeling that the rendering of other template elements (form, attachments, plugins?) is based on the same replace pattern. Perhaps someone deeper into the rendering pipeline can confirm.

-- ArthurClemens - 15 Mar 2005

Read my lips; BUG NOT IN CAIRO - it was introduced in DevelopBranch, and has been fixed. Mario, it's really not that simple; the rendering pipeline is horrendously complex, and nailing down the time and place to disable <p> expansion would be a nightmare.

-- CrawfordCurrie - 15 Mar 2005

horrendously complex: it was my same impression, that's why after half an hour+ trying to understand and find the place, I gave up. but then we must take care that no superfluous double "\n" gets in a template. in particular, as I told yesterday, I would take those two blank lines preceding and following %TEXT% out of the branches/DEVELOP/templates/Main/view.pattern.tmpl. maybe it has already been done, I don't read SVN from here...

-- MarioFrasca - 15 Mar 2005

I didn't bother removing the newlines, because they are harmless with the bug fixed.

-- CrawfordCurrie - 15 Mar 2005

you mean: "this still is a can of worms", present and not yet past?

on r3810 the blank line before the %TEXT% still caused any topic to start with a <p />. this is not a mistake as it was putting that <p /> outside the body element, but it is not wat the user writes in the topic anyway... on my system I removed it. it is necessary to make the rendered text look the same on both Cairo and DEVELOP.

-- MarioFrasca - 15 Mar 2005

r3819 I have removed the blank lines.

-- ArthurClemens - 16 Mar 2005

 
Topic revision: r11 - 2005-03-16 - ArthurClemens
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.