Skip Menu |

This queue is for tickets about the Syntax-Highlight-Engine-Kate CPAN distribution.

Report information
The Basics
Id: 84982
Status: resolved
Priority: 0/
Queue: Syntax-Highlight-Engine-Kate

People
Owner: Nobody in particular
Requestors: Jeff.Fearn [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.07
Fixed in: 0.08



Subject: Support case insensitive names [patch]
Hi, due to our tool having to accept upstream sources for input we need to handle insesitive name matches. Attached is a patch to languagePlug that allows this behaviour. It defaults to the current behiour. Cheers, Jeff.
Subject: insensitive.patch
--- Syntax-Highlight-Engine-Kate-0.07/lib/Syntax/Highlight/Engine/Kate.pm 2012-09-23 20:01:18.000000000 +1000 +++ Syntax-Highlight-Engine-Kate-inse/lib/Syntax/Highlight/Engine/Kate.pm 2013-05-02 11:47:22.117779928 +1000 @@ -616,11 +616,30 @@ } sub languagePlug { - my ($self, $req) = @_; + my ($self, $req, $insensitive) = @_; + unless (exists($self->{'syntaxes'}->{$req})) { - warn "undefined language: $req"; - return undef; + if (defined($insensitive) && $insensitive) { + my $matched = 0; + foreach my $key (keys(%{$self->{'syntaxes'}})) { + if ($key =~ /^$req$/i) { + warn "substituting language $key for $req"; + $req = $key; + $matched = 1; + last; + } + } + + unless ($matched) { + warn "undefined language: $req"; + return undef; + } + } else { + warn "undefined language: $req"; + return undef; + } } + return $self->{'syntaxes'}->{$req}; } @@ -804,9 +823,13 @@ returns a list of languages for which plugins have been defined. -=item B<languagePlug>(I<$language>); +=item B<languagePlug>(I<$language>, I<?$insensitive?>); + +Returns the module name of the plugin for B<$language>. + +If B<$insensitive> is set it will also try to match names ignoring case and return the correct module name of the plugin. -returns the module name of the plugin for B<$language> +e.g. $highlighter->languagePlug('HtMl', 1); will return 'HTML'. =item B<languagePropose>(I<$filename>);
Thanks for the patch. Could you please fork this repository and send me a pull request there? https://github.com/szabgab/Syntax-Highlight-Engine-Kate
Done, sorry for the delay.
On Tue Jul 09 19:11:06 2013, jfearn wrote: Show quoted text
> Done, sorry for the delay.
Hi Gabor, Now that the patch has been pulled in, would it be possible to have a new release of the module to avoid having to carry over that patch in distro packages, such as Fedora's? Thanks in advance, best regards, J. -- Jérôme Fenal - jfenal at free dot fr http://fenal.org/ - http://search.cpan.org/~jfenal/
fixed in 0.09