3 " Maintainer: Johannes Zellner <johannes@zellner.org>
4 " Author and previous maintainer:
5 " Paul Siegmann <pauls@euronet.nl>
7 " URL: http://www.zellner.org/vim/syntax/xml.vim
8 " Last Change: Dec 09 1999
9 " $Id: xml.vim,v 1.1.1.1 2001/06/07 21:35:13 corinna Exp $
12 " - This syntax file will highlight xml tags and arguments.
13 " The original version was derived by Paul Siegmann from
14 " Claudio Fleiner's html.vim.
16 " - suggestions and patches by:
17 " Rafael Garcia-Suarez
20 " http://www.w3.org/TR/1998/REC-xml-19980210
21 " http://www.w3.org/XML/1998/06/xmlspec-report-19980910.htm
24 " For version 5.x: Clear all syntax items
25 " For version 6.x: Quit when a syntax file was already loaded
28 elseif exists("b:current_syntax")
32 " Following items are case-sensitive
33 " Case-insensitive rules can be specified by 'syn case ignore' later
36 " mark illegal characters
37 syn match xmlError "[<>&]"
41 syn match xmlSpecial contained "\\\d\d\d\|\\."
42 syn region xmlString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=xmlSpecial
43 syn region xmlString contained start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=xmlSpecial
44 syn region xmlEndTag start=+</+ end=+>+ contains=xmlTagError
45 syn region xmlTag start=+<[^/]+ end=+>+ contains=xmlString,xmlTagError
46 syn match xmlTagError contained "[^>]<"ms=s+1
49 syn match xmlSpecialChar "&[^;]*;"
51 syn keyword xmlTodo contained TODO FIXME XXX
53 " The real comments (this implements the comments as defined by xml,
54 " but not all xml pages actually conform to it. Errors are flagged.
55 syn region xmlComment start=+<!+ end=+>+ contains=xmlCommentPart,xmlString,xmlCommentError,xmlTodo
56 syn match xmlCommentError contained "[^><!]"
57 syn region xmlCommentPart contained start=+--+ end=+--+
59 " DTD -- we use dtd.vim here
60 syn region xmlDocType matchgroup=xmlDocTypeDecl start="<!DOCTYPE"he=s+2,rs=s+2 end=">" contains=xmlDocTypeKeyword,xmlInlineDTD,xmlString
61 syn keyword xmlDocTypeKeyword contained DOCTYPE PUBLIC SYSTEM
62 syn region xmlInlineDTD contained start="\[" end="]" contains=@xmlDTD
63 syn include @xmlDTD <sfile>:p:h/dtd.vim
65 " Processing instructions
66 " This allows "?>" inside strings -- good idea?
67 syn region xmlProcessing matchgroup=xmlProcessingDelim start="<?" end="?>" contains=xmlString
70 syn region xmlCdata matchgroup=xmlCdataDecl start="<!\[CDATA\[" keepend end="]]>"
72 " synchronizing (does not always work if a comment includes legal
73 " xml tags, but doing it right would mean to always start
74 " at the first line, which is too slow)
75 syn sync match xmlHighlight groupthere NONE "<[/a-zA-Z]"
76 syn sync match xmlHighlightSkip "^.*['\"].*$"
79 " Define the default highlighting.
80 " For version 5.7 and earlier: only when not done already
81 " For version 5.8 and later: only when an item doesn't have highlighting yet
82 if version >= 508 || !exists("did_xml_syntax_inits")
84 let did_xml_syntax_inits = 1
85 command -nargs=+ HiLink hi link <args>
87 command -nargs=+ HiLink hi def link <args>
91 HiLink xmlTag Function
92 HiLink xmlEndTag Identifier
93 HiLink xmlSpecial Special
94 HiLink xmlSpecialChar Special
95 HiLink xmlString String
96 HiLink xmlComment Comment
97 HiLink xmlCommentPart Comment
98 HiLink xmlCommentError xmlError
99 HiLink xmlTagError xmlError
100 HiLink xmlError Error
102 HiLink xmlProcessingDelim Comment
103 HiLink xmlProcessing Type
104 HiLink xmlCdata Normal
105 HiLink xmlCdataDecl String
106 HiLink xmlDocType Normal
107 HiLink xmlDocTypeDecl Function
108 HiLink xmlDocTypeKeyword Statement
109 HiLink xmlInlineDTD Function
114 let b:current_syntax = "xml"