Skip to content

Instantly share code, notes, and snippets.

@preaction
Created December 5, 2020 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save preaction/623a1395ca7ee1cdf8a81663ee06655f to your computer and use it in GitHub Desktop.
Save preaction/623a1395ca7ee1cdf8a81663ee06655f to your computer and use it in GitHub Desktop.
sub register( $self, $site ) {
$site->on( build => sub( $event ) {
for my $page ( $event->pages->@* ) {
$page->dom->find( 'img[src$=.mp3]' )->each( sub( $el ) {
$el->replace( '<audio controls><source type="audio/mp3" src="%s"></audio>', $el->attr( 'src' ) );
} );
}
} );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment