Skip to content

Instantly share code, notes, and snippets.

@llelf
Created September 5, 2013 12:24
Show Gist options
  • Save llelf/6449417 to your computer and use it in GitHub Desktop.
Save llelf/6449417 to your computer and use it in GitHub Desktop.
use Modern::Perl;
while (<>) {
# Kill
s{<abr>\w+</abr> \s+ <rref>.*wav</rref>}{}xg;
s{<rref>.*\.(wav|jpg)</rref>}{}g;
# Head
s{<k>.*</k>}{};
my $pron = qr{(?:[^<>]|<i>|</i>)+};
s{ /($pron)/([[:punct:][:space:]])}{ <span class="pr">| $1 |</span>$2}g;
# s{<span class="pr">\| ($pron) \$ ($pron) \|</span>}
# {<span class="pr">| $1 |<span>, <span class="pr">| $2 |</span>}g;
#s{<c c="blue">((?:.(!?</c>))+.)</c>}{<span class="h">$1</span>};
s{^(?:<blockquote>){2} (.*) (?:</blockquote>){2}}{<div class="topquote">$1</div>}x;
s{<b>(\d+)</b>\.}{$1};
s{^<b>[[:upper:]]+\.</b>}{};
s{<ex>((?:.(?!</ex>))*.)</ex>}{<span class="ex">$1</span>}g;
s{ – }{ — }g;
my $def = qr{<b><c c="dimgray">([\w\s/]+)</c></b>};
s{$def}{<span class="def">\L$1\E</span>}g;
s{<i>(\s?\w+)</i>}{<i>$1 </i>}g;
# Requote
my $topquote = qr{<div class="topquote">};
s{$topquote ((?:<blockquote>){2})}{<div class="topquote q2">$1}x;
s{$topquote (<blockquote>)}{<div class="topquote q1">$1}x;
print;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment