#!/usr/bin/env ruby replace_table = { '->' => 'rightarrow', '∙' => 'circ', '≡' => 'equiv', '×' => 'times', '⟨' => 'langle', '⟩' => 'rangle', '∎' => 'blacksquare' } footer = '.replaced' sources = Dir.glob('src/*.agda') sources.each do |src| code = File.read(src) replace_table.each do |k, v| code = code.gsub(k, "@$\\#{v}$@" ) end File.write(src+footer , code) end