-
-
Save rymai/1003676 to your computer and use it in GitHub Desktop.
Convert markdown inline links to link definitions
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
# For https://github.com/guard/guard/blob/master/CHANGELOG.md | |
input, output, people = File.read('CHANGELOG.md'), "", {} | |
input.each_line do |line| | |
if found = line.match(/\[@(\w+)\]\(([\w:\/.]+)\)/) | |
user, url = found[1], found[2] | |
people[user] = url unless people.include?(user) | |
end | |
end | |
people = people.sort { |p1, p2| p1[0] <=> p2[0] } | |
output += input.gsub(/\[@(\w+)\]\(([\w:\/.]+)\)/, '[@\1][]') | |
output += "\n" | |
people.each do |user, url| | |
output += "[@#{user}]: #{url}\n" | |
end | |
puts output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment