We have our own skin at our site but every viewed HTML page has a trailing <p /> after the </html> tag. I have tracked down the reason to poor handling of empty lines in TWiki::Template::readTemplate():
The function at some point removes all the TMPL:DEF blocks leaving only the text that is left, typically something like this for a page view:
%TMPL:P{"htmldoctype"}%
%TMPL:P{"head"}%
%TMPL:P{"bodystart"}%
%TMPL:P{"main"}%
%TMPL:P{"bodyend"}%
With our template there are both empty lines before and after that. Some of them come from removed comment lines but some I have not been able to remove all of them by reformating the templates.
I think that all empty lines before and after the remaining template text should be removed. The attached patch to readTemplate() did the job and removes the trailing paragraphs.
Can you please implement this (or a similar fix) in the main TWiki code?
--
TWiki:Main/StefanWalter
- 2016-06-16
Sorry that you stumbled over this, but I'm afraid this patch can't make it into the code.
The current behaviour, to keep newlines
exactly as the template author wrote them, was introduced in TWiki 4 (Dakar release) after some discussion, because it was required to make some templating stuff work, in particular with the
TWiki:Plugins.CommentPlugin
. Back then, all the Skins shipped with TWiki were adapted, and therefore today you see
bodyend
usually written like this:
%TMPL:DEF{"bodyend"}%</div><!--/twikiPage--></body></html>%TMPL:END%
. Note there's no newline between the end tags and
%TMPL:END%
!
TWiki:TWiki.TWikiSkins
has an - easily overlooked - warning to "Make sure templates do not end with a newline", mentioning the spurious extra paragraph this can cause. In many places this is ugly but harmless, but for
bodyend
as well as for all templates expanded in the
head
element, you get invalid HTML.
If you just adapt your
bodyend
definition in your template then the extra paragraph should go away!
--
TWiki:Main.HaraldJoerg
- 2016-06-16
18 months passed, so I'm marking this now as 'No action required' before the next release.
--
TWiki:Main.HaraldJoerg
- 2017-12-19