On 30/05/09 02:35, Cesar Romani wrote:
>
> I'm using vim 7.2.184 on Windows XP.
> If I load a html file without extension, let's say "test"
>
> <?xml version="1.0" encoding="UTF-8"?>
> <html>
> <head>
> <title>Test</title>
> </head>
> <body>
> blah blah blah
> </body>
> </html>
>
> matchit doesn't work on it, notwithstanding the fact that I set
> set ft=html
>
> If I rename the file to "test.html", it works fine.
> How can I enable matchit on "test"?
>
> Many thanks in advance,
> Cesar
Now that you've got your answer, let me chime in: the above file is
plainly _wrong_ as HTML.
It could be XHTML, but in that case it would need an XHTML doctype line
immediately after the <?xml header, and I don't know what such a doctype
should be. However, XHTML syntax is much stricter than HTML syntax, and
in particular:
- There are no optionally-closed tags: all optionally-closed tags become
mandatorily-closed (such as <p>blah blah</p>, <li>blah blah</li> etc.
- Never-closed tags become self-closed (e.g. <hr />, <br />; see also
the <meta> tag below)
- All tag names and attribute names are lowercase
- All attribute values must be quoted (e.g. <div align="center">, not
<div align=center>
- Unlike in XML and general SGML, a paired tag which happens to be empty
must still be paired and not self-closed, e.g. <a name="some_stuff"
id="some_stuff"></a>, NOT a single <a with /> at the end and no </a>.
OR it could be HTML, but an HTML file MUST NOT include an <?xml line; it
SHOULD start with an HTML doctype; the following works well for me, but
there are other possibilities (I put it linewise in Vim's register "d (D
for Doctype is easy to remember), and the |viminfo| file remembers it
for me):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
For an HTML file, if you aren't master of the HTTP headers which tell
the browser the MIME type, there are still two ways (not exclusive of
each other) to say that it is encoded in UTF-8, without using an <?xml
header which is forbidden with this kind of file:
(a) use a UTF-8 BOM by using ":setlocal bomb fenc=utf-8" in Vim. Every
browser should accept that and, as a minimum, look past the BOM for the
doctype line.
(b) Include in the <head> part the following line:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
The above line is written in "XHTML style" but "HTML browsers" ought to
accept it too, even in a "purely" HTML file. Or you could use the
following (which is now deprecated), but not in an XHTML page:
<META HTTP-EQUIV=Content-Type CONTENT="text/html; charset=utf-8">
Notice that the CONTENT attribute value MUST still be quoted because it
includes a space.
Best regards,
Tony.
--
I think pop music has done more for oral intercourse than anything else
that has ever happened, and vice versa.
-- Frank Zappa
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---