Created
June 2, 2011 00:12
-
-
Save pcreux/1003649 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 | |
str = File.read('CHANGELOG.md') | |
people = [] | |
str.each_line do |l| | |
found = l.match(/\[@(\w+)\]\(([\w:\/.]+)\)/) | |
if found | |
user = found[1] | |
url = found[2] | |
people << [user, url] unless people.include? [user, url] | |
end | |
end | |
people.sort! { |p1, p2| p1.first <=> p2.first } | |
puts str.gsub(/\[@(\w+)\]\(([\w:\/.]+)\)/, '[@\1][]') | |
puts "" | |
people.each do |user, url| | |
puts "[@#{user}]: #{url}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sweet!!