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:
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?
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
usually written like this:
. Note there's no newline between the end tags and
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
as well as for all templates expanded in the
element, you get invalid HTML.
If you just adapt your
definition in your template then the extra paragraph should go away!
18 months passed, so I'm marking this now as 'No action required' before the next release.