[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vim-dev
Subject:    Re: Proposing new "filetype"
From:       "Dan Sharp" <dwsharp () hotmail ! com>
Date:       2003-02-04 16:14:46
[Download RAW message or body]

>From: Benji Fisher <benji@member.AMS.org>
>
>Antoine J. Mechelynck wrote:
>
>[snip]
>>The problem is: how to detect?
>>- Maybe some users are still not doing any XHTML composing. For them,
>>nothing needs to change.
>>- I suppose some others have only XHTML files and no "old-style" HTML. For
>>them, it will be simply a matter of telling the system that all HTML 
>>should
>>default to XHTML. Maybe something like
>>     :au FileType html set ft=xhtml
>>would do the trick for them. Otherwise, it might be more "in style" with
>>existing filetype detection methods to create a user-definable variable
>>named, for instance, g:html_is_xhtml -- but at the cost of a slight change
>>to filetype.vim (the filetype detection script).
>>- Finally, there are people like me, maintaining some "older" files in 
>>HTML
>>and also "newer" ones in XHTML. I suppose that in this case, adding a
>>modeline
>>     <!-- vim: set ft=xhtml : -->
>>in the <HEAD> section of XHTML files would do the trick, overriding the
>>filetype detection mechanism.
>[snip]
>
>      I think it would be better to use the existing mechanism than to 
>override it.  Remember, $VIMRUNTIME/scripts.vim can be used to check the 
>first few lines.  Do XHTML files have the extension .html ?  If so, then 
>instead of deciding, in filetype.vim, that this file is HTML, it should be 
>left to scripts.vim, where the first few lines can be checked for the XML 
>header <?xml ... ?>.  If this is found, we can look for the DTD and assign 
>a filetype of XHTML if appropriate.

Checking for the XML header in a .html file would probably be easiest, but 
according to the XHTML 1.0 spec it is not required, so may not always be 
available.  The DOCTYPE definition is required, so scripts.vim could check 
for one of (or just XHTML inside of) the following three definitions to 
determine if a file is xhtml instead of plain html.

<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

On another note, Bram has added an xhtml ftplugin I created that loads both 
XML and HTML ftplugins, so that part is already done.  I just didn't realize 
at the time that xhtml wasn't yet a recognized filetype.  It is available at 
ftp://ftp.vim.org/pub/vim/runtime/ftplugin/xhtml.vim if you want to look at 
it.

Dan Sharp

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic