You are here: Foswiki>Tasks Web>Item11102 (05 Nov 2024, MichaelDaum)Edit Attach

Item11102: Conditionally render html as html5

pencil
Priority: Enhancement
Current State: No Action Required
Released In: n/a
Target Release: minor
Applies To: Engine
Component: FoswikiRender
Branches:
Reported By: ArthurClemens
Waiting For:
Last Change By: MichaelDaum
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 frown, sad smile

-- SvenDowideit - 26 Dec 2011

HTML5 is default nowadays

-- MichaelDaum - 05 Nov 2024
 

ItemTemplate edit

Summary Conditionally render html as html5
ReportedBy ArthurClemens
Codebase trunk
SVN Range
AppliesTo Engine
Component FoswikiRender
Priority Enhancement
CurrentState No Action Required
WaitingFor
Checkins
TargetRelease minor
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
masterCheckins
ItemBranchCheckins
Release02x01Checkins
Release02x00Checkins
Release01x01Checkins
Topic revision: r9 - 05 Nov 2024, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy