Created
April 29, 2014 09:11
-
-
Save jcenters/11394815 to your computer and use it in GitHub Desktop.
Markdown lazy link counter.
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
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use diagnostics; | |
# Counts Markdown lazy link references and compares against linked | |
# URLs. Helps check for unclosed links. | |
# Serving Suggestions: Pipe text into lazylink_converter.pl | |
# from the command line or install as a BBEdit Text Filter. | |
# 2014 Josh Centers. http://joshcenters.com/ | |
my $text; # Our hero, the $text variable. | |
local $/; # Grab all the text. | |
$text = <>; # Assign STDIN to our hero. | |
my $link_count = () = $text =~ m/\[.+?\]\[\*\]/g; | |
my $url_count = () = $text =~ m/\[\*\]\:/g; | |
unless ($link_count == $url_count) { | |
warn "You have $link_count links and $url_count matching URLs. Check your links and try again.\n"; | |
} | |
else { print $text; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment