1 # Copyright (c) 2005 - 2006 Hans Jeuken. All rights reserved.
2 # This program is free software; you can redistribute it and/or
3 # modify it under the same terms as Perl itself.
5 # This file was generated from the 'html.xml' file of the syntax highlight
6 # engine of the kate text editor (http://www.kate-editor.org
10 #kate author Wilbert Berendsen (wilbert@kde.nl)
11 #generated: Sun Feb 3 22:02:05 2008, localtime
13 package Syntax::Highlight::Engine::Kate::HTML;
15 our $VERSION = '0.06';
19 use base('Syntax::Highlight::Engine::Kate::Template');
23 my $class = ref($proto) || $proto;
24 my $self = $class->SUPER::new(@_);
26 'Attribute' => 'Others',
28 'Comment' => 'Comment',
29 'Doctype' => 'DataType',
30 'Element' => 'Keyword',
31 'EntityRef' => 'DecVal',
33 'Normal Text' => 'Normal',
34 'PEntityRef' => 'DecVal',
35 'Processing Instruction' => 'Keyword',
40 callback => \&parseCDATA,
41 attribute => 'Normal Text',
44 callback => \&parseCSS,
45 attribute => 'Normal Text',
48 callback => \&parseCSScontent,
49 attribute => 'Normal Text',
52 callback => \&parseComment,
53 attribute => 'Comment',
56 callback => \&parseDoctype,
57 attribute => 'Normal Text',
59 'Doctype Internal Subset' => {
60 callback => \&parseDoctypeInternalSubset,
61 attribute => 'Normal Text',
63 'Doctype Markupdecl' => {
64 callback => \&parseDoctypeMarkupdecl,
65 attribute => 'Normal Text',
67 'Doctype Markupdecl DQ' => {
68 callback => \&parseDoctypeMarkupdeclDQ,
71 'Doctype Markupdecl SQ' => {
72 callback => \&parseDoctypeMarkupdeclSQ,
76 callback => \&parseElClose,
77 attribute => 'Normal Text',
80 callback => \&parseElClose2,
81 attribute => 'Normal Text',
84 callback => \&parseElClose3,
85 attribute => 'Normal Text',
88 callback => \&parseElOpen,
89 attribute => 'Normal Text',
92 callback => \&parseFindAttributes,
93 attribute => 'Normal Text',
96 callback => \&parseFindDTDRules,
97 attribute => 'Normal Text',
100 callback => \&parseFindEntityRefs,
101 attribute => 'Normal Text',
104 callback => \&parseFindHTML,
105 attribute => 'Normal Text',
107 'FindPEntityRefs' => {
108 callback => \&parseFindPEntityRefs,
109 attribute => 'Normal Text',
112 callback => \&parseJS,
113 attribute => 'Normal Text',
115 'JS comment close' => {
116 callback => \&parseJScommentclose,
117 attribute => 'Comment',
118 lineending => '#pop',
121 callback => \&parseJScontent,
122 attribute => 'Normal Text',
125 callback => \&parsePI,
126 attribute => 'Normal Text',
129 callback => \&parseStart,
130 attribute => 'Normal Text',
133 callback => \&parseValue,
134 attribute => 'Normal Text',
135 fallthrough => 'Value NQ',
138 callback => \&parseValueDQ,
139 attribute => 'Value',
142 callback => \&parseValueNQ,
143 attribute => 'Normal Text',
144 lineending => '#pop#pop',
145 fallthrough => '#pop#pop',
148 callback => \&parseValueSQ,
149 attribute => 'Value',
152 $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\');
153 $self->basecontext('Start');
154 $self->keywordscase(1);
156 bless ($self, $class);
165 my ($self, $text) = @_;
166 # type => 'DetectSpaces'
167 if ($self->testDetectSpaces($text, 0, undef, 0, '#stay', undef)) {
170 # type => 'DetectIdentifier'
171 if ($self->testDetectIdentifier($text, 0, undef, 0, '#stay', undef)) {
175 # attribute => 'CDATA'
177 # endRegion => 'cdata'
178 # type => 'StringDetect'
179 if ($self->testStringDetect($text, ']]>', 0, 0, 0, undef, 0, '#pop', 'CDATA')) {
183 # attribute => 'EntityRef'
185 # type => 'StringDetect'
186 if ($self->testStringDetect($text, ']]>', 0, 0, 0, undef, 0, '#stay', 'EntityRef')) {
193 my ($self, $text) = @_;
194 # attribute => 'Element'
198 # endRegion => 'style'
199 # type => 'Detect2Chars'
200 if ($self->testDetect2Chars($text, '/', '>', 0, 0, 0, undef, 0, '#pop', 'Element')) {
203 # attribute => 'Element'
205 # context => 'CSS content'
206 # type => 'DetectChar'
207 if ($self->testDetectChar($text, '>', 0, 0, 0, undef, 0, 'CSS content', 'Element')) {
210 # context => 'FindAttributes'
211 # type => 'IncludeRules'
212 if ($self->includeRules('FindAttributes', $text)) {
216 # attribute => 'Error'
219 if ($self->testRegExpr($text, '\\S', 0, 0, 0, undef, 0, '#stay', 'Error')) {
225 sub parseCSScontent {
226 my ($self, $text) = @_;
227 # String => '</style\b'
228 # attribute => 'Element'
229 # context => 'El Close 2'
230 # endRegion => 'style'
231 # insensitive => 'TRUE'
233 if ($self->testRegExpr($text, '</style\\b', 1, 0, 0, undef, 0, 'El Close 2', 'Element')) {
237 # includeAttrib => 'true'
238 # type => 'IncludeRules'
239 if ($self->includePlugin('CSS', $text)) {
246 my ($self, $text) = @_;
247 # type => 'DetectSpaces'
248 if ($self->testDetectSpaces($text, 0, undef, 0, '#stay', undef)) {
251 # context => '##Alerts'
252 # type => 'IncludeRules'
253 if ($self->includePlugin('Alerts', $text)) {
256 # type => 'DetectIdentifier'
257 if ($self->testDetectIdentifier($text, 0, undef, 0, '#stay', undef)) {
261 # attribute => 'Comment'
263 # endRegion => 'comment'
264 # type => 'StringDetect'
265 if ($self->testStringDetect($text, '-->', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
268 # String => '-(-(?!->))+'
269 # attribute => 'Error'
272 if ($self->testRegExpr($text, '-(-(?!->))+', 0, 0, 0, undef, 0, '#stay', 'Error')) {
279 my ($self, $text) = @_;
280 # attribute => 'Doctype'
283 # endRegion => 'doctype'
284 # type => 'DetectChar'
285 if ($self->testDetectChar($text, '>', 0, 0, 0, undef, 0, '#pop', 'Doctype')) {
288 # attribute => 'Doctype'
289 # beginRegion => 'int_subset'
291 # context => 'Doctype Internal Subset'
292 # type => 'DetectChar'
293 if ($self->testDetectChar($text, '[', 0, 0, 0, undef, 0, 'Doctype Internal Subset', 'Doctype')) {
299 sub parseDoctypeInternalSubset {
300 my ($self, $text) = @_;
301 # attribute => 'Doctype'
304 # endRegion => 'int_subset'
305 # type => 'DetectChar'
306 if ($self->testDetectChar($text, ']', 0, 0, 0, undef, 0, '#pop', 'Doctype')) {
309 # context => 'FindDTDRules'
310 # type => 'IncludeRules'
311 if ($self->includeRules('FindDTDRules', $text)) {
315 # attribute => 'Comment'
316 # beginRegion => 'comment'
317 # context => 'Comment'
318 # type => 'StringDetect'
319 if ($self->testStringDetect($text, '<!--', 0, 0, 0, undef, 0, 'Comment', 'Comment')) {
322 # String => '<\?[\w:-]*'
323 # attribute => 'Processing Instruction'
324 # beginRegion => 'pi'
327 if ($self->testRegExpr($text, '<\\?[\\w:-]*', 0, 0, 0, undef, 0, 'PI', 'Processing Instruction')) {
330 # context => 'FindPEntityRefs'
331 # type => 'IncludeRules'
332 if ($self->includeRules('FindPEntityRefs', $text)) {
338 sub parseDoctypeMarkupdecl {
339 my ($self, $text) = @_;
340 # attribute => 'Doctype'
343 # type => 'DetectChar'
344 if ($self->testDetectChar($text, '>', 0, 0, 0, undef, 0, '#pop', 'Doctype')) {
347 # attribute => 'Value'
349 # context => 'Doctype Markupdecl DQ'
350 # type => 'DetectChar'
351 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'Doctype Markupdecl DQ', 'Value')) {
354 # attribute => 'Value'
356 # context => 'Doctype Markupdecl SQ'
357 # type => 'DetectChar'
358 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, 'Doctype Markupdecl SQ', 'Value')) {
364 sub parseDoctypeMarkupdeclDQ {
365 my ($self, $text) = @_;
366 # attribute => 'Value'
369 # type => 'DetectChar'
370 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop', 'Value')) {
373 # context => 'FindPEntityRefs'
374 # type => 'IncludeRules'
375 if ($self->includeRules('FindPEntityRefs', $text)) {
381 sub parseDoctypeMarkupdeclSQ {
382 my ($self, $text) = @_;
383 # attribute => 'Value'
386 # type => 'DetectChar'
387 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, '#pop', 'Value')) {
390 # context => 'FindPEntityRefs'
391 # type => 'IncludeRules'
392 if ($self->includeRules('FindPEntityRefs', $text)) {
399 my ($self, $text) = @_;
400 # attribute => 'Element'
403 # type => 'DetectChar'
404 if ($self->testDetectChar($text, '>', 0, 0, 0, undef, 0, '#pop', 'Element')) {
408 # attribute => 'Error'
411 if ($self->testRegExpr($text, '\\S', 0, 0, 0, undef, 0, '#stay', 'Error')) {
418 my ($self, $text) = @_;
419 # attribute => 'Element'
421 # context => '#pop#pop#pop'
422 # type => 'DetectChar'
423 if ($self->testDetectChar($text, '>', 0, 0, 0, undef, 0, '#pop#pop#pop', 'Element')) {
427 # attribute => 'Error'
430 if ($self->testRegExpr($text, '\\S', 0, 0, 0, undef, 0, '#stay', 'Error')) {
437 my ($self, $text) = @_;
438 # attribute => 'Element'
440 # context => '#pop#pop#pop#pop'
441 # type => 'DetectChar'
442 if ($self->testDetectChar($text, '>', 0, 0, 0, undef, 0, '#pop#pop#pop#pop', 'Element')) {
446 # attribute => 'Error'
449 if ($self->testRegExpr($text, '\\S', 0, 0, 0, undef, 0, '#stay', 'Error')) {
456 my ($self, $text) = @_;
457 # attribute => 'Element'
461 # type => 'Detect2Chars'
462 if ($self->testDetect2Chars($text, '/', '>', 0, 0, 0, undef, 0, '#pop', 'Element')) {
465 # attribute => 'Element'
468 # type => 'DetectChar'
469 if ($self->testDetectChar($text, '>', 0, 0, 0, undef, 0, '#pop', 'Element')) {
472 # context => 'FindAttributes'
473 # type => 'IncludeRules'
474 if ($self->includeRules('FindAttributes', $text)) {
478 # attribute => 'Error'
481 if ($self->testRegExpr($text, '\\S', 0, 0, 0, undef, 0, '#stay', 'Error')) {
487 sub parseFindAttributes {
488 my ($self, $text) = @_;
489 # String => '[A-Za-z_:][\w.:_-]*'
490 # attribute => 'Attribute'
494 if ($self->testRegExpr($text, '[A-Za-z_:][\\w.:_-]*', 0, 0, 0, 0, 0, '#stay', 'Attribute')) {
497 # String => '\s+[A-Za-z_:][\w.:_-]*'
498 # attribute => 'Attribute'
501 if ($self->testRegExpr($text, '\\s+[A-Za-z_:][\\w.:_-]*', 0, 0, 0, undef, 0, '#stay', 'Attribute')) {
504 # attribute => 'Attribute'
507 # type => 'DetectChar'
508 if ($self->testDetectChar($text, '=', 0, 0, 0, undef, 0, 'Value', 'Attribute')) {
514 sub parseFindDTDRules {
515 my ($self, $text) = @_;
516 # String => '<!(ELEMENT|ENTITY|ATTLIST|NOTATION)\b'
517 # attribute => 'Doctype'
518 # context => 'Doctype Markupdecl'
520 if ($self->testRegExpr($text, '<!(ELEMENT|ENTITY|ATTLIST|NOTATION)\\b', 0, 0, 0, undef, 0, 'Doctype Markupdecl', 'Doctype')) {
526 sub parseFindEntityRefs {
527 my ($self, $text) = @_;
528 # String => '&(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z_:][\w.:_-]*);'
529 # attribute => 'EntityRef'
532 if ($self->testRegExpr($text, '&(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z_:][\\w.:_-]*);', 0, 0, 0, undef, 0, '#stay', 'EntityRef')) {
536 # attribute => 'Error'
539 if ($self->testAnyChar($text, '&<', 0, 0, undef, 0, '#stay', 'Error')) {
546 my ($self, $text) = @_;
547 # type => 'DetectSpaces'
548 if ($self->testDetectSpaces($text, 0, undef, 0, '#stay', undef)) {
551 # type => 'DetectIdentifier'
552 if ($self->testDetectIdentifier($text, 0, undef, 0, '#stay', undef)) {
556 # attribute => 'Comment'
557 # beginRegion => 'comment'
558 # context => 'Comment'
559 # type => 'StringDetect'
560 if ($self->testStringDetect($text, '<!--', 0, 0, 0, undef, 0, 'Comment', 'Comment')) {
563 # String => '<![CDATA['
564 # attribute => 'CDATA'
565 # beginRegion => 'cdata'
567 # type => 'StringDetect'
568 if ($self->testStringDetect($text, '<![CDATA[', 0, 0, 0, undef, 0, 'CDATA', 'CDATA')) {
571 # String => '<!DOCTYPE\s+'
572 # attribute => 'Doctype'
573 # beginRegion => 'doctype'
574 # context => 'Doctype'
576 if ($self->testRegExpr($text, '<!DOCTYPE\\s+', 0, 0, 0, undef, 0, 'Doctype', 'Doctype')) {
579 # String => '<\?[\w:-]*'
580 # attribute => 'Processing Instruction'
581 # beginRegion => 'pi'
584 if ($self->testRegExpr($text, '<\\?[\\w:-]*', 0, 0, 0, undef, 0, 'PI', 'Processing Instruction')) {
587 # String => '<style\b'
588 # attribute => 'Element'
589 # beginRegion => 'style'
591 # insensitive => 'TRUE'
593 if ($self->testRegExpr($text, '<style\\b', 1, 0, 0, undef, 0, 'CSS', 'Element')) {
596 # String => '<script\b'
597 # attribute => 'Element'
598 # beginRegion => 'script'
600 # insensitive => 'TRUE'
602 if ($self->testRegExpr($text, '<script\\b', 1, 0, 0, undef, 0, 'JS', 'Element')) {
606 # attribute => 'Element'
607 # beginRegion => 'pre'
608 # context => 'El Open'
609 # insensitive => 'TRUE'
611 if ($self->testRegExpr($text, '<pre\\b', 1, 0, 0, undef, 0, 'El Open', 'Element')) {
615 # attribute => 'Element'
616 # beginRegion => 'div'
617 # context => 'El Open'
618 # insensitive => 'TRUE'
620 if ($self->testRegExpr($text, '<div\\b', 1, 0, 0, undef, 0, 'El Open', 'Element')) {
623 # String => '<table\b'
624 # attribute => 'Element'
625 # beginRegion => 'table'
626 # context => 'El Open'
627 # insensitive => 'TRUE'
629 if ($self->testRegExpr($text, '<table\\b', 1, 0, 0, undef, 0, 'El Open', 'Element')) {
632 # String => '<[A-Za-z_:][\w.:_-]*'
633 # attribute => 'Element'
634 # context => 'El Open'
636 if ($self->testRegExpr($text, '<[A-Za-z_:][\\w.:_-]*', 0, 0, 0, undef, 0, 'El Open', 'Element')) {
639 # String => '</pre\b'
640 # attribute => 'Element'
641 # context => 'El Close'
643 # insensitive => 'TRUE'
645 if ($self->testRegExpr($text, '</pre\\b', 1, 0, 0, undef, 0, 'El Close', 'Element')) {
648 # String => '</div\b'
649 # attribute => 'Element'
650 # context => 'El Close'
652 # insensitive => 'TRUE'
654 if ($self->testRegExpr($text, '</div\\b', 1, 0, 0, undef, 0, 'El Close', 'Element')) {
657 # String => '</table\b'
658 # attribute => 'Element'
659 # context => 'El Close'
660 # endRegion => 'table'
661 # insensitive => 'TRUE'
663 if ($self->testRegExpr($text, '</table\\b', 1, 0, 0, undef, 0, 'El Close', 'Element')) {
666 # String => '</[A-Za-z_:][\w.:_-]*'
667 # attribute => 'Element'
668 # context => 'El Close'
670 if ($self->testRegExpr($text, '</[A-Za-z_:][\\w.:_-]*', 0, 0, 0, undef, 0, 'El Close', 'Element')) {
673 # context => 'FindDTDRules'
674 # type => 'IncludeRules'
675 if ($self->includeRules('FindDTDRules', $text)) {
678 # context => 'FindEntityRefs'
679 # type => 'IncludeRules'
680 if ($self->includeRules('FindEntityRefs', $text)) {
686 sub parseFindPEntityRefs {
687 my ($self, $text) = @_;
688 # String => '&(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z_:][\w.:_-]*);'
689 # attribute => 'EntityRef'
692 if ($self->testRegExpr($text, '&(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z_:][\\w.:_-]*);', 0, 0, 0, undef, 0, '#stay', 'EntityRef')) {
695 # String => '%[A-Za-z_:][\w.:_-]*;'
696 # attribute => 'PEntityRef'
699 if ($self->testRegExpr($text, '%[A-Za-z_:][\\w.:_-]*;', 0, 0, 0, undef, 0, '#stay', 'PEntityRef')) {
703 # attribute => 'Error'
706 if ($self->testAnyChar($text, '&%', 0, 0, undef, 0, '#stay', 'Error')) {
713 my ($self, $text) = @_;
714 # attribute => 'Element'
718 # endRegion => 'script'
719 # type => 'Detect2Chars'
720 if ($self->testDetect2Chars($text, '/', '>', 0, 0, 0, undef, 0, '#pop', 'Element')) {
723 # attribute => 'Element'
725 # context => 'JS content'
726 # type => 'DetectChar'
727 if ($self->testDetectChar($text, '>', 0, 0, 0, undef, 0, 'JS content', 'Element')) {
730 # context => 'FindAttributes'
731 # type => 'IncludeRules'
732 if ($self->includeRules('FindAttributes', $text)) {
736 # attribute => 'Error'
739 if ($self->testRegExpr($text, '\\S', 0, 0, 0, undef, 0, '#stay', 'Error')) {
745 sub parseJScommentclose {
746 my ($self, $text) = @_;
747 # String => '</script\b'
748 # attribute => 'Element'
749 # context => 'El Close 3'
750 # endRegion => 'script'
751 # insensitive => 'TRUE'
753 if ($self->testRegExpr($text, '</script\\b', 1, 0, 0, undef, 0, 'El Close 3', 'Element')) {
756 # context => '##Alerts'
757 # type => 'IncludeRules'
758 if ($self->includePlugin('Alerts', $text)) {
765 my ($self, $text) = @_;
766 # String => '</script\b'
767 # attribute => 'Element'
768 # context => 'El Close 2'
769 # endRegion => 'script'
770 # insensitive => 'TRUE'
772 if ($self->testRegExpr($text, '</script\\b', 1, 0, 0, undef, 0, 'El Close 2', 'Element')) {
775 # String => '//(?=.*</script\b)'
776 # attribute => 'Comment'
777 # context => 'JS comment close'
778 # insensitive => 'TRUE'
780 if ($self->testRegExpr($text, '//(?=.*</script\\b)', 1, 0, 0, undef, 0, 'JS comment close', 'Comment')) {
783 # context => '##JavaScript'
784 # includeAttrib => 'true'
785 # type => 'IncludeRules'
786 if ($self->includePlugin('JavaScript', $text)) {
793 my ($self, $text) = @_;
794 # attribute => 'Processing Instruction'
799 # type => 'Detect2Chars'
800 if ($self->testDetect2Chars($text, '?', '>', 0, 0, 0, undef, 0, '#pop', 'Processing Instruction')) {
807 my ($self, $text) = @_;
808 # context => 'FindHTML'
809 # type => 'IncludeRules'
810 if ($self->includeRules('FindHTML', $text)) {
817 my ($self, $text) = @_;
818 # attribute => 'Value'
820 # context => 'Value DQ'
821 # type => 'DetectChar'
822 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, 'Value DQ', 'Value')) {
825 # attribute => 'Value'
827 # context => 'Value SQ'
828 # type => 'DetectChar'
829 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, 'Value SQ', 'Value')) {
832 # type => 'DetectSpaces'
833 if ($self->testDetectSpaces($text, 0, undef, 0, '#stay', undef)) {
840 my ($self, $text) = @_;
841 # attribute => 'Value'
843 # context => '#pop#pop'
844 # type => 'DetectChar'
845 if ($self->testDetectChar($text, '"', 0, 0, 0, undef, 0, '#pop#pop', 'Value')) {
848 # context => 'FindEntityRefs'
849 # type => 'IncludeRules'
850 if ($self->includeRules('FindEntityRefs', $text)) {
857 my ($self, $text) = @_;
858 # context => 'FindEntityRefs'
859 # type => 'IncludeRules'
860 if ($self->includeRules('FindEntityRefs', $text)) {
864 # attribute => 'Value'
867 if ($self->testRegExpr($text, '/(?!>)', 0, 0, 0, undef, 0, '#stay', 'Value')) {
870 # String => '[^/><"'\s]'
871 # attribute => 'Value'
874 if ($self->testRegExpr($text, '[^/><"\'\\s]', 0, 0, 0, undef, 0, '#stay', 'Value')) {
881 my ($self, $text) = @_;
882 # attribute => 'Value'
884 # context => '#pop#pop'
885 # type => 'DetectChar'
886 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, '#pop#pop', 'Value')) {
889 # context => 'FindEntityRefs'
890 # type => 'IncludeRules'
891 if ($self->includeRules('FindEntityRefs', $text)) {
904 Syntax::Highlight::Engine::Kate::HTML - a Plugin for HTML syntax highlighting
908 require Syntax::Highlight::Engine::Kate::HTML;
909 my $sh = new Syntax::Highlight::Engine::Kate::HTML([
914 Syntax::Highlight::Engine::Kate::HTML is a plugin module that provides syntax highlighting
915 for HTML to the Syntax::Haghlight::Engine::Kate highlighting engine.
917 This code is generated from the syntax definition files used
919 It works quite fine, but can use refinement and optimization.
921 It inherits Syntax::Higlight::Engine::Kate::Template. See also there.
927 Hans Jeuken (haje <at> toneel <dot> demon <dot> nl)
933 Unknown. If you find any, please contact the author