Mercurial > hg > Papers > 2021 > soto-prosym
view Paper/escape_agda.rb @ 14:393c839f987b default tip
DONE
author | soto <soto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 08 Jan 2022 12:41:39 +0900 |
parents | 339fb67b4375 |
children |
line wrap: on
line source
#!/usr/bin/env ruby # coding: utf-8 Suffix = '.agda.replaced' EscapeChar = '!' FileName = ARGV.first ReplaceTable = { '→' => 'rightarrow', '->' => 'rightarrow', '⊔' => 'sqcup', '∷' => 'text{::}', '∙' => 'circ', '≡' => 'equiv', '×' => 'times', '⟨' => 'langle', '⟩' => 'rangle', 'ℕ' => 'mathbb{N}', '₁' => '_{1}', '₂' => '_{2}', '₃' => '_{3}', '∎' => 'blacksquare', 'λ' => 'lambda', '∧' => 'wedge', '/\\' => 'wedge', '⇒' => 'Rightarrow', '¬' => 'neg', '≤' => 'leq', '⊥' => 'bot', '∀' => 'forall', '#' => '\#', '⊤' => '\top', '\'' => '\prime', '≈' => '\approx' } code = File.read(FileName) ReplaceTable.each do |k, v| escaped_str = EscapeChar + "$\\#{v}$" + EscapeChar code = code.gsub(k, escaped_str) end File.write(FileName.sub(/.agda$/, Suffix), code)