home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / runtime / dos / syntax / dtd.vim < prev    next >
Encoding:
Text File  |  2012-05-31  |  5.3 KB  |  171 lines

  1. " Vim syntax file
  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
  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.  
  16. if exists("b:current_syntax")
  17.     finish
  18. endif
  19. let s:dtd_cpo_save = &cpo
  20. set cpo&vim
  21.  
  22. if !exists("dtd_ignore_case")
  23.     " I prefer having the case takes into consideration.
  24.     syn case match
  25. else
  26.     syn case ignore
  27. endif
  28.  
  29.  
  30. " the following line makes the opening <! and
  31. " closing > highlighted using 'dtdFunction'.
  32. "
  33. " PROVIDES: @dtdTagHook
  34. "
  35. syn region dtdTag matchgroup=dtdFunction
  36.     \ start=+<!+ end=+>+ matchgroup=NONE
  37.     \ contains=dtdTag,dtdTagName,dtdError,dtdComment,dtdString,dtdAttrType,dtdAttrDef,dtdEnum,dtdParamEntityInst,dtdParamEntityDecl,dtdCard,@dtdTagHook
  38.  
  39. if !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=+>+
  45. endif
  46.  
  47. " if this is a html like comment hightlight also
  48. " the opening <! and the closing > as Comment.
  49. syn region dtdComment        start=+<![ \t]*--+ end=+-->+ contains=dtdTodo,@Spell
  50.  
  51.  
  52. " proper DTD comment
  53. syn 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.
  59. syn match dtdTagName contained +<!\(ATTLIST\|DOCTYPE\|ELEMENT\|ENTITY\|NOTATION\|SHORTREF\|USEMAP\|\[\)+lc=2,hs=s+2
  60.  
  61.  
  62. " wildcards and operators
  63. syn match  dtdCard contained "|"
  64. syn match  dtdCard contained ","
  65. " evenutally overridden by dtdEntity
  66. syn match  dtdCard contained "&"
  67. syn match  dtdCard contained "?"
  68. syn match  dtdCard contained "\*"
  69. syn match  dtdCard contained "+"
  70.  
  71. " ...and finally, special cases.
  72. syn match  dtdCard      "ANY"
  73. syn match  dtdCard      "EMPTY"
  74.  
  75. if !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.  
  94. endif
  95.  
  96. " &entities; compare with xml
  97. syn match   dtdEntity              "&[^; \t]*;" contains=dtdEntityPunct
  98. syn match   dtdEntityPunct  contained "[&.;]"
  99.  
  100. " Strings are between quotes
  101. syn region dtdString    start=+"+ skip=+\\\\\|\\"+  end=+"+ contains=dtdAttrDef,dtdAttrType,dtdEnum,dtdParamEntityInst,dtdEntity,dtdCard
  102. syn 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. "
  108. syn region dtdEnum matchgroup=dtdType start="(" end=")" matchgroup=NONE contains=dtdEnum,dtdParamEntityInst,dtdCard,@dtdEnumHook
  109.  
  110. "Attribute types
  111. syn keyword dtdAttrType NMTOKEN  ENTITIES  NMTOKENS  ID  CDATA
  112. syn keyword dtdAttrType IDREF  IDREFS
  113. " ENTITY has to treated special for not overriding <!ENTITY
  114. syn match   dtdAttrType +[^!]\<ENTITY+
  115.  
  116. "Attribute Definitions
  117. syn match  dtdAttrDef   "#REQUIRED"
  118. syn match  dtdAttrDef   "#IMPLIED"
  119. syn match  dtdAttrDef   "#FIXED"
  120.  
  121. syn case match
  122. " define some common keywords to mark TODO
  123. " and important sections inside comments.
  124. syn keyword dtdTodo contained TODO FIXME XXX
  125.  
  126. syn sync lines=250
  127.  
  128. " Define the default highlighting.
  129. " For version 5.7 and earlier: only when not done already
  130. " For version 5.8 and later: only when an item doesn't have highlighting yet
  131. if version >= 508 || !exists("did_dtd_syn_inits")
  132.     if version < 508
  133.     let did_dtd_syn_inits = 1
  134.     command -nargs=+ HiLink hi link <args>
  135.     else
  136.     command -nargs=+ HiLink hi def link <args>
  137.     endif
  138.  
  139.     " The default highlighting.
  140.     HiLink dtdFunction        Function
  141.     HiLink dtdTag        Normal
  142.     HiLink dtdType        Type
  143.     HiLink dtdAttrType        dtdType
  144.     HiLink dtdAttrDef        dtdType
  145.     HiLink dtdConstant        Constant
  146.     HiLink dtdString        dtdConstant
  147.     HiLink dtdEnum        dtdConstant
  148.     HiLink dtdCard        dtdFunction
  149.  
  150.     HiLink dtdEntity        Statement
  151.     HiLink dtdEntityPunct    dtdType
  152.     HiLink dtdParamEntityInst    dtdConstant
  153.     HiLink dtdParamEntityPunct    dtdType
  154.     HiLink dtdParamEntityDecl    dtdType
  155.     HiLink dtdParamEntityDPunct dtdComment
  156.  
  157.     HiLink dtdComment        Comment
  158.     HiLink dtdTagName        Statement
  159.     HiLink dtdError        Error
  160.     HiLink dtdTodo        Todo
  161.  
  162.     delcommand HiLink
  163. endif
  164.  
  165. let &cpo = s:dtd_cpo_save
  166. unlet s:dtd_cpo_save
  167.  
  168. let b:current_syntax = "dtd"
  169.  
  170. " vim: ts=8
  171.