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