<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl

package IkiWiki::Plugin::typography;

use warnings;
use strict;
use IkiWiki 3.00;

sub import {
	hook(type =&gt; "getopt", id =&gt; "typography", call =&gt; \&amp;getopt);
	hook(type =&gt; "getsetup", id =&gt; "typography", call =&gt; \&amp;getsetup);
	hook(type =&gt; "sanitize", id =&gt; "typography", call =&gt; \&amp;sanitize);
}

sub getopt () {
	eval q{use Getopt::Long};
	error($@) if $@;
	Getopt::Long::Configure('pass_through');
	GetOptions("typographyattributes=s" =&gt; \$config{typographyattributes});
}

sub getsetup () {
	eval q{use Text::Typography};
	error($@) if $@;

	return
		plugin =&gt; {
			safe =&gt; 1,
			rebuild =&gt; 1,
		},
		typographyattributes =&gt; {
			type =&gt; "string",
			example =&gt; "3",
			description =&gt; "Text::Typography attributes value",
			advanced =&gt; 1,
			safe =&gt; 1,
			rebuild =&gt; 1,
		},
}

sub sanitize (@) {
	my %params=@_;

	eval q{use Text::Typography};
	return $params{content} if $@;

	my $attributes=defined $config{typographyattributes} ? $config{typographyattributes} : '3';
	return Text::Typography::typography($params{content}, $attributes);
}

1
</pre></body></html>