File: hlansi.pl

package info (click to toggle)
libsyntax-highlight-engine-kate-perl 0.14%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,844 kB
  • sloc: perl: 84,065; ruby: 176; asm: 166; cpp: 144; jsp: 128; haskell: 116; sh: 111; f90: 99; python: 98; ml: 75; javascript: 61; xml: 43; yacc: 37; ansic: 32; tcl: 29; lisp: 24; makefile: 15; awk: 13; php: 5
file content (53 lines) | stat: -rwxr-xr-x 1,723 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl -w

# Copyright (c) 2005 Hans Jeuken. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.

use strict;
use Term::ANSIColor;

use Syntax::Highlight::Engine::Kate;


unless (@ARGV) { die "You must supply a syntax mode as parameter" };
my $syntax = shift @ARGV;

my $hl = new Syntax::Highlight::Engine::Kate(
	language => $syntax,
	substitutions => {
		"\n" => color('reset') . "\n",
	},
	format_table => {
		Alert => [color('white bold on_green'), color('reset')],
		BaseN => [color('green'), color('reset')],
		BString => [color('red bold'), color('reset')],
		Char => [color('magenta'), color('reset')],
		Comment => [color('white bold on_blue'), color('reset')],
		DataType => [color('blue'), color('reset')],
		DecVal => [color('blue bold'), color('reset')],
		Error => [color('yellow bold on_red'), color('reset')],
		Float => [color('blue bold'), color('reset')],
		Function => [color('yellow bold on_blue'), color('reset')],
		IString => [color('red'), color('reset')],
		Keyword => [color('bold'), color('reset')],
		Normal => [color('reset'), color('reset')],
		Operator => [color('green'), color('reset')],
		Others => [color('yellow bold on_green'), color('reset')],
		RegionMarker => [color('black on_yellow bold'), color('reset')],
		Reserved => [color('magenta on_blue'), color('reset')],
		String => [color('red'), color('reset')],
		Variable => [color('blue on_red bold'), color('reset')],
		Warning => [color('green bold on_red'), color('reset')],
		
	},
);

my $newline = color('reset') . "\n";

while (my $in = <>) {
#	print $in;
	my $res = $hl->highlightText($in);
#	$res =~ s/\n/$newline/g;
	print $res;
}