Re: [textadept] XHTML

From: Robert <ro....at.web.de>
Date: Fri, 26 Aug 2011 11:12:58 +0200

On Wed, Aug 24, 2011 at 8:57 PM, Robert <ro....at.web.de> wrote:
> On Wed, Aug 24, 2011 at 8:54 PM, Robert <ro....at.web.de> wrote:
>> On Wed, Aug 24, 2011 at 8:41 PM, mitchell <c....at.caladbolg.net> wrote:
>>> Brian,
>>>
>>> On Tue, 23 Aug 2011, Brian Schott wrote:
>>>
>>>> I think that these files are still being identified as XML due to the
>>>> pattern that checks for "<?xml" at the beginning of the file. My
>>>> reading of mime_types.lua seems to confirm that patterns are checked
>>>> before file extensions. Can anyone else reproduce this?
>>>
>>> Yeah, file extension is the last check because patterns or sh bangs are more
>>> accurate for detecting file types than just extension. Obviously we have a
>>> corner case here. I'm not sure how I want to proceed.
>>>
>>> mitchell
>>>
>>
>> Xhtml wants to be proper xml, so treat as such ;-)
>> As a workaround one could check for the occurrence of, for example
>> "<html>" in the file during set_buffer_properties of an xml module and
>> then switch the lexer if a tag is found. I used something similar to
>> switch from files with ".html" extension to the django lexer.
>>
>> Robert
>>
>
> Found the snippet:
>
> function set_buffer_properties()
>  local text = buffer:get_text()
>  if text:match('{%%') then
>    buffer:set_lexer('django')
>  end
> end
>
> or something like
>
> function set_buffer_properties()
>  local text = buffer:get_text()
>  if text:match('<html>') then
>    buffer:set_lexer('hypertext')
>  end
> end
>

Even simpler probably to just check here again, if the suffix is .html.

Robert
Received on Fri 26 Aug 2011 - 05:12:58 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:17:14 EST