codekingpro/portable-devtools
114k
1" Vim syntax file2" Language: SGML3" Maintainer: Johannes Zellner <johannes@zellner.org>4" Last Change: Tue, 27 Apr 2004 15:05:21 CEST5" Filenames: *.sgml,*.sgm6" $Id: sgml.vim,v 1.1 2004/06/13 17:52:57 vimboss Exp $7 8" quit when a syntax file was already loaded9if exists("b:current_syntax")10 finish11endif12 13let s:sgml_cpo_save = &cpo14set cpo&vim15 16syn case match17 18" mark illegal characters19syn match sgmlError "[<&]"20 21 22" unicode numbers:23" provide different highlithing for unicode characters24" inside strings and in plain text (character data).25"26" EXAMPLE:27"28" \u4e8829"30syn match sgmlUnicodeNumberAttr +\\u\x\{4}+ contained contains=sgmlUnicodeSpecifierAttr31syn match sgmlUnicodeSpecifierAttr +\\u+ contained32syn match sgmlUnicodeNumberData +\\u\x\{4}+ contained contains=sgmlUnicodeSpecifierData33syn match sgmlUnicodeSpecifierData +\\u+ contained34 35 36" strings inside character data or comments37"38syn region sgmlString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=sgmlEntity,sgmlUnicodeNumberAttr display39syn region sgmlString contained start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=sgmlEntity,sgmlUnicodeNumberAttr display40 41" punctuation (within attributes) e.g. <tag sgml:foo.attribute ...>42" ^ ^43syn match sgmlAttribPunct +[:.]+ contained display44 45 46" no highlighting for sgmlEqual (sgmlEqual has no highlighting group)47syn match sgmlEqual +=+48 49 50" attribute, everything before the '='51"52" PROVIDES: @sgmlAttribHook53"54" EXAMPLE:55"56" <tag foo.attribute = "value">57" ^^^^^^^^^^^^^58"59syn match sgmlAttrib60 \ +[^-'"<]\@<=\<[a-zA-Z0-9.:]\+\>\([^'">]\@=\|$\)+61 \ contained62 \ contains=sgmlAttribPunct,@sgmlAttribHook63 \ display64 65 66" UNQUOTED value (not including the '=' -- sgmlEqual)67"68" PROVIDES: @sgmlValueHook69"70" EXAMPLE:71"72" <tag foo.attribute = value>73" ^^^^^74"75syn match sgmlValue76 \ +[^"' =/!?<>][^ =/!?<>]*+77 \ contained78 \ contains=sgmlEntity,sgmlUnicodeNumberAttr,@sgmlValueHook79 \ display80 81 82" QUOTED value (not including the '=' -- sgmlEqual)83"84" PROVIDES: @sgmlValueHook85"86" EXAMPLE:87"88" <tag foo.attribute = "value">89" ^^^^^^^90" <tag foo.attribute = 'value'>91" ^^^^^^^92"93syn region sgmlValue contained start=+"+ skip=+\\\\\|\\"+ end=+"+94 \ contains=sgmlEntity,sgmlUnicodeNumberAttr,@sgmlValueHook95syn region sgmlValue contained start=+'+ skip=+\\\\\|\\'+ end=+'+96 \ contains=sgmlEntity,sgmlUnicodeNumberAttr,@sgmlValueHook97 98 99" value, everything after (and including) the '='100" no highlighting!101"102" EXAMPLE:103"104" <tag foo.attribute = "value">105" ^^^^^^^^^106" <tag foo.attribute = value>107" ^^^^^^^108"109syn match sgmlEqualValue110 \ +=\s*[^ =/!?<>]\++111 \ contained112 \ contains=sgmlEqual,sgmlString,sgmlValue113 \ display114 115 116" start tag117" use matchgroup=sgmlTag to skip over the leading '<'118" see also sgmlEmptyTag below.119"120" PROVIDES: @sgmlTagHook121"122syn region sgmlTag123 \ matchgroup=sgmlTag start=+<[^ /!?"']\@=+124 \ matchgroup=sgmlTag end=+>+125 \ contained126 \ contains=sgmlError,sgmlAttrib,sgmlEqualValue,@sgmlTagHook127 128 129" tag content for empty tags. This is the same as sgmlTag130" above, except the `matchgroup=sgmlEndTag for highlighting131" the end '/>' differently.132"133" PROVIDES: @sgmlTagHook134"135syn region sgmlEmptyTag136 \ matchgroup=sgmlTag start=+<[^ /!?"']\@=+137 \ matchgroup=sgmlEndTag end=+/>+138 \ contained139 \ contains=sgmlError,sgmlAttrib,sgmlEqualValue,@sgmlTagHook140 141 142" end tag143" highlight everything but not the trailing '>' which144" was already highlighted by the containing sgmlRegion.145"146" PROVIDES: @sgmlTagHook147" (should we provide a separate @sgmlEndTagHook ?)148"149syn match sgmlEndTag150 \ +</[^ /!?>"']\+>+151 \ contained152 \ contains=@sgmlTagHook153 154 155" [-- SGML SPECIFIC --]156 157" SGML specific158" tag content for abbreviated regions159"160" PROVIDES: @sgmlTagHook161"162syn region sgmlAbbrTag163 \ matchgroup=sgmlTag start=+<[^ /!?"']\@=+164 \ matchgroup=sgmlTag end=+/+165 \ contained166 \ contains=sgmlError,sgmlAttrib,sgmlEqualValue,@sgmlTagHook167 168 169" SGML specific170" just highlight the trailing '/'171syn match sgmlAbbrEndTag +/+172 173 174" SGML specific175" abbreviated regions176"177" No highlighting, highlighting is done by contained elements.178"179" PROVIDES: @sgmlRegionHook180"181" EXAMPLE:182"183" <bold/Im Anfang war das Wort/184"185syn match sgmlAbbrRegion186 \ +<[^/!?>"']\+/\_[^/]\+/+187 \ contains=sgmlAbbrTag,sgmlAbbrEndTag,sgmlCdata,sgmlComment,sgmlEntity,sgmlUnicodeNumberData,@sgmlRegionHook188 189" [-- END OF SGML SPECIFIC --]190 191 192" real (non-empty) elements. We cannot do syntax folding193" as in xml, because end tags may be optional in sgml depending194" on the dtd.195" No highlighting, highlighting is done by contained elements.196"197" PROVIDES: @sgmlRegionHook198"199" EXAMPLE:200"201" <tag id="whoops">202" <!-- comment -->203" <another.tag></another.tag>204" <another.tag/>205" some data206" </tag>207"208" SGML specific:209" compared to xmlRegion:210" - removed folding211" - added a single '/'in the start pattern212"213syn region sgmlRegion214 \ start=+<\z([^ /!?>"']\+\)\(\(\_[^/>]*[^/!?]>\)\|>\)+215 \ end=+</\z1>+216 \ contains=sgmlTag,sgmlEndTag,sgmlCdata,@sgmlRegionCluster,sgmlComment,sgmlEntity,sgmlUnicodeNumberData,@sgmlRegionHook217 \ keepend218 \ extend219 220 221" empty tags. Just a container, no highlighting.222" Compare this with sgmlTag.223"224" EXAMPLE:225"226" <tag id="lola"/>227"228" TODO use sgmlEmptyTag instead of sgmlTag229syn match sgmlEmptyRegion230 \ +<[^ /!?>"']\(\_[^"'<>]\|"\_[^"]*"\|'\_[^']*'\)*/>+231 \ contains=sgmlEmptyTag232 233 234" cluster which contains the above two elements235syn cluster sgmlRegionCluster contains=sgmlRegion,sgmlEmptyRegion,sgmlAbbrRegion236 237 238" &entities; compare with dtd239syn match sgmlEntity "&[^; \t]*;" contains=sgmlEntityPunct240syn match sgmlEntityPunct contained "[&.;]"241 242 243" The real comments (this implements the comments as defined by sgml,244" but not all sgml pages actually conform to it. Errors are flagged.245syn region sgmlComment start=+<!+ end=+>+ contains=sgmlCommentPart,sgmlString,sgmlCommentError,sgmlTodo246syn keyword sgmlTodo contained TODO FIXME XXX display247syn match sgmlCommentError contained "[^><!]"248syn region sgmlCommentPart contained start=+--+ end=+--+249 250 251" CData sections252"253" PROVIDES: @sgmlCdataHook254"255syn region sgmlCdata256 \ start=+<!\[CDATA\[+257 \ end=+]]>+258 \ contains=sgmlCdataStart,sgmlCdataEnd,@sgmlCdataHook259 \ keepend260 \ extend261" using the following line instead leads to corrupt folding at CDATA regions262" syn match sgmlCdata +<!\[CDATA\[\_.\{-}]]>+ contains=sgmlCdataStart,sgmlCdataEnd,@sgmlCdataHook263syn match sgmlCdataStart +<!\[CDATA\[+ contained contains=sgmlCdataCdata264syn keyword sgmlCdataCdata CDATA contained265syn match sgmlCdataEnd +]]>+ contained266 267 268" Processing instructions269" This allows "?>" inside strings -- good idea?270syn region sgmlProcessing matchgroup=sgmlProcessingDelim start="<?" end="?>" contains=sgmlAttrib,sgmlEqualValue271 272 273" DTD -- we use dtd.vim here274syn region sgmlDocType matchgroup=sgmlDocTypeDecl start="\c<!DOCTYPE"he=s+2,rs=s+2 end=">" contains=sgmlDocTypeKeyword,sgmlInlineDTD,sgmlString275syn keyword sgmlDocTypeKeyword contained DOCTYPE PUBLIC SYSTEM276syn region sgmlInlineDTD contained start="\[" end="]" contains=@sgmlDTD277syn include @sgmlDTD <sfile>:p:h/dtd.vim278 279 280" synchronizing281" TODO !!! to be improved !!!282 283syn sync match sgmlSyncDT grouphere sgmlDocType +\_.\(<!DOCTYPE\)\@=+284" syn sync match sgmlSyncDT groupthere NONE +]>+285 286syn sync match sgmlSync grouphere sgmlRegion +\_.\(<[^ /!?>"']\+\)\@=+287" syn sync match sgmlSync grouphere sgmlRegion "<[^ /!?>"']*>"288syn sync match sgmlSync groupthere sgmlRegion +</[^ /!?>"']\+>+289 290syn sync minlines=100291 292 293" The default highlighting.294hi def link sgmlTodo Todo295hi def link sgmlTag Function296hi def link sgmlEndTag Identifier297" SGML specific298hi def link sgmlAbbrEndTag Identifier299hi def link sgmlEmptyTag Function300hi def link sgmlEntity Statement301hi def link sgmlEntityPunct Type302 303hi def link sgmlAttribPunct Comment304hi def link sgmlAttrib Type305 306hi def link sgmlValue String307hi def link sgmlString String308hi def link sgmlComment Comment309hi def link sgmlCommentPart Comment310hi def link sgmlCommentError Error311hi def link sgmlError Error312 313hi def link sgmlProcessingDelim Comment314hi def link sgmlProcessing Type315 316hi def link sgmlCdata String317hi def link sgmlCdataCdata Statement318hi def link sgmlCdataStart Type319hi def link sgmlCdataEnd Type320 321hi def link sgmlDocTypeDecl Function322hi def link sgmlDocTypeKeyword Statement323hi def link sgmlInlineDTD Function324hi def link sgmlUnicodeNumberAttr Number325hi def link sgmlUnicodeSpecifierAttr SpecialChar326hi def link sgmlUnicodeNumberData Number327hi def link sgmlUnicodeSpecifierData SpecialChar328 329let b:current_syntax = "sgml"330 331let &cpo = s:sgml_cpo_save332unlet s:sgml_cpo_save333 334" vim: ts=8335 