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 'mediawiki.xml' file of the syntax highlight
6 # engine of the kate text editor (http://www.kate-editor.org
10 #generated: Sun Feb 3 22:02:06 2008, localtime
12 package Syntax::Highlight::Engine::Kate::Wikimedia;
14 our $VERSION = '0.06';
18 use base('Syntax::Highlight::Engine::Kate::Template');
22 my $class = ref($proto) || $proto;
23 my $self = $class->SUPER::new(@_);
25 'Comment' => 'Comment',
27 'HTML-Entity' => 'DecVal',
28 'HTML-Tag' => 'Keyword',
32 'Section' => 'Keyword',
34 'Unformatted' => 'Normal',
35 'Wiki-Tag' => 'DecVal',
39 callback => \&parseError,
44 callback => \&parseLink,
45 attribute => 'Template',
48 callback => \&parseNoWiki,
49 attribute => 'NoWiki',
52 callback => \&parsePre,
53 attribute => 'NoWiki',
56 callback => \&parseTable,
57 attribute => 'Normal',
60 callback => \&parseTemplate,
64 callback => \&parseURL,
68 callback => \&parseUnformatted,
69 attribute => 'Unformatted',
73 callback => \&parseWikiLink,
77 callback => \&parsecomment,
78 attribute => 'Comment',
81 callback => \&parsenormal,
82 attribute => 'Normal',
85 $self->deliminators('\\s||\\.|\\(|\\)|:|\\!|\\+|,|-|<|=|>|\\%|\\&|\\*|\\/|;|\\?|\\[|\\]|\\^|\\{|\\||\\}|\\~|\\\\');
86 $self->basecontext('normal');
87 $self->keywordscase(0);
89 bless ($self, $class);
98 my ($self, $text) = @_;
103 my ($self, $text) = @_;
104 # attribute => 'Wiki-Tag'
108 # type => 'Detect2Chars'
109 if ($self->testDetect2Chars($text, '}', '}', 0, 0, 0, undef, 0, '#pop', 'Wiki-Tag')) {
113 # attribute => 'Error'
116 if ($self->testAnyChar($text, '\'[]', 0, 0, undef, 0, 'Error', 'Error')) {
123 my ($self, $text) = @_;
124 # String => '<!--[^-]*-->'
125 # attribute => 'NoWiki'
127 if ($self->testRegExpr($text, '<!--[^-]*-->', 0, 0, 0, undef, 0, '#stay', 'NoWiki')) {
130 # String => '</nowiki>'
131 # attribute => 'Wiki-Tag'
133 # type => 'StringDetect'
134 if ($self->testStringDetect($text, '</nowiki>', 0, 0, 0, undef, 0, '#pop', 'Wiki-Tag')) {
137 # String => '[<][^>]+[>]'
138 # attribute => 'HTML-Tag'
141 if ($self->testRegExpr($text, '[<][^>]+[>]', 0, 0, 0, undef, 0, '#stay', 'HTML-Tag')) {
145 # attribute => 'HTML-Tag'
147 # type => 'StringDetect'
148 if ($self->testStringDetect($text, '<pre>', 0, 0, 0, undef, 0, 'Pre', 'HTML-Tag')) {
155 my ($self, $text) = @_;
157 # attribute => 'Wiki-Tag'
159 # type => 'StringDetect'
160 if ($self->testStringDetect($text, '</pre>', 0, 0, 0, undef, 0, '#pop', 'Wiki-Tag')) {
167 my ($self, $text) = @_;
169 # attribute => 'Comment'
170 # context => 'comment'
171 # type => 'StringDetect'
172 if ($self->testStringDetect($text, '<!--', 0, 0, 0, undef, 0, 'comment', 'Comment')) {
175 # String => '([=]{2,2}[^=]+[=]{2,2}|[=]{3,3}[^=]+[=]{3,3}|[=]{4,4}[^=]+[=]{4,4}|[=]{5,5}[^=]+[=]{5,5})'
176 # attribute => 'Section'
180 if ($self->testRegExpr($text, '([=]{2,2}[^=]+[=]{2,2}|[=]{3,3}[^=]+[=]{3,3}|[=]{4,4}[^=]+[=]{4,4}|[=]{5,5}[^=]+[=]{5,5})', 0, 0, 0, 0, 0, '#stay', 'Section')) {
183 # String => '[*#;:\s]*[*#:]+'
184 # attribute => 'Wiki-Tag'
188 if ($self->testRegExpr($text, '[*#;:\\s]*[*#:]+', 0, 0, 0, 0, 0, '#stay', 'Wiki-Tag')) {
191 # String => '[[](?![[])'
192 # attribute => 'Wiki-Tag'
195 if ($self->testRegExpr($text, '[[](?![[])', 0, 0, 0, undef, 0, 'URL', 'Wiki-Tag')) {
198 # String => '(http:|ftp:|mailto:)[\S]*($|[\s])'
202 if ($self->testRegExpr($text, '(http:|ftp:|mailto:)[\\S]*($|[\\s])', 0, 0, 0, undef, 0, '#stay', 'URL')) {
205 # String => '[']{2,}'
206 # attribute => 'Wiki-Tag'
209 if ($self->testRegExpr($text, '[\']{2,}', 0, 0, 0, undef, 0, '#stay', 'Wiki-Tag')) {
212 # attribute => 'Wiki-Tag'
217 # endRegion => 'table'
218 # type => 'Detect2Chars'
219 if ($self->testDetect2Chars($text, '|', '}', 0, 0, 0, 0, 0, '#pop', 'Wiki-Tag')) {
222 # attribute => 'Wiki-Tag'
225 # type => 'DetectChar'
226 if ($self->testDetectChar($text, '|', 0, 0, 0, undef, 0, '#stay', 'Wiki-Tag')) {
229 # attribute => 'Wiki-Tag'
232 # context => 'Template'
233 # type => 'Detect2Chars'
234 if ($self->testDetect2Chars($text, '{', '{', 0, 0, 0, undef, 0, 'Template', 'Wiki-Tag')) {
237 # attribute => 'Wiki-Tag'
240 # context => 'WikiLink'
241 # type => 'Detect2Chars'
242 if ($self->testDetect2Chars($text, '[', '[', 0, 0, 0, undef, 0, 'WikiLink', 'Wiki-Tag')) {
245 # attribute => 'HTML-Entity'
249 # type => 'RangeDetect'
250 if ($self->testRangeDetect($text, '&', ';', 0, 0, undef, 0, '#stay', 'HTML-Entity')) {
253 # String => '<nowiki>'
254 # attribute => 'Wiki-Tag'
255 # context => 'NoWiki'
256 # type => 'StringDetect'
257 if ($self->testStringDetect($text, '<nowiki>', 0, 0, 0, undef, 0, 'NoWiki', 'Wiki-Tag')) {
261 # attribute => 'HTML-Tag'
263 # type => 'StringDetect'
264 if ($self->testStringDetect($text, '<pre>', 0, 0, 0, undef, 0, 'Pre', 'HTML-Tag')) {
267 # String => '[<][^>]+[>]'
268 # attribute => 'HTML-Tag'
271 if ($self->testRegExpr($text, '[<][^>]+[>]', 0, 0, 0, undef, 0, '#stay', 'HTML-Tag')) {
276 # context => 'Unformatted'
278 if ($self->testRegExpr($text, '[\\s]', 0, 0, 0, 0, 0, 'Unformatted', undef)) {
281 # String => '[~]{3,4}'
282 # attribute => 'Wiki-Tag'
285 if ($self->testRegExpr($text, '[~]{3,4}', 0, 0, 0, undef, 0, '#stay', 'Wiki-Tag')) {
288 # String => '[-]{4,}'
289 # attribute => 'Wiki-Tag'
292 if ($self->testRegExpr($text, '[-]{4,}', 0, 0, 0, undef, 0, '#stay', 'Wiki-Tag')) {
295 # attribute => 'Wiki-Tag'
299 # type => 'DetectChar'
300 if ($self->testDetectChar($text, '!', 0, 0, 0, 0, 0, '#stay', 'Wiki-Tag')) {
307 my ($self, $text) = @_;
308 # attribute => 'Wiki-Tag'
312 # type => 'Detect2Chars'
313 if ($self->testDetect2Chars($text, '}', '}', 0, 0, 0, undef, 0, '#pop', 'Wiki-Tag')) {
316 # attribute => 'Error'
319 # type => 'DetectChar'
320 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, 'Error', 'Error')) {
327 my ($self, $text) = @_;
328 # attribute => 'Wiki-Tag'
331 # type => 'DetectChar'
332 if ($self->testDetectChar($text, ']', 0, 0, 0, undef, 0, '#pop', 'Wiki-Tag')) {
335 # attribute => 'Error'
338 # type => 'DetectChar'
339 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, 'Error', 'Error')) {
345 sub parseUnformatted {
346 my ($self, $text) = @_;
351 my ($self, $text) = @_;
352 # attribute => 'Wiki-Tag'
355 # type => 'DetectChar'
356 if ($self->testDetectChar($text, '|', 0, 0, 0, undef, 0, '#stay', 'Wiki-Tag')) {
359 # attribute => 'Wiki-Tag'
363 # type => 'Detect2Chars'
364 if ($self->testDetect2Chars($text, ']', ']', 0, 0, 0, undef, 0, '#pop', 'Wiki-Tag')) {
367 # attribute => 'Error'
370 # type => 'DetectChar'
371 if ($self->testDetectChar($text, '\'', 0, 0, 0, undef, 0, 'Error', 'Error')) {
378 my ($self, $text) = @_;
380 # attribute => 'Comment'
382 # endRegion => 'comment'
383 # type => 'StringDetect'
384 if ($self->testStringDetect($text, '-->', 0, 0, 0, undef, 0, '#pop', 'Comment')) {
391 my ($self, $text) = @_;
393 # attribute => 'Comment'
394 # beginRegion => 'comment'
395 # context => 'comment'
396 # type => 'StringDetect'
397 if ($self->testStringDetect($text, '<!--', 0, 0, 0, undef, 0, 'comment', 'Comment')) {
400 # String => '([=]{2,2}[^=]+[=]{2,2}|[=]{3,3}[^=]+[=]{3,3}|[=]{4,4}[^=]+[=]{4,4}|[=]{5,5}[^=]+[=]{5,5})'
401 # attribute => 'Section'
404 if ($self->testRegExpr($text, '([=]{2,2}[^=]+[=]{2,2}|[=]{3,3}[^=]+[=]{3,3}|[=]{4,4}[^=]+[=]{4,4}|[=]{5,5}[^=]+[=]{5,5})', 0, 0, 0, 0, 0, '#stay', 'Section')) {
407 # String => '[~]{3,4}'
408 # attribute => 'Wiki-Tag'
411 if ($self->testRegExpr($text, '[~]{3,4}', 0, 0, 0, undef, 0, '#stay', 'Wiki-Tag')) {
414 # String => '[*#;:\s]*[*#:]+'
415 # attribute => 'Wiki-Tag'
419 if ($self->testRegExpr($text, '[*#;:\\s]*[*#:]+', 0, 0, 0, 0, 0, '#stay', 'Wiki-Tag')) {
422 # String => '[[](?![[])'
423 # attribute => 'Wiki-Tag'
426 if ($self->testRegExpr($text, '[[](?![[])', 0, 0, 0, undef, 0, 'URL', 'Wiki-Tag')) {
429 # String => '(http:|ftp:|mailto:)[\S]*($|[\s])'
433 if ($self->testRegExpr($text, '(http:|ftp:|mailto:)[\\S]*($|[\\s])', 0, 0, 0, undef, 0, '#stay', 'URL')) {
436 # String => '[']{2,}'
437 # attribute => 'Wiki-Tag'
440 if ($self->testRegExpr($text, '[\']{2,}', 0, 0, 0, undef, 0, '#stay', 'Wiki-Tag')) {
443 # attribute => 'Wiki-Tag'
444 # beginRegion => 'table'
449 # type => 'Detect2Chars'
450 if ($self->testDetect2Chars($text, '{', '|', 0, 0, 0, 0, 0, 'Table', 'Wiki-Tag')) {
453 # attribute => 'Wiki-Tag'
456 # context => 'Template'
457 # type => 'Detect2Chars'
458 if ($self->testDetect2Chars($text, '{', '{', 0, 0, 0, undef, 0, 'Template', 'Wiki-Tag')) {
461 # attribute => 'Wiki-Tag'
464 # context => 'WikiLink'
465 # type => 'Detect2Chars'
466 if ($self->testDetect2Chars($text, '[', '[', 0, 0, 0, undef, 0, 'WikiLink', 'Wiki-Tag')) {
469 # attribute => 'HTML-Entity'
473 # type => 'RangeDetect'
474 if ($self->testRangeDetect($text, '&', ';', 0, 0, undef, 0, '#stay', 'HTML-Entity')) {
477 # String => '<nowiki>'
478 # attribute => 'Wiki-Tag'
479 # context => 'NoWiki'
480 # type => 'StringDetect'
481 if ($self->testStringDetect($text, '<nowiki>', 0, 0, 0, undef, 0, 'NoWiki', 'Wiki-Tag')) {
485 # attribute => 'HTML-Tag'
487 # type => 'StringDetect'
488 if ($self->testStringDetect($text, '<pre>', 0, 0, 0, undef, 0, 'Pre', 'HTML-Tag')) {
491 # String => '[<][^>]+[>]'
492 # attribute => 'HTML-Tag'
495 if ($self->testRegExpr($text, '[<][^>]+[>]', 0, 0, 0, undef, 0, '#stay', 'HTML-Tag')) {
500 # context => 'Unformatted'
502 if ($self->testRegExpr($text, '[\\s]', 0, 0, 0, 0, 0, 'Unformatted', undef)) {
515 Syntax::Highlight::Engine::Kate::Wikimedia - a Plugin for Wikimedia syntax highlighting
519 require Syntax::Highlight::Engine::Kate::Wikimedia;
520 my $sh = new Syntax::Highlight::Engine::Kate::Wikimedia([
525 Syntax::Highlight::Engine::Kate::Wikimedia is a plugin module that provides syntax highlighting
526 for Wikimedia to the Syntax::Haghlight::Engine::Kate highlighting engine.
528 This code is generated from the syntax definition files used
530 It works quite fine, but can use refinement and optimization.
532 It inherits Syntax::Higlight::Engine::Kate::Template. See also there.
538 Hans Jeuken (haje <at> toneel <dot> demon <dot> nl)
544 Unknown. If you find any, please contact the author