Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
9 lines (7 sloc) 265 Bytes
# call with ruby -p -i.bak
BEGIN {
require 'yaml'
$p = YAML.load_file(ENV['PASTIE_FILE_NAME'] || 'pasties.yml')
PAT = /\\codefile(figure)?\s*(?:\[\w*\])?\{([^}]+)\}/
}
$_.gsub!(PAT, "\\codefile#{$1}[#{$p[$2]['url']}]{#{$2}}") if $_ =~ PAT && $p.has_key?($2)