blog/_plugins/re_substitute.rb

13 lines
291 B
Ruby

# From <https://stackoverflow.com/a/25802375>.
module Jekyll
module RegexFilter
def re_substitute(input, reg_str, repl_str)
regexp = Regexp.new reg_str, Regexp::MULTILINE
input.gsub regexp, repl_str
end
end
end
Liquid::Template.register_filter(Jekyll::RegexFilter)