Anki-Import
view release on metacpan or search on metacpan
lib/Anki/Import.pm view on Meta::CPAN
# enter whitespace mode and adding appropriate HTML
if ($line =~ /^`{3,3}$/ && !$ws_mode) {
$ws_mode = 1;
# add a couple of blank lines to previous line
if ($$last_line) {
$$last_line .= '<br><br>';
}
$$last_line .= '<div style="text-align: left; font-family: courier; white-space: pre;">';
next;
}
# exit whitespace mode, close out HTML, add blank lines
if ($line =~ /^`{3,3}$/ && $ws_mode) {
$ws_mode = 0;
$$last_line .= "</div><br><br>";
next;
}
lib/Anki/Import.pm view on Meta::CPAN
my $count = 0;
foreach my $part (@$parts) {
$count++;
next if ($count % 2); # only substitute on odd number array items
$part =~ s/</</g;
}
$field = join '`', @$parts;
# backticked characters
$field =~ s/(?<!\\)`(.*?)`/<span style="font-family: courier; weight: bold;">$1<\/span>/gm;
$field =~ s/\\`/`/g;
# bold
$field =~ s/(?<!\\)\*(.*?)\*/<span style="weight: bold;">$1<\/span>/gm;
$field =~ s/\\\*/*/g;
# unordered lists
$field =~ s'(?<!\\)%(.*?)%'"<ul><li>" . join ("</li><li>", (split (/,\s*/, $1))) . "</li><\/ul>"'gme;
$field =~ s/\\%/%/g;
( run in 0.473 second using v1.01-cache-2.11-cpan-5735350b133 )