
# Parse html and other similar markups (xml, jsp, etc).
#
# start and end tags allow leading/trailing punctuation (% @ etc) used by some markups)
#

syntaxdef html {

/\s+/m :;

/<\!--(.*?)-->/s : {
      # todo - support embedded scripts
      region {
        type=comment;
      }
    }

/  <
   ([%@!?=$\s]+)?             # leading punctuation (opt)
   ([\p{N}\p{L}._:-]+  )      # tag name
   /mx : {
          context {           #context for matching attributes
                /
                ([%@!?$\s]+)?              # trailing punctuation (opt)
                (\/\s*)?                   # trailing slash (opt)
                >                          # closing angle brackets
                /mx : exit;

                /
                ([\p{N}\p{L}._:-]+)         # attribute name
                \s*=\s*                     # equals
                ("[^"]*?"|'[^']*?'|[^\s>]+) # attribute data - should consume '>' if encountered inside " or '
                /mx : {
                    region ${1} {
                       type=attrib;
                    }
                    region ${2} {
                       type=string;
                       findlinks=true;
                    }
                }
          }
          region ${ALL} {
            type=starttag;
          }
    }

/  <\/
   ([%@!?=$\s]+)?          # leading punctuation (opt)
   ([\p{N}\p{L}._:-]+)     # tag name
   ([%@!?=$\s]+)?          # trailing punctuation (opt)
   (\/\s*)?                # trailing slash (opt)
   >  /mx : {
      region {
        type=endtag;
      }
   }

/&[\w\d]+;/ : {
      region {
        type=escape;
      }
    }

}