Introduce markdown renderer for templates
Change-Id: Ia0166b5c7f3b80f70902c97653e517968d39dcf5
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index e7174f0..0d835e9 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -280,6 +280,19 @@
$self->plugin($_);
};
+ $self->plugin('Markdown' => {
+ link_callback => sub {
+ my ($c, $url, $text) = @_;
+ if ($url =~ m{^https?://}) {
+ # $text is already-rendered HTML from the Markdown converter (it may
+ # contain inline markup such as <em>/<code>), so mark it safe to keep
+ # link_to from escaping it back to visible tags.
+ return $c->ext_link_to(b($text), $url)->to_string;
+ }
+ return undef;
+ },
+ });
+
my $serializer = 'JSON';
if (my $chi = $self->config('CHI')) {