Item11102: Conditionally render html as html5
Priority: Enhancement
Current State: No Action Required
Released In: n/a
Target Release: minor
Quite some html markup that is emitted by core code is invalid in html5. For instance, anchor links do not have a
name
attribute, list items do not have a
type
attribute.
We cannot change this because we will support html 4 for a very long time. A rendering setting can be used to conditionally emit different markup.
Proposal: new "Miscellaneous" setting
{RenderedHtmlVersion}
with the options 4 (default) and 5.
Core code then renders different html if
{RenderedHtmlVersion}
is
5
.
For instance,
Anchors.pm
will have 2 ways to render an anchor link:
if ( $Foswiki::cfg{RenderedHtmlVersion} == 5 ) {
# some code
} else {
# other code
}
But it would be better if we had a HtmlRenderer class that took care of writing html. This class could have subclasses for html4 and html5.
So we could write:
Foswiki::renderer->anchor($name)
--
ArthurClemens - 02 Sep 2011
Absolutely. I have some ideas for this (build a WikiText DOM compatible with
CPAN:XML::XPathEngine, but who knows if this will be faster/slower than our existing regex spaghetti), but it requires drastically overhauling Foswiki::Render and Foswiki::Form.
So perhaps it would be worthwhile, as a first step, to make Foswiki::Render pluggable.
--
PaulHarvey - 04 Sep 2011
Having said that, would be nice if we could work towoards polyglot output (both XHTML and HTML5 valid).
--
PaulHarvey - 04 Sep 2011
Actually, named anchors are not a good example because the substitute with element IDs are already supported cross browser. Update: and implemented in
Item11389.
Another candidate is meta data, currently in
meta
tags. In html5 this is no longer allowed: the meta fields are restricted. With a custom tag, the validator will give an error like:
Bad value foswiki.WIKIUSERNAME for attribute name on element meta: Keyword foswiki.wikiusername is not registered.
Is meta data used outside of javascript? Otherwise we could as well write it to head in a script tag using JSON.
--
ArthurClemens - 25 Dec 2011
can't we use the template system to do this? hardcoded or code based html generation is a problem pretty much everywhere
--
SvenDowideit - 26 Dec 2011
HTML5 is default nowadays
--
MichaelDaum - 05 Nov 2024