annotate runtime/syntax/dtd.vim @ 917:94164a5b0626 v7.0.043

updated for version 7.0-043
author vimboss
date Tue, 08 Aug 2006 14:29:16 +0000
parents 1cdd2661f34c
children dd6c2497c997
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim syntax file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: DTD (Document Type Definition for XML)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Johannes Zellner <johannes@zellner.org>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " Author and previous maintainer:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " Daniel Amyot <damyot@site.uottawa.ca>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Last Change: Tue, 27 Apr 2004 14:54:59 CEST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " Filenames: *.dtd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " REFERENCES:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " http://www.w3.org/TR/html40/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 " http://www.w3.org/TR/NOTE-html-970421
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " TODO:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 " - improve synchronizing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 syntax clear
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 let __dtd_cpo_save__ = &cpo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 set cpo&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 if exists("b:current_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 let s:dtd_cpo_save = &cpo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 set cpo&vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 if !exists("dtd_ignore_case")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " I prefer having the case takes into consideration.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 syn case match
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 syn case ignore
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 " the following line makes the opening <! and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 " closing > highlighted using 'dtdFunction'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 " PROVIDES: @dtdTagHook
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 syn region dtdTag matchgroup=dtdFunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 \ start=+<!+ end=+>+ matchgroup=NONE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 \ contains=dtdTag,dtdTagName,dtdError,dtdComment,dtdString,dtdAttrType,dtdAttrDef,dtdEnum,dtdParamEntityInst,dtdParamEntityDecl,dtdCard,@dtdTagHook
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 if !exists("dtd_no_tag_errors")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 " mark everything as an error which starts with a <!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 " and is not overridden later. If this is annoying,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 " it can be switched off by setting the variable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 " dtd_no_tag_errors.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 syn region dtdError contained start=+<!+lc=2 end=+>+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 " if this is a html like comment hightlight also
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 " the opening <! and the closing > as Comment.
826
1cdd2661f34c updated for version 7.0d01
vimboss
parents: 7
diff changeset
55 syn region dtdComment start=+<![ \t]*--+ end=+-->+ contains=dtdTodo,@Spell
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 " proper DTD comment
826
1cdd2661f34c updated for version 7.0d01
vimboss
parents: 7
diff changeset
59 syn region dtdComment contained start=+--+ end=+--+ contains=dtdTodo,@Spell
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 " Start tags (keywords). This is contained in dtdFunction.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " Note that everything not contained here will be marked
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 " as error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 syn match dtdTagName contained +<!\(ATTLIST\|DOCTYPE\|ELEMENT\|ENTITY\|NOTATION\|SHORTREF\|USEMAP\|\[\)+lc=2,hs=s+2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 " wildcards and operators
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 syn match dtdCard contained "|"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 syn match dtdCard contained ","
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 " evenutally overridden by dtdEntity
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 syn match dtdCard contained "&"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 syn match dtdCard contained "?"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 syn match dtdCard contained "\*"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 syn match dtdCard contained "+"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 " ...and finally, special cases.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 syn match dtdCard "ANY"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 syn match dtdCard "EMPTY"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 if !exists("dtd_no_param_entities")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 " highlight parameter entity declarations
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 " and instances. Note that the closing `;'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 " is optional.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 " instances
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 syn region dtdParamEntityInst oneline matchgroup=dtdParamEntityPunct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 \ start="%[-_a-zA-Z0-9.]\+"he=s+1,rs=s+1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 \ skip=+[-_a-zA-Z0-9.]+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 \ end=";\|\>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 \ matchgroup=NONE contains=dtdParamEntityPunct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 syn match dtdParamEntityPunct contained "\."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 " declarations
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 " syn region dtdParamEntityDecl oneline matchgroup=dtdParamEntityDPunct start=+<!ENTITY % +lc=8 skip=+[-_a-zA-Z0-9.]+ matchgroup=NONE end="\>" contains=dtdParamEntityDPunct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 syn match dtdParamEntityDecl +<!ENTITY % [-_a-zA-Z0-9.]*+lc=8 contains=dtdParamEntityDPunct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 syn match dtdParamEntityDPunct contained "%\|\."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 " &entities; compare with xml
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 syn match dtdEntity "&[^; \t]*;" contains=dtdEntityPunct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 syn match dtdEntityPunct contained "[&.;]"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 " Strings are between quotes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 syn region dtdString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=dtdAttrDef,dtdAttrType,dtdEnum,dtdParamEntityInst,dtdEntity,dtdCard
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 syn region dtdString start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=dtdAttrDef,dtdAttrType,dtdEnum,dtdParamEntityInst,dtdEntity,dtdCard
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 " Enumeration of elements or data between parenthesis
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 " PROVIDES: @dtdEnumHook
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 syn region dtdEnum matchgroup=dtdType start="(" end=")" matchgroup=NONE contains=dtdEnum,dtdParamEntityInst,dtdCard,@dtdEnumHook
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 "Attribute types
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 syn keyword dtdAttrType NMTOKEN ENTITIES NMTOKENS ID CDATA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 syn keyword dtdAttrType IDREF IDREFS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 " ENTITY has to treated special for not overriding <!ENTITY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 syn match dtdAttrType +[^!]\<ENTITY+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 "Attribute Definitions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 syn match dtdAttrDef "#REQUIRED"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 syn match dtdAttrDef "#IMPLIED"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 syn match dtdAttrDef "#FIXED"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 syn case match
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 " define some common keywords to mark TODO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 " and important sections inside comments.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 syn keyword dtdTodo contained TODO FIXME XXX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 syn sync lines=250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 " Define the default highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 " For version 5.7 and earlier: only when not done already
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 " For version 5.8 and later: only when an item doesn't have highlighting yet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 if version >= 508 || !exists("did_dtd_syn_inits")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 if version < 508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 let did_dtd_syn_inits = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 command -nargs=+ HiLink hi link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 command -nargs=+ HiLink hi def link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 " The default highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 HiLink dtdFunction Function
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 HiLink dtdTag Normal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 HiLink dtdType Type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 HiLink dtdAttrType dtdType
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 HiLink dtdAttrDef dtdType
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 HiLink dtdConstant Constant
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 HiLink dtdString dtdConstant
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 HiLink dtdEnum dtdConstant
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 HiLink dtdCard dtdFunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 HiLink dtdEntity Statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 HiLink dtdEntityPunct dtdType
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 HiLink dtdParamEntityInst dtdConstant
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 HiLink dtdParamEntityPunct dtdType
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 HiLink dtdParamEntityDecl dtdType
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 HiLink dtdParamEntityDPunct dtdComment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 HiLink dtdComment Comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 HiLink dtdTagName Statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 HiLink dtdError Error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 HiLink dtdTodo Todo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 delcommand HiLink
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 let &cpo = __dtd_cpo_save__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 unlet __dtd_cpo_save__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 let &cpo = s:dtd_cpo_save
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 unlet s:dtd_cpo_save
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 let b:current_syntax = "dtd"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 " vim: ts=8