2006-09-21 22:28:40 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
package IkiWiki::Plugin::typography;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2008-12-23 22:34:19 +01:00
|
|
|
use IkiWiki 3.00;
|
2006-09-21 22:28:40 +02:00
|
|
|
|
2008-12-17 21:22:16 +01: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);
|
2010-02-12 10:01:04 +01:00
|
|
|
hook(type => "sanitize", id => "typography", call => \&sanitize);
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2006-09-21 22:28:40 +02:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub getopt () {
|
2007-06-05 21:04:15 +02:00
|
|
|
eval q{use Getopt::Long};
|
|
|
|
error($@) if $@;
|
|
|
|
Getopt::Long::Configure('pass_through');
|
|
|
|
GetOptions("typographyattributes=s" => \$config{typographyattributes});
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2007-06-05 21:04:15 +02:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub getsetup () {
|
2008-07-26 06:38:13 +02:00
|
|
|
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,
|
|
|
|
},
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2008-07-26 06:38:13 +02:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub sanitize (@) {
|
2006-09-21 22:28:40 +02:00
|
|
|
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);
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2006-09-21 22:28:40 +02:00
|
|
|
|
|
|
|
1
|