Created
May 10, 2020 02:24
-
-
Save LadyAleena/9516ea9bfdb5999bbf1ed6444fe8115c to your computer and use it in GitHub Desktop.
LA's textify subroutine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub textify { | |
my ($text, $opt) = @_; | |
my $root_link = base_path('link'); | |
$text =~ s/$root_link\///; | |
$text =~ s/_/ /g; | |
$text =~ s/(?<!Rev\s)\b([DMSJ][rsx]|Mrs|Rev)\b(?!\.)/$1./g; | |
$text =~ s/\s&\s/ & /g; | |
$text =~ s/\.{3}/…/g; | |
$text =~ s/(\w|\b|\s|^)'(\w|\b|\s|$)/$1ʼ$2/g; | |
$text =~ s/<.+?>//g unless ($opt->{'html'} && $opt->{'html'} =~ /^[ytk1]/); | |
$text =~ s/\s\(.*?\)$// unless ($opt->{'parens'} && $opt->{'parens'} =~ /^[ytk1]/); | |
$text =~ s/\.\w{2,5}?$// unless $text =~ /\.(?:com|net|org)$/; | |
# $text =~ s/(?<!\A)((?<! )\p{uppercase})/ $1/g; # from Kenosis, kcott, and tye on PerlMonks | |
return encode('UTF-8',$text); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment