2 " Language: DTD (Document Type Definition for XML)
3 " Maintainer: Johannes Zellner <johannes@zellner.org>
4 " Author and previous maintainer:
5 " Daniel Amyot <damyot@site.uottawa.ca>
6 " Last Change: Tue, 27 Apr 2004 14:54:59 CEST
10 " http://www.w3.org/TR/html40/
11 " http://www.w3.org/TR/NOTE-html-970421
14 " - improve synchronizing.
18 let __dtd_cpo_save__ = &cpo
21 if exists("b:current_syntax")
24 let s:dtd_cpo_save = &cpo
28 if !exists("dtd_ignore_case")
29 " I prefer having the case takes into consideration.
36 " the following line makes the opening <! and
37 " closing > highlighted using 'dtdFunction'.
39 " PROVIDES: @dtdTagHook
41 syn region dtdTag matchgroup=dtdFunction
42 \ start=+<!+ end=+>+ matchgroup=NONE
43 \ contains=dtdTag,dtdTagName,dtdError,dtdComment,dtdString,dtdAttrType,dtdAttrDef,dtdEnum,dtdParamEntityInst,dtdParamEntityDecl,dtdCard,@dtdTagHook
45 if !exists("dtd_no_tag_errors")
46 " mark everything as an error which starts with a <!
47 " and is not overridden later. If this is annoying,
48 " it can be switched off by setting the variable
50 syn region dtdError contained start=+<!+lc=2 end=+>+
53 " if this is a html like comment hightlight also
54 " the opening <! and the closing > as Comment.
55 syn region dtdComment start=+<![ \t]*--+ end=+-->+ contains=dtdTodo,@Spell
59 syn region dtdComment contained start=+--+ end=+--+ contains=dtdTodo,@Spell
62 " Start tags (keywords). This is contained in dtdFunction.
63 " Note that everything not contained here will be marked
65 syn match dtdTagName contained +<!\(ATTLIST\|DOCTYPE\|ELEMENT\|ENTITY\|NOTATION\|SHORTREF\|USEMAP\|\[\)+lc=2,hs=s+2
68 " wildcards and operators
69 syn match dtdCard contained "|"
70 syn match dtdCard contained ","
71 " evenutally overridden by dtdEntity
72 syn match dtdCard contained "&"
73 syn match dtdCard contained "?"
74 syn match dtdCard contained "\*"
75 syn match dtdCard contained "+"
77 " ...and finally, special cases.
78 syn match dtdCard "ANY"
79 syn match dtdCard "EMPTY"
81 if !exists("dtd_no_param_entities")
83 " highlight parameter entity declarations
84 " and instances. Note that the closing `;'
88 syn region dtdParamEntityInst oneline matchgroup=dtdParamEntityPunct
89 \ start="%[-_a-zA-Z0-9.]\+"he=s+1,rs=s+1
90 \ skip=+[-_a-zA-Z0-9.]+
92 \ matchgroup=NONE contains=dtdParamEntityPunct
93 syn match dtdParamEntityPunct contained "\."
96 " syn region dtdParamEntityDecl oneline matchgroup=dtdParamEntityDPunct start=+<!ENTITY % +lc=8 skip=+[-_a-zA-Z0-9.]+ matchgroup=NONE end="\>" contains=dtdParamEntityDPunct
97 syn match dtdParamEntityDecl +<!ENTITY % [-_a-zA-Z0-9.]*+lc=8 contains=dtdParamEntityDPunct
98 syn match dtdParamEntityDPunct contained "%\|\."
102 " &entities; compare with xml
103 syn match dtdEntity "&[^; \t]*;" contains=dtdEntityPunct
104 syn match dtdEntityPunct contained "[&.;]"
106 " Strings are between quotes
107 syn region dtdString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=dtdAttrDef,dtdAttrType,dtdEnum,dtdParamEntityInst,dtdEntity,dtdCard
108 syn region dtdString start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=dtdAttrDef,dtdAttrType,dtdEnum,dtdParamEntityInst,dtdEntity,dtdCard
110 " Enumeration of elements or data between parenthesis
112 " PROVIDES: @dtdEnumHook
114 syn region dtdEnum matchgroup=dtdType start="(" end=")" matchgroup=NONE contains=dtdEnum,dtdParamEntityInst,dtdCard,@dtdEnumHook
117 syn keyword dtdAttrType NMTOKEN ENTITIES NMTOKENS ID CDATA
118 syn keyword dtdAttrType IDREF IDREFS
119 " ENTITY has to treated special for not overriding <!ENTITY
120 syn match dtdAttrType +[^!]\<ENTITY+
122 "Attribute Definitions
123 syn match dtdAttrDef "#REQUIRED"
124 syn match dtdAttrDef "#IMPLIED"
125 syn match dtdAttrDef "#FIXED"
128 " define some common keywords to mark TODO
129 " and important sections inside comments.
130 syn keyword dtdTodo contained TODO FIXME XXX
134 " Define the default highlighting.
135 " For version 5.7 and earlier: only when not done already
136 " For version 5.8 and later: only when an item doesn't have highlighting yet
137 if version >= 508 || !exists("did_dtd_syn_inits")
139 let did_dtd_syn_inits = 1
140 command -nargs=+ HiLink hi link <args>
142 command -nargs=+ HiLink hi def link <args>
145 " The default highlighting.
146 HiLink dtdFunction Function
149 HiLink dtdAttrType dtdType
150 HiLink dtdAttrDef dtdType
151 HiLink dtdConstant Constant
152 HiLink dtdString dtdConstant
153 HiLink dtdEnum dtdConstant
154 HiLink dtdCard dtdFunction
156 HiLink dtdEntity Statement
157 HiLink dtdEntityPunct dtdType
158 HiLink dtdParamEntityInst dtdConstant
159 HiLink dtdParamEntityPunct dtdType
160 HiLink dtdParamEntityDecl dtdType
161 HiLink dtdParamEntityDPunct dtdComment
163 HiLink dtdComment Comment
164 HiLink dtdTagName Statement
165 HiLink dtdError Error
172 let &cpo = __dtd_cpo_save__
173 unlet __dtd_cpo_save__
175 let &cpo = s:dtd_cpo_save
179 let b:current_syntax = "dtd"