2006-09-21 22:28:40 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
package IkiWiki::Plugin::typography;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2007-04-27 04:55:52 +02:00
|
|
|
use IkiWiki 2.00;
|
2006-09-21 22:28:40 +02:00
|
|
|
|
|
|
|
sub import { #{{{
|
2007-06-05 21:04:15 +02:00
|
|
|
hook(type => "getopt", id => "typography", call => \&getopt);
|
2008-07-26 06:38:13 +02:00
|
|
|
hook(type => "getsetup", id => "typography", call => \&getsetup);
|
2006-09-21 22:28:40 +02:00
|
|
|
IkiWiki::hook(type => "sanitize", id => "typography", call => \&sanitize);
|
|
|
|
} # }}}
|
|
|
|
|
2007-06-05 21:04:15 +02:00
|
|
|
sub getopt () { #{{{
|
|
|
|
eval q{use Getopt::Long};
|
|
|
|
error($@) if $@;
|
|
|
|
Getopt::Long::Configure('pass_through');
|
|
|
|
GetOptions("typographyattributes=s" => \$config{typographyattributes});
|
|
|
|
} #}}}
|
|
|
|
|
2008-07-26 06:38:13 +02:00
|
|
|
sub getsetup () { #{{{
|
|
|
|
eval q{use Text::Typography};
|
|
|
|
error($@) if $@;
|
|
|
|
|
|
|
|
return
|
2008-08-04 01:35:35 +02:00
|
|
|
plugin => {
|
|
|
|
safe => 1,
|
|
|
|
rebuild => 1,
|
|
|
|
},
|
2008-07-26 06:38:13 +02:00
|
|
|
typographyattributes => {
|
|
|
|
type => "string",
|
2008-07-27 03:07:15 +02:00
|
|
|
example => "3",
|
2008-07-26 06:38:13 +02:00
|
|
|
description => "Text::Typography attributes value",
|
2008-08-03 20:57:24 +02:00
|
|
|
advanced => 1,
|
2008-07-26 06:38:13 +02:00
|
|
|
safe => 1,
|
|
|
|
rebuild => 1,
|
|
|
|
},
|
|
|
|
} #}}}
|
|
|
|
|
2006-09-21 22:28:40 +02:00
|
|
|
sub sanitize (@) { #{{{
|
|
|
|
my %params=@_;
|
|
|
|
|
2006-09-26 08:08:24 +02:00
|
|
|
eval q{use Text::Typography};
|
2008-07-26 06:45:21 +02:00
|
|
|
return $params{content} if $@;
|
2006-09-26 08:08:24 +02:00
|
|
|
|
2007-06-05 21:04:15 +02:00
|
|
|
my $attributes=defined $config{typographyattributes} ? $config{typographyattributes} : '3';
|
|
|
|
return Text::Typography::typography($params{content}, $attributes);
|
2006-09-21 22:28:40 +02:00
|
|
|
} # }}}
|
|
|
|
|
|
|
|
1
|