comparison Paper/escape_agda.rb @ 0:c59202657321

init
author soto <soto@cr.ie.u-ryukyu.ac.jp>
date Tue, 02 Nov 2021 06:55:58 +0900
parents
children 9176dff8f38a
comparison
equal deleted inserted replaced
-1:000000000000 0:c59202657321
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 '∎' => 'blacksquare',
22 'λ' => 'lambda',
23 '∧' => 'wedge',
24 '/\\' => 'wedge',
25 '⇒' => 'Rightarrow',
26 '¬' => 'neg',
27 '≤' => 'leq',
28 '⊥' => 'bot',
29 '∀' => 'forall',
30 '#' => '\#',
31 '⊤' => '\top'
32 }
33
34 code = File.read(FileName)
35 ReplaceTable.each do |k, v|
36 escaped_str = EscapeChar + "$\\#{v}$" + EscapeChar
37 code = code.gsub(k, escaped_str)
38 end
39
40 File.write(FileName.sub(/.agda$/, Suffix), code)