diff options
author | Joey Hess <joey@kitenet.net> | 2010-11-20 12:55:26 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-11-20 12:55:26 -0400 |
commit | af5f162ca7c8cd14d64f6282e05a3032dbd7c2fb (patch) | |
tree | 926150984baac3fdb505e2102c4011a18b8912b6 | |
parent | f8f8770a652520b2f09eb2262510a04a8e353e9d (diff) |
highlight: Support new format of filetypes.conf used by version 3.2 of the highlight package.
-rw-r--r-- | IkiWiki/Plugin/highlight.pm | 27 | ||||
-rw-r--r-- | debian/changelog | 2 |
2 files changed, 23 insertions, 6 deletions
diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm index 934e64bed..9d05e9fcf 100644 --- a/IkiWiki/Plugin/highlight.pm +++ b/IkiWiki/Plugin/highlight.pm @@ -96,14 +96,29 @@ my %highlighters; # Parse highlight's config file to get extension => language mappings. sub read_filetypes () { - open (IN, $config{filetypes_conf}) || error("$config{filetypes_conf}: $!"); - while (<IN>) { - chomp; - if (/^\$ext\((.*)\)=(.*)$/) { - $ext2lang{$_}=$1 foreach $1, split ' ', $2; + open (my $f, $config{filetypes_conf}) || error("$config{filetypes_conf}: $!"); + local $/=undef; + my $config=<$f>; + close $f; + + # highlight >= 3.2 format (bind-style) + while ($config=~m/Lang\s*=\s*\"([^"]+)\"[,\s]+Extensions\s*=\s*{([^}]+)}/sg) { + my $lang=$1; + foreach my $bit (split ',', $2) { + $bit=~s/.*"(.*)".*/$1/s; + $ext2lang{$bit}=$lang; } } - close IN; + + # highlight < 3.2 format + if (! keys %ext2lang) { + foreach (split("\n", $config)) { + if (/^\$ext\((.*)\)=(.*)$/) { + $ext2lang{$_}=$1 foreach $1, split ' ', $2; + } + } + } + $filetypes_read=1; } diff --git a/debian/changelog b/debian/changelog index 65c235317..ecd028a0c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ ikiwiki (3.20101113) UNRELEASED; urgency=low (Which doesn't include html5 just yet, but then the old version didn't either.) Bonus: 4 times faster than old regexp method. * Optimise glob() pagespec. (Thanks, Kathryn and smcv) + * highlight: Support new format of filetypes.conf used by version 3.2 + of the highlight package. -- Joey Hess <joeyh@debian.org> Tue, 16 Nov 2010 14:23:47 -0400 |