#! /usr/bin/env perl # # Re-generate hyperlinks in place: # # perl -i scripts/markdown-hyperlinks.pl CHANGELOG.md # # Generate to another file: # # scripts/markdown-hyperlinks.pl CHANGELOG.md > CHANGELOG-autolink.md use strict; use warnings; my $user = qr/ [a-zA-Z] [a-zA-Z0-9]* /x; my $repo = qr/ [a-zA-Z] [a-zA-Z0-9.-]* /x; while (<>) { # make links from @username references # (except when escaped like \@foobar or in code like `where !@barman! = 'Moe'`) s"(?: (`++) .*? \g{-1} (*SKIP) (*FAIL) )? # skip over code spans (?