#!/usr/bin/env perl
use strict;
use warnings;
use 5.10.0;
use Text::Markdown::Discount;
# Enable html5 block-level tags:
Text::Markdown::Discount::with_html5_tags();
my $flags = Text::Markdown::Discount::MKD_EXTRA_FOOTNOTE();
my $markdown = Text::Markdown::Discount->new;
my $full_source = '';
while (my $source = get_input()) {
$full_source .= $source;
}
print replace_some_stuff($markdown->markdown($full_source, $flags));
sub get_input {
local $/ = undef;
my $source = <>;
return $source;
}
# Super cheeseball, man.
sub replace_some_stuff {
my ($markup) = @_;
$markup =~ s{<\^>(.*?)<\^>}{$1}g;
$markup =~ s{\[label (.*?)\]}{$1
}g;
$markup =~ s{\[secondary_label (.*?)\]}{$1
}g;
return $markup;
}