Mercurial > hg > Papers > 2022 > kiyama-sigos
comparison Paper/escape_agda.rb @ 0:78fab99c6008
定期
author | kiyama <e185758@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 05 May 2022 01:40:29 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:78fab99c6008 |
---|---|
1 #!/usr/bin/env ruby | |
2 # coding: utf-8 | |
3 | |
4 Suffix = '.agda.replaced' | |
5 EscapeChar = '!' | |
6 FileName = ARGV.first | |
7 | |
8 ReplaceTable = { | |
9 '→' => 'rightarrow', | |
10 '->' => 'rightarrow', | |
11 '⊔' => 'sqcup', | |
12 '∷' => 'text{::}', | |
13 '∙' => 'circ', | |
14 '≡' => 'equiv', | |
15 '×' => 'times', | |
16 '⟨' => 'langle', | |
17 '⟩' => 'rangle', | |
18 'ℕ' => 'mathbb{N}', | |
19 '₁' => '_{1}', | |
20 '₂' => '_{2}', | |
21 '₃' => '_{3}', | |
22 '∎' => 'blacksquare', | |
23 'λ' => 'lambda', | |
24 '∧' => 'wedge', | |
25 '/\\' => 'wedge', | |
26 '⇒' => 'Rightarrow', | |
27 '¬' => 'neg', | |
28 '≤' => 'leq', | |
29 '⊥' => 'bot', | |
30 '∀' => 'forall', | |
31 '#' => '\#', | |
32 '⊤' => '\top', | |
33 '\'' => '\prime', | |
34 '≈' => '\approx' | |
35 } | |
36 | |
37 code = File.read(FileName) | |
38 ReplaceTable.each do |k, v| | |
39 escaped_str = EscapeChar + "$\\#{v}$" + EscapeChar | |
40 code = code.gsub(k, escaped_str) | |
41 end | |
42 | |
43 File.write(FileName.sub(/.agda$/, Suffix), code) |