123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- " Vim syntax file
- " Language: SGML
- " Maintainer: Johannes Zellner <johannes@zellner.org>
- " Last Change: Tue, 27 Apr 2004 15:05:21 CEST
- " Filenames: *.sgml,*.sgm
- " $Id: sgml.vim,v 1.1 2004/06/13 17:52:57 vimboss Exp $
- " quit when a syntax file was already loaded
- if exists("b:current_syntax")
- finish
- endif
- let s:sgml_cpo_save = &cpo
- set cpo&vim
- syn case match
- " mark illegal characters
- syn match sgmlError "[<&]"
- " unicode numbers:
- " provide different highlithing for unicode characters
- " inside strings and in plain text (character data).
- "
- " EXAMPLE:
- "
- " \u4e88
- "
- syn match sgmlUnicodeNumberAttr +\\u\x\{4}+ contained contains=sgmlUnicodeSpecifierAttr
- syn match sgmlUnicodeSpecifierAttr +\\u+ contained
- syn match sgmlUnicodeNumberData +\\u\x\{4}+ contained contains=sgmlUnicodeSpecifierData
- syn match sgmlUnicodeSpecifierData +\\u+ contained
- " strings inside character data or comments
- "
- syn region sgmlString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=sgmlEntity,sgmlUnicodeNumberAttr display
- syn region sgmlString contained start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=sgmlEntity,sgmlUnicodeNumberAttr display
- " punctuation (within attributes) e.g. <tag sgml:foo.attribute ...>
- " ^ ^
- syn match sgmlAttribPunct +[:.]+ contained display
- " no highlighting for sgmlEqual (sgmlEqual has no highlighting group)
- syn match sgmlEqual +=+
- " attribute, everything before the '='
- "
- " PROVIDES: @sgmlAttribHook
- "
- " EXAMPLE:
- "
- " <tag foo.attribute = "value">
- " ^^^^^^^^^^^^^
- "
- syn match sgmlAttrib
- \ +[^-'"<]\@<=\<[a-zA-Z0-9.:]\+\>\([^'">]\@=\|$\)+
- \ contained
- \ contains=sgmlAttribPunct,@sgmlAttribHook
- \ display
- " UNQUOTED value (not including the '=' -- sgmlEqual)
- "
- " PROVIDES: @sgmlValueHook
- "
- " EXAMPLE:
- "
- " <tag foo.attribute = value>
- " ^^^^^
- "
- syn match sgmlValue
- \ +[^"' =/!?<>][^ =/!?<>]*+
- \ contained
- \ contains=sgmlEntity,sgmlUnicodeNumberAttr,@sgmlValueHook
- \ display
- " QUOTED value (not including the '=' -- sgmlEqual)
- "
- " PROVIDES: @sgmlValueHook
- "
- " EXAMPLE:
- "
- " <tag foo.attribute = "value">
- " ^^^^^^^
- " <tag foo.attribute = 'value'>
- " ^^^^^^^
- "
- syn region sgmlValue contained start=+"+ skip=+\\\\\|\\"+ end=+"+
- \ contains=sgmlEntity,sgmlUnicodeNumberAttr,@sgmlValueHook
- syn region sgmlValue contained start=+'+ skip=+\\\\\|\\'+ end=+'+
- \ contains=sgmlEntity,sgmlUnicodeNumberAttr,@sgmlValueHook
- " value, everything after (and including) the '='
- " no highlighting!
- "
- " EXAMPLE:
- "
- " <tag foo.attribute = "value">
- " ^^^^^^^^^
- " <tag foo.attribute = value>
- " ^^^^^^^
- "
- syn match sgmlEqualValue
- \ +=\s*[^ =/!?<>]\++
- \ contained
- \ contains=sgmlEqual,sgmlString,sgmlValue
- \ display
- " start tag
- " use matchgroup=sgmlTag to skip over the leading '<'
- " see also sgmlEmptyTag below.
- "
- " PROVIDES: @sgmlTagHook
- "
- syn region sgmlTag
- \ matchgroup=sgmlTag start=+<[^ /!?"']\@=+
- \ matchgroup=sgmlTag end=+>+
- \ contained
- \ contains=sgmlError,sgmlAttrib,sgmlEqualValue,@sgmlTagHook
- " tag content for empty tags. This is the same as sgmlTag
- " above, except the `matchgroup=sgmlEndTag for highlighting
- " the end '/>' differently.
- "
- " PROVIDES: @sgmlTagHook
- "
- syn region sgmlEmptyTag
- \ matchgroup=sgmlTag start=+<[^ /!?"']\@=+
- \ matchgroup=sgmlEndTag end=+/>+
- \ contained
- \ contains=sgmlError,sgmlAttrib,sgmlEqualValue,@sgmlTagHook
- " end tag
- " highlight everything but not the trailing '>' which
- " was already highlighted by the containing sgmlRegion.
- "
- " PROVIDES: @sgmlTagHook
- " (should we provide a separate @sgmlEndTagHook ?)
- "
- syn match sgmlEndTag
- \ +</[^ /!?>"']\+>+
- \ contained
- \ contains=@sgmlTagHook
- " [-- SGML SPECIFIC --]
- " SGML specific
- " tag content for abbreviated regions
- "
- " PROVIDES: @sgmlTagHook
- "
- syn region sgmlAbbrTag
- \ matchgroup=sgmlTag start=+<[^ /!?"']\@=+
- \ matchgroup=sgmlTag end=+/+
- \ contained
- \ contains=sgmlError,sgmlAttrib,sgmlEqualValue,@sgmlTagHook
- " SGML specific
- " just highlight the trailing '/'
- syn match sgmlAbbrEndTag +/+
- " SGML specific
- " abbreviated regions
- "
- " No highlighting, highlighting is done by contained elements.
- "
- " PROVIDES: @sgmlRegionHook
- "
- " EXAMPLE:
- "
- " <bold/Im Anfang war das Wort/
- "
- syn match sgmlAbbrRegion
- \ +<[^/!?>"']\+/\_[^/]\+/+
- \ contains=sgmlAbbrTag,sgmlAbbrEndTag,sgmlCdata,sgmlComment,sgmlEntity,sgmlUnicodeNumberData,@sgmlRegionHook
- " [-- END OF SGML SPECIFIC --]
- " real (non-empty) elements. We cannot do syntax folding
- " as in xml, because end tags may be optional in sgml depending
- " on the dtd.
- " No highlighting, highlighting is done by contained elements.
- "
- " PROVIDES: @sgmlRegionHook
- "
- " EXAMPLE:
- "
- " <tag id="whoops">
- " <!-- comment -->
- " <another.tag></another.tag>
- " <another.tag/>
- " some data
- " </tag>
- "
- " SGML specific:
- " compared to xmlRegion:
- " - removed folding
- " - added a single '/'in the start pattern
- "
- syn region sgmlRegion
- \ start=+<\z([^ /!?>"']\+\)\(\(\_[^/>]*[^/!?]>\)\|>\)+
- \ end=+</\z1>+
- \ contains=sgmlTag,sgmlEndTag,sgmlCdata,@sgmlRegionCluster,sgmlComment,sgmlEntity,sgmlUnicodeNumberData,@sgmlRegionHook
- \ keepend
- \ extend
- " empty tags. Just a container, no highlighting.
- " Compare this with sgmlTag.
- "
- " EXAMPLE:
- "
- " <tag id="lola"/>
- "
- " TODO use sgmlEmptyTag instead of sgmlTag
- syn match sgmlEmptyRegion
- \ +<[^ /!?>"']\(\_[^"'<>]\|"\_[^"]*"\|'\_[^']*'\)*/>+
- \ contains=sgmlEmptyTag
- " cluster which contains the above two elements
- syn cluster sgmlRegionCluster contains=sgmlRegion,sgmlEmptyRegion,sgmlAbbrRegion
- " &entities; compare with dtd
- syn match sgmlEntity "&[^; \t]*;" contains=sgmlEntityPunct
- syn match sgmlEntityPunct contained "[&.;]"
- " The real comments (this implements the comments as defined by sgml,
- " but not all sgml pages actually conform to it. Errors are flagged.
- syn region sgmlComment start=+<!+ end=+>+ contains=sgmlCommentPart,sgmlString,sgmlCommentError,sgmlTodo
- syn keyword sgmlTodo contained TODO FIXME XXX display
- syn match sgmlCommentError contained "[^><!]"
- syn region sgmlCommentPart contained start=+--+ end=+--+
- " CData sections
- "
- " PROVIDES: @sgmlCdataHook
- "
- syn region sgmlCdata
- \ start=+<!\[CDATA\[+
- \ end=+]]>+
- \ contains=sgmlCdataStart,sgmlCdataEnd,@sgmlCdataHook
- \ keepend
- \ extend
- " using the following line instead leads to corrupt folding at CDATA regions
- " syn match sgmlCdata +<!\[CDATA\[\_.\{-}]]>+ contains=sgmlCdataStart,sgmlCdataEnd,@sgmlCdataHook
- syn match sgmlCdataStart +<!\[CDATA\[+ contained contains=sgmlCdataCdata
- syn keyword sgmlCdataCdata CDATA contained
- syn match sgmlCdataEnd +]]>+ contained
- " Processing instructions
- " This allows "?>" inside strings -- good idea?
- syn region sgmlProcessing matchgroup=sgmlProcessingDelim start="<?" end="?>" contains=sgmlAttrib,sgmlEqualValue
- " DTD -- we use dtd.vim here
- syn region sgmlDocType matchgroup=sgmlDocTypeDecl start="\c<!DOCTYPE"he=s+2,rs=s+2 end=">" contains=sgmlDocTypeKeyword,sgmlInlineDTD,sgmlString
- syn keyword sgmlDocTypeKeyword contained DOCTYPE PUBLIC SYSTEM
- syn region sgmlInlineDTD contained start="\[" end="]" contains=@sgmlDTD
- syn include @sgmlDTD <sfile>:p:h/dtd.vim
- " synchronizing
- " TODO !!! to be improved !!!
- syn sync match sgmlSyncDT grouphere sgmlDocType +\_.\(<!DOCTYPE\)\@=+
- " syn sync match sgmlSyncDT groupthere NONE +]>+
- syn sync match sgmlSync grouphere sgmlRegion +\_.\(<[^ /!?>"']\+\)\@=+
- " syn sync match sgmlSync grouphere sgmlRegion "<[^ /!?>"']*>"
- syn sync match sgmlSync groupthere sgmlRegion +</[^ /!?>"']\+>+
- syn sync minlines=100
- " The default highlighting.
- hi def link sgmlTodo Todo
- hi def link sgmlTag Function
- hi def link sgmlEndTag Identifier
- " SGML specifig
- hi def link sgmlAbbrEndTag Identifier
- hi def link sgmlEmptyTag Function
- hi def link sgmlEntity Statement
- hi def link sgmlEntityPunct Type
- hi def link sgmlAttribPunct Comment
- hi def link sgmlAttrib Type
- hi def link sgmlValue String
- hi def link sgmlString String
- hi def link sgmlComment Comment
- hi def link sgmlCommentPart Comment
- hi def link sgmlCommentError Error
- hi def link sgmlError Error
- hi def link sgmlProcessingDelim Comment
- hi def link sgmlProcessing Type
- hi def link sgmlCdata String
- hi def link sgmlCdataCdata Statement
- hi def link sgmlCdataStart Type
- hi def link sgmlCdataEnd Type
- hi def link sgmlDocTypeDecl Function
- hi def link sgmlDocTypeKeyword Statement
- hi def link sgmlInlineDTD Function
- hi def link sgmlUnicodeNumberAttr Number
- hi def link sgmlUnicodeSpecifierAttr SpecialChar
- hi def link sgmlUnicodeNumberData Number
- hi def link sgmlUnicodeSpecifierData SpecialChar
- let b:current_syntax = "sgml"
- let &cpo = s:sgml_cpo_save
- unlet s:sgml_cpo_save
- " vim: ts=8
|