Search

A new extension, "HTML5 Doctype" is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

Hi Stephen,

Thanks for this.

While this topic title is clear your description had me confused. This extension is simply the post-processed HTML5 doctype, right?

What your extension does is swap out the first n of lines from the processed XSLT and replace the Doctype/Charset with its HTML5 equivalent. There are a couple variations of this extension floating around.

You seem to suggest in your description, though, that you've continued work on Nick's post-processing extension. Nick's extension was not about the Doctype, perse, but was about post-processing the complete HTML and re-indent it properly (right Nick?).

I am asking because this remains a bit of a frustration as I've mentioned before.

Just to be sure: are not trying to tackle the 'indentation' problem but only replacing the default XHTML Doctype for the HTML5 one?

Yes, this is the post-processed HTML5 doctype. I've tried to clarify what this extension does by adding an explanation of the usage to the extension description.

I have been using this extension in production since the beginning of the year and it has been working quite well. You can see the nicely indented output on our site.

Thanks Stephen, that's what I meant. I have been using (a variation of) this extension too, for quite some time and it works well.

Basically you have Symphony output a XHTML page that get's transformed to HTML5 with the XHTML syntax. Because the output-method="xml" the indentation is preserved.

The issue remains that it's not possible to output properly indented HTML syntax at the moment. You kinda got my hopes up for a moment ;)

Are you referring to the closing of void elements, such as script and textarea?

If so, the proper closing of elements is being preserved because the XHTML doctype is being declared as well as output-method="xml".

See the script elements at the bottom of the page. They are being properly treated as void elements.

Nope, I was referring to the fact that this extension (still) requires a XHTML syntax (through output="xml"). It works fine that way (no issues with textarea or script, etc.) because you post-parse the default XHTML doctype and use output="xml"

The main issue re: void elements simply seems to be the Doctype: use output="xml" together with anything but the XHTML Doctype (such as the legacy-compat one) and you'll run into trouble.

These troubles are obviously worked around by post-parsing the Doctype so that's fine.

My current thinking, however, is that I'd prefer the output="html" output for HTML documents ;) And this breaks indentation. Which annoys me (OCD maybe, but then again: view-source should be important to any front-end developer :) )

In short: mostly ignore my ramblings. This is a nice <del>hack</del><ins>extension</ins> to allow us to use the HTML5 doctype with XHTML syntax and proper indenting.

HTML syntax and proper indenting remains impossible(?) but that has nothing to do with this extension and is probably only annoying for very picky people such as myself :)

Thanks for clarifying. I agree that this hack should not be necessary. But it seems it will need to be available as a possible workaround until the XSLT processor used by PHP is updated to properly output HTML5.

@bauhouse, has something happened to the Github repository? The extension shows as 1.2.5 (4 Nov) here at the Symphony extension page, but at the Github repo it only seems to have the commits for 1.2.4 (3 Mar).

I have the extension cloned in one Symphony install, which includes the 1.2.5 commits, and it tells me I'm ahead of the master branch:

$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 5 commits.

1.2.4 has:

$html_array = explode("n", $html, 5);

1.2.5 (including my repo which is "ahead") has:

$html_array = explode("n", $html, 15);

Umm. Yeah. Thanks for noting that.

Sorry about that, David (and anyone else who might have been using this repository). I actually lost track of which of my repositories was the master when I deleted the old repository and pushed it back up to GitHub (which is what Nick and I agreed to do to make me the official maintainer of the extension). So, the domain7 repository is no longer a fork. But I pushed from an old repo instead of the latest.

If anyone has any conflicts with pulling the git repository, you may have to force it:

git pull -f origin master

Note the -f flag to force the pull to overwrite the local history for the master branch.

My bad.

I just started to modify the extension to include the extension.meta.xml file, as recommended by the Migration Guide for Symphony 2.3. But I mistakenly added it to an older version of the repo.

Aha - thanks a lot for the info and -f tip.

Hi, i was trying to implement the facebook like in a project, so i needed to add the xmln namespace to html element. After research and thinking, i just modified the line 100 of the extension driver to include the code for the beloved IE

$html_doctype = preg_replace('/ xmlns="http://www.w3.org/1999/xhtml"| xml:lang="[^"]*"/', ' xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml"', $html_doctype);

This solved the issue, perhaps, as a suggestion, it could be cool to have an input field in the preferences to add namespaces.

Thank you for your great extension.

Rather than adding XML namespaces through this extension, I think you would be better off declaring them in your templates.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:og="http://ogp.me/ns#"
    xmlns:fb="http://www.facebook.com/2008/fbml">

<xsl:output method="xml"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    omit-xml-declaration="yes"
    encoding="UTF-8"
    indent="no" />

<xsl:template match="/">
    <html lang="en">
        <head>
            <title>HTML5 Doctype Extension</title>
        </head>
        <body>
            <h1>XML Namespace Example</h1>
        </body>
    </html>
</xsl:template>

</xsl:stylesheet>

I think you would be better off declaring them in your templates.

But wouldn't they get stripped out by the extension?

No. The extension only looks for specific strings and removes them. Line 100 of the extension driver looks specifically for the xmlns attribute with the value http://www.w3.org/1999/xhtml and any xml:lang attribute and removes them. Other namespace declarations are left untouched.

It is a hack. The reasons for the HTML5 Doctype hack are somewhat dubious, as it is really just a sign of throwing up our hands in defeat because XHTML seems to have been a failed experiment.

However, what I love about Symphony is its ability to stand in the middle of the rush to HTML5 and say that there was really no need for such a failure. If developers had followed the W3C recommendation to use XSLT as a templating language, we could still have machine readable code as a standard for HTML documents and be that much closer to a semantic, interoperable web.

I love clean, maintainable code that validates and is readable. XSLT helps me to create high quality, reusable, interoperable code. So I'm leaning more toward declaring my pages as XHTML as a badge of pride that I can live in both worlds: XHTML + HTML5. This approach is both backward compatible and future friendly, and declaring my pages as valid XHTML signals that the content can be consumed as valid XML. I'm not quite ready to throw up my hands, because XML works just fine for me.

HTML5 Doctype updated to version 1.3 on 2nd of January 2013

Well, not really. The extension was not updated, just moved.

I transfered the extension repository to the symphonists organization, since Domain7 will no longer be maintaining the extension. I left Domain7 as of December 31 to pursue such things as Symphony extension development and maintenance ;-)

(and possibly a book)

By the way, I am still trying to figure out how to get the symphonyextensions.com site to point to the new repository location. Apparently, GitHub has removed the ability to sign in to an organization account, so I will need to get admin access permissions to the domain7 GitHub organization for my account to be able to remove the extension.

This shouldn't be a problem, but...

@nickdunn, is there another way that we can do this?

You will have to get Nick to delete it I think, and then resubmit it again after a few hours from the symphonists account. I'm sure you're a member of Symphonists.

Good luck with the future Stephen!

@bauhouse thanks for merging my pullrequest!

is there a way to get html5 doctype into pages, without an extension?

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details