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.
@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âŚ
@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 .
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)
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âŚ)
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)
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.
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.
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
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.)