Enable HTML syntax checking?

I’ve mentioned before that I really like how Komodo detects inconsistent line endings and puts little squiggles under the offending lines. After I fix the error, I get a little check mark in the bottom, right-hand corner. Excellent.

I’m testing editing of XHTML5. The editor is very responsive. The HTML tag and attribute suggestions are smooth, and the auto-tag-closing functionality is slick. I like it.

But I don’t understand the syntax checking. I enter the following line:

<p>This is a <code>good test.</p>

I expect to get some sort of error because there is no closing </code> tag. But the syntax checker does not complain. The little checkmark remains in the status window, as if everything is code.

I installed the KLint extension, but I didn’t see any difference.

How do I enable HTML syntax checking?

@garretwilson by default komodo only shows errors only, to enable it to show warnings you go to your preferences > Syntax Checking. Select the html language you got here a select “error level:” if you set this one to" errors and warnings" you will get lint results on above errors

Unfortunately I don’t have that option, as I had to turn off HTML Tidy because somehow Komodo was using a really out of date version. More unfortunately is that @nathanr doesn’t know when he’ll be able to fix this bug (Issue #944). So one bug is having a cascading effect with other issues… :frowning:

There’s a milestone for that. I guess it will be fixed in 9.3.3

That’s two releases away. :frowning:

I guess that 9.3.2 will be released very soon, I don’t see any issues opened for 9.3.2 milestone and new issues are in 9.3.3 milestone.

That’s right, 9.3.2 is being released this week.

1 Like

@garretwilson added a work around to the issue on github, you can add a config file to komodo with the missing html5 elements, this will clear the lint errors on the missing html5 elements so you can use html tidy :grinning:.

You asked this question on the forum: Easy way to format XHTML5? so i created a xhtml file (new file from templates) and added the <figure> tag, but if you have warnings enabled you will get a warning on the <figure> element. “Warning <figure> is not approved by W3C”.
Did a quick google search, but there is no such thing as xhtml5, you’ve got xhtml and html5, xhtml is based on html 4 and that’s why you can’t use html5 elements in xhtml files. (You can read more about the relationship between xhtml and html5 here)

There is indeed. Go right to the HTML5 specification:

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

XHTML5 (or “XHTML 5” if you want to use the exact wording used by the W3C) is the XML serialization of HTML5. (Your information on XHTML is out of date—you’re talking about the old XHTML 1 that was then supposed to be modularized—I think maybe in XHTML 1.1.)

I have to be careful not to go off on one of my rants, but sometimes it irritates me to no end when I follow the latest specifications and use the best practices, and nobody’s tools work.

XML-based HTML5 is so much better than non-XML HTML5, because it provides a rigorous and unambiguous output parse tree. If I want to process these documents with an XML parser, I can. Everybody’s parsers have to match. I can ensure that my editors and translators don’t screw up the document, as the well-formedness rules of XML are quite clear. etc.

But (to use Atom Editor as an example, so as not to overly-criticize Komodo) I try to load an XHTML5 document into Atom and the Lint plugin (using HTMLHint) thinks my XML declaration is erroneous. The HTMLHint author tells me that he/she doesn’t support XML. The atom-beautify plugin leaves the XML declaration and indents the entire document. etc.

I will stop there. Yes, there is an XHTML5. I use it. Everything would work much better if everyone would use it. It’s not like XML is new or hard. (It is hard to Microsoft, of course—their browsers (at least a few years ago) didn’t even support application/xhtml+xml. I know because I created an entire web framework that had to check the user agent and change the MIME response type just for IE. But now I’m digressing on my digressions…)

Hi, @babobski. I saw that pop up somewhere—thanks, and I will investigate it. Cheers.

It doesn’t sound like that helps me very much—so if I go to a lot of trouble and create config files, it will merely reduce the errors to warnings?

Sorry for that one, there was noting showing up in my search results even related.
Still finding information on xhtml5 is hard.

Finding the correct way to set up your document for xhtml is tough.
Found this answer on how to use html 5 element with xhtml, if i use the code from this answer and you add the <figure> you will get no lint warnings or errors.

Even my search on witch doctype you should use was a struggle found out that for xhtml5 there are only 2 types of doctypes as can been seen here

Still a bit in the dark how to properly syntax your xhtml5 files, but if i use the template from stackoverflow i have no lint warnings. And if this doesn’t fix it, you can still keep the lint settings on “warnings only”, you will not have the lint errors on html5 elements that you had before. (better something than nothing)

Your entire response is confusing me.

There is no DTD for HTML5. There is no DTD for XHTML5. If an element is recognized in HTML5, it will be recognized in XHTML5. The <figure> element has been in HTML5 for ages. The <figure> element is valid HTML5. The <figure> element is valid XHTML5. What am I missing here?

An HTML5 validator should validate XHTML5 just fine for 99.9% of the cases. In fact it should be even easier, as XHTML5 is more well-formed than HTML5. (That’s why the response of the HTMLHint author that “XML is not supported by the plugin” was ludicrous.) Basically you simply have to make your HTML5 validator not freak out if you see an XML declaration on the first line… and then you’re done!

There is only one HTML5 doctype: <!DOCTYPE html>. All this other stuff you’re finding is either legacy or outdated draft stuff. An XHTML5 doctype looks just like an HTML5 doctype.

Even the answer to the StackOverflow question you mentioned makes it clear that all this XHTML 1.0 stuff and all this DTD stuff is outdated and doesn’t apply. XHTML5 is HTML5 that doesn’t cut corners. Lint it like you would HTML5, throw in the even-more-strict rules of XML (i.e. don’t allow <br> but require <br/>, both of which would be valid HTML5), and don’t freak out when you see an XML declaration like <?xml version="1.0" encoding="utf-8"?>. That’s pretty much it.

I’m confused about how this could be confusing.

It is not confusing, but there is not that much to find how to proper syntax you’re xhtml5 files.
I don’t work with xhtml so I’m not that familiar with xhtml5.

If i use the template from my previous answer and add the <figure> i get no lint errors or warnings,
if i type <br> i get the correct lint warning on the br tag “Warning: <br> element is empty or not closed”.
Only when i drop the <?xml version="1.0" encoding="utf-8"?> tag in the file, i get a warning on my html5 elements as described before.
So found someone with the same question “is this <?xml version="1.0" encoding="utf-8"?> still valid xhtml5”, discussion can be found here.
Also found another example how to set up your xhtml5 file, and here is also no reference to the <?xml version="1.0" encoding="utf-8"?> tag.
So maybe the lint warning is correct, that if you drop the <?xml version="1.0" encoding="utf-8"?> tag it falls-back to xhtml 1.0 with html 4 support, but I’m no xhtml5 expert

That part is what confuses me. Make sure the file is valid HTML5. Then make sure it is well-formed XML (which pretty much means making sure the linters give no warnings). Add an XML declaration. Then you have XHTML5. As a practical matter, it’s as simple as that.

You keep talking about errors and warnings you get when you do this or that. I suppose you’re talking about some specific linter or tidy program. I have no idea what is out there or what they do. I only know what the specifications say. If you want to know what the specifications say, read the specifications. I don’t know if the linter or a tidy authors read the specifications.

I do note however that Tidy has an -asxhtml option, which may be what we’re looking for.

So it sounds like some linter is saying that they think that <br> should really be <br/>, but that in HTML5 isn’t not an error. That’s true. In XHTML5, it would be an error, but I can live with a warning.

First of all <?xml ... is not a tag. It’s the XML declaration. It says “this is an XML document”. It’s completely separate from the tags. It has been a part of the XML specification from the beginning—around 1997, if my memory serves me correctly. And I can see how an article on XML would not even feel the need to mention it, simply because it’s a fundamental part of the XML specification and everyone who deals with XML should be familiar with it. Or maybe the author wasn’t an expert. I don’t know what to say about these articles, especially some you’re digging out that are five years old when some of this HTML5 stuff was still in flux.

XHTML5 is HTML5 that is also valid XML. It can have an XML declaration, which isn’t allowed in HTML5, but other than that an XHTML5 document should be a completely valid HTML5 document (without even any warnings!) 99% of the time. It’s really not harder than that.

I think part of the confusion here is that when I say “XHTML5” you think I’m talking about some old XHTML 1.0/1.1 standards that were complicated, clunky, had all sorts of confusing DTDs, and which never really got off the ground.

Instead of saying “XHTML5”, maybe I should say, “I’m making sure my HTML5 files are also valid XML files. Plus I’m putting an XML declaration at the front.” Maybe that would confuse you less, because when the W3C says “XHTML5”, that’s really all they mean (with a few tiny technicalities that we can ignore here).

So forget I said anything about XHTML. I’m making sure my HTML5 files can be parsed by an XML parser. That is all.

Sorry but this is incorrect, the XML declaration is optional

Note that in this example, the XML declaration is included. An XML
declaration like the one above is
not required in all XML documents. XHTML document authors are strongly
encouraged to use XML declarations in all their documents. Such a
declaration is required
when the character encoding of the document is other than the default
UTF-8 or
UTF-16.

The xhtml namespace makes it xhtml

The namespace for XHTML is
defined to be
http://www.w3.org/1999/xhtml

As we are here to help eachother out, you are searching for the input-xml option.
If you add input-xml: true to the config file, you will have the correct xhtml5 syntax checking.
It will reconize the html5 elements(and gives no warnings) and you get you’re xhtml lint results :smiley:

You’re right. I didn’t intend to imply that it was required, only that it is preferred—and I want to use one. I do believe the XML declaration is required in XML 1.1, though.

Ah, very good catch. I was getting tired yesterday and forgot all about that. But I think as far as at the HTML5 syntax checker is concerned the namespace declaration would be just another attribute.

Maybe. I’ll have to see how it behaves. I haven’t yet looked into to the tidy configuration options.

Anyway, to come full circle, if this config file you provided to Issue #944 solves my problems, then I greatly appreciate it! I haven’t had a chance to try it out. I’ll have to experiment with passing input-xml to it as well, if that is possible. I’ll let you know when I’ve tried it.

Hi, @babobski. I just wanted to drop back in and say thanks again for your Tidy config file. This will get me by for a little while. And I just confirmed that if I add the input-xml option, then it checks the well-formedness of the XML. So that addresses 80% of my needs for the moment.

Now we just need to have @nathanr upgrade HTML Tidy… and then have KomodoEdit detect the XML declaration and switch HTML Tidy in to input-xml mode automatically. (When I get time I’ll file a feature request.)

@garretwilson no problem, I’m glad it helped you out