diff --git a/Webperl/Template.pm b/Webperl/Template.pm index ced0ecc..7766611 100644 --- a/Webperl/Template.pm +++ b/Webperl/Template.pm @@ -884,7 +884,7 @@ sub format_time { $datestr =~ s/(\d+)\s*%o/ordinal($1)/ge; # Trim leading zeros, as they are pointless - $datestr =~ s/(\A|\D)0+([1-9])/$1$2/g; + $datestr =~ s/(\A|\b)0+([1-9])/$1$2/g; return $datestr; } @@ -1035,6 +1035,9 @@ sub html_to_markdown { # Sometimes there are bizarre <>s left in the content, dunno why... $body =~ s|<>||g; + # Fix underscores in links + $body =~ s|\[([^\]+)\]|_fix_link_underscores($1)|g; + $body =~ s|\n\n+|\n\n|g; my $imglist = ""; @@ -1080,6 +1083,14 @@ sub _markdown_underline { } +sub _fix_link_underscores { + my $text = shift; + + $text =~ s/\\_/_/g; + return $text; +} + + ## @method $ bytes_to_human($bytes, $long) # Convenience wrappper around humanise_bytes for backwards compatibility. #