From d2bf30bbdd63f8445719b001c0e0f7999d631062 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Fri, 10 Jul 2009 04:19:51 +0000 Subject: [PATCH] Experimentally enable HTML 5 doctype Per wikitech-l discussion. This also removes a tag that was completely pointless, but theoretically required by XHTML 1, yet causes the HTML 5 validator to complain. Together with a few other recent commits, this should cause at least Special:BlankPage to validate as HTML 5. Real pages may still have some invalid markup that should be fixed -- in a large majority of cases, markup that was poor practice in XHTML as well. (The Wikimedia copyright icon needs to have border="0" removed for everything to validate 100% on Wikipedia.) By Brion's request, this is still behind a config option, and can be disabled with $wgHtml5 = false;. I expect we'll be able to remove that option in the near future, once everyone is satisfied that changing two lines of HTML output that all browsers have demonstrably ignored since the Paleolithic won't cause all Wikipedia users' computers to undergo a spontaneous uncontrolled fission reaction or something. --- includes/DefaultSettings.php | 8 ++++++++ includes/OutputPage.php | 14 ++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 0b499bf809..8e1bbb1f18 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -874,6 +874,14 @@ $wgDocType = '-//W3C//DTD XHTML 1.0 Transitional//EN'; $wgDTD = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'; $wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml'; +/** + * Temporary setting to disable HTML 5 for the unlikely event that it causes + * everything to blow up. If all goes well, should be removed (and forced + * true) well before it ever makes it into a release. If set to false, go back + * to serving an XHTML 1.0 Transitional doctype (per $wgDocType et al. above). + */ +$wgHtml5 = true; + /** * Permit other namespaces in addition to the w3.org default. * Use the prefix for the key and the namespace for the value. For diff --git a/includes/OutputPage.php b/includes/OutputPage.php index a05867d6f5..3eabf63dfc 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1547,7 +1547,7 @@ class OutputPage { public function headElement( Skin $sk ) { global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType; global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces; - global $wgContLang, $wgUseTrackbacks, $wgStyleVersion; + global $wgContLang, $wgUseTrackbacks, $wgStyleVersion, $wgHtml5; $this->addMeta( "http:Content-Type", "$wgMimeType; charset={$wgOutputEncoding}" ); if ( $sk->commonPrintStylesheet() ) { @@ -1561,7 +1561,11 @@ class OutputPage { $ret .= "\n"; } - $ret .= "\n"; + if ( $wgHtml5 ) { + $ret .= ''; + } else { + $ret .= "\n"; + } if ( '' == $this->getHTMLTitle() ) { $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() )); @@ -1592,7 +1596,7 @@ class OutputPage { } protected function addDefaultMeta() { - global $wgVersion; + global $wgVersion, $wgHtml5; static $called = false; if ( $called ) { @@ -1601,7 +1605,9 @@ class OutputPage { } $called = true; - $this->addMeta( 'http:Content-Style-Type', 'text/css' ); //bug 15835 + if ( !$wgHtml5 ) { + $this->addMeta( 'http:Content-Style-Type', 'text/css' ); //bug 15835 + } $this->addMeta( 'generator', "MediaWiki $wgVersion" ); $p = "{$this->mIndexPolicy},{$this->mFollowPolicy}"; -- 2.20.1