How to get Komodo to recognize unclosed XHTML5 tags as errors

I’m editing an XHTML5 document. I enter <br>, but Komodo doesn’t tell me that the <br> tag should be closed, that is, <br/>. This is obviously an XML file, with an xhtml extension and an XML declaration. Why doesn’t Komodo catch these errors?

<br> is valid in HTML5, you no longer need to close it the way you did in HTML4 and before.

Reference: http://www.w3.org/TR/html5/text-level-semantics.html#the-br-element

You didn’t read closely what I said. A <br> is valid in HTML5, as it was valid in HTML4 and so on. But it is not valid XHTML5, which is the syntax of HTML5 that adheres to XML syntax rules:

http://www.w3.org/TR/html5/introduction.html#html-vs-xhtml

As I mentioned, my document is clearly XHTML. It has an xhtml extension. It has an XML declaration:

<?xml version="1.0" encoding="utf-8"?>

In an XHTML5 document, as in all XML documents, it is illegal to have an opening element tag with no closing element tag (or be a single tag with closing slash).

Where/how can I configure Komodo to flag this invalid tag representation in my XHTML5 document?

Hi Garret,

Check out Prefs > Syntax Checking, under HTML5 you can set the Error level for HTML Tidy to “Errors and warnings”, this will then give warnings about
tags. You can control the way HTML Tidy checks your document by passing in a custom configuration file, here are the possible configuration values: http://tidy.sourceforge.net/docs/quickref.html

…but you already told me to turn off HTML Tidy because it didn’t recognize HTML5 tags. :frowning:

Besides, this is only a frail workaround.

Does your XML syntax checker recognize that <br> is invalid if there is no ending tag? (It should or it isn’t a good XML syntax checker.) Your editor should note that I have an .xhtml file with an XML declaration, and should provide the same strictness checking as it does with XML files in that scenario. I shouldn’t have to muck around with some HTML tidy setting.

…or at least I should be able to turn on some setting that associates strict XML checking with the .xhtml extension (although that should be configured out of the box).

We use HTML Tidy, which does indeed detect that. The only problem seems to be that our version is slightly out of date so it doesn’t recognize certain new element types.

Note it seems you could add support for “custom” elements yourself in HTML Tidy, that would work around both your problems:

http://tidy.sourceforge.net/docs/quickref.html#new-empty-tags

Why don’t we just have an option to run tidy in XML mode? And why can’t we just specify that this is turned on by default for .xhtml files? And why couldn’t this be the default in Komodo, because .xhtml isn’t used for non-XML HTML files.

I guess it confuses my why I have to muck around under the hood for something that should be just turnkey and go. If I load an .xhtml file in Firefox, and I don’t have to go into the configuration and turn on XML strict checking—it does it automatically.

Do I need to join the GitHub project and implement something like this, is that what you’re saying? I want everyone to be helped by my work.

You shouldn’t have to, HTML Tidy should be able to do all the things that you are asking for, however because we are running an older version this is not working as it should. Once the bug I opened is fixed your issues should disappear.

All my suggestions here are workarounds for this “bug”, they are not the intended user experience but they are the best I can offer you with the current stable version of Komodo.

Ah, I see. OK, I look forward to the bug fix!!

I think I’ve already resolved myself that eventually I’ll have to submit some code to GitHub anyway… :wink:

I look forward to it, contributors are more than welcome :slight_smile:

(Like I really needed more work. hahaha Well, all least you are receptive, and that I really, really appreciate.)

1 Like

I’m unclear if you mean that the new HTML Tidy will automatically turn on XML mode when it sees the XML declaration and/or if it sees an .xhtml extension.

But do you have an estimate on when that bug (I suppose you mean #944) will be addressed?

To the best of my knowledge Tidy auto detects this from the doctype.

I do not have a precise estimate to give you unfortunately, Komodo 9.3.3 would likely be releasing in about 2 months, but that’s very rough and I cannot commit to that. Generally we release maintenance releases when we feel we’ve fixed a number of bugs that will significantly improve the experience of Komodo developers.

Any way I could update the version of HTML Tidy myself? Could I distribute a config file to my translators?

Perhaps if this were done as a plugin it could be revved separately from the entire distribution and wouldn’t have to be held up?

Normally stuff like this is fairly simple, however in this case htmltidy is ran as a Perl module and so it’s a bit more challenging to just drop in a new version. It can be done, but if you’d want to do it with an addon it would likely involve overriding our syntax checker or registering a new one, which is not super easy if you are not familiar with the codebase.