On Tue, 16 Mar 2010, Benjamin R. Haskell wrote:
> Three things that help it work:
>
> 1. [...]
>
> 2. It does NOT include the final closing '>' of the closing tag.
> (Otherwise, the normal XML highlighting is seen as matching sooner,
> since this pattern is using the lookbehind to match the start tag. (I
> think...))
...Nope -- was a problem with the capture group in the lookbehind. (See
other thread if interested.)
> 3. [...]
Attached is an updated version with better CDATA-section handling.
Unfortunately, it seems the two-line lookbehind limitation prevents this
from working well for:
<sql:operator>
<![CDATA[
(sql here)
But the other CDATA cases are handled properly, and the CDATA markers
are now properly highlighted.
Still fun. :-)
--
Best,
Ben
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
function! s:NoCurrent()
if exists("b:current_syntax")
unlet b:current_syntax
endif
endfunction
" include XML syntax
runtime! syntax/xml.vim
call s:NoCurrent()
" include SQL syntax w/ ability to include it elsewhere
syntax include @sql syntax/sql.vim
call s:NoCurrent()
let b:current_syntax='jelly'
syn match sqlCdata
+\%(<\1\%(\_s\_[^>]*\)\{-}>\_s*<!\[CDATA\[\_s*\)\@<=\_.\{-}\%(\_s*\]\]>\_s*<\/\(sql:\w\+\)\)\...@=+
contai...@sql
syn match sqlRegion
+\%(<\1\%(\_s\_[^>]*\)\{-}>\%(\_s*<!\[CDATA\[\)\...@!\)\@<=\_.\{-}\%(<\/\(sql:\w\+\)\)\...@=+
contai...@sql
syn cluster xmlCdataHook add=sqlCdata
syn cluster xmlRegionHook add=sqlRegion
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<sql:one>select * from foo;</sql:one>
<sql:two att="val">select * from foo;</sql:two>
<sql:three att="val"><![CDATA[ /* this section works without linebreak */
select * from foo;
]]></sql:three>
<sql:four att="val">
<![CDATA[
select * from foo; /* this section won't work */
]]>
</sql:four>
<sql:five><![CDATA[select * from foo;]]></sql:five>
<asdf><![CDATA[blahblah]]></asdf>
<nonsql>select * from foo;</nonsql>
<ns:other>select * from foo;</ns:other>
</xml>