text-highlight

 view release on metacpan or  search on metacpan

lib/Text/Highlight.pm  view on Meta::CPAN

		blockCommentOn => [],
		lineComment => [],
		quot => [],
	);
	#attempt to open grammar file
	open FH, $grammar or croak "Cannot open '$grammar' to find syntax for '$type': $!";
	
	if($format eq 'editplus') {
		_get_syntax_editplus(\%syntax, \*FH);
	}
	elsif($format eq 'ultraedit') {
		_get_syntax_ultraedit(\%syntax, \*FH);
	}
	#else return a non-function yet parsable %syntax, might be desired?
	
	close FH;
	$self->{_grammars}{$type} = \%syntax;
	
	#dump the syntax table to stderr (less screen space than Data::Dumper)
	#print STDERR "$_ : ".((ref $syntax{$_} eq 'HASH') ? join(' | ', keys %{$syntax{$_}}) : (ref $syntax{$_} eq 'ARRAY') ? join(' | ', @{$syntax{$_}}) : $syntax{$_})."\n" for(keys %syntax);

	return $self->{_grammars}{$type};

lib/Text/Highlight.pm  view on Meta::CPAN

				} else {
					$syntax->{"key$key"}{lc($_)} = $_;
				}
			}
			$key++;             #for next potential key group
			redo unless(eof);   #back to the top of the while without hitting <FILE> again, assuming not EOF
		}
	}
}

sub _get_syntax_ultraedit
{
	my $syntax = shift;
	my $FH = shift;
	
	#make sure we break on newlines
	local $/ = "\n";
		
	while(<$FH>)
	{
		$syntax->{name} = $1                   if(/^\/L\d+"(.+?)"/i);

lib/Text/Highlight.pm  view on Meta::CPAN

=back

C<< grammar => $filename | \%syntax >>

=over 4

C<grammar> can be one of two things: the filename containing the syntax, or a hashref to an already parsed language syntax. If a filename, the file must contain only a single language syntax definition. Though some editors allow multiple language def...

=back

C<< format => 'editplus' | 'ultraedit' >>

=over 4

C<format> is a string specifying which format the syntax definition in the file is in. It is not used if C<grammar> is a hashref, but is required if it is a filename. Currently, it must be set to one of the following strings: 'editplus' 'ultraedit'

The syntax for a language is set to the following default hash before parsing the file. This means if any of the options are not set in the syntax file, the default specified here is used instead. If C<format> is not set to a valid string, this defau...

  { name => 'Unknown-type',
    escape => '\\',
    case => 1,
    continueQuote => 0,
    blockCommentOn => [],
    lineComment => [],
    quot => [],



( run in 0.244 second using v1.01-cache-2.11-cpan-ec4f86ec37b )