annotate Paper/escape_agda.rb @ 5:339fb67b4375

INIT rbt.agda
author soto <soto@cr.ie.u-ryukyu.ac.jp>
date Sun, 07 Nov 2021 00:51:16 +0900
parents 9176dff8f38a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #!/usr/bin/env ruby
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 # coding: utf-8
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 Suffix = '.agda.replaced'
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
5 EscapeChar = '!'
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 FileName = ARGV.first
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 ReplaceTable = {
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 '→' => 'rightarrow',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 '->' => 'rightarrow',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 '⊔' => 'sqcup',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 '∷' => 'text{::}',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 '∙' => 'circ',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 '≡' => 'equiv',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 '×' => 'times',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 '⟨' => 'langle',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 '⟩' => 'rangle',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 'ℕ' => 'mathbb{N}',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 '₁' => '_{1}',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 '₂' => '_{2}',
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
21 '₃' => '_{3}',
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 '∎' => 'blacksquare',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 'λ' => 'lambda',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 '∧' => 'wedge',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 '/\\' => 'wedge',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 '⇒' => 'Rightarrow',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 '¬' => 'neg',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 '≤' => 'leq',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 '⊥' => 'bot',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 '∀' => 'forall',
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 '#' => '\#',
2
9176dff8f38a ADD while loop description
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
32 '⊤' => '\top',
5
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
33 '\'' => '\prime',
339fb67b4375 INIT rbt.agda
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
34 '≈' => '\approx'
0
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 }
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 code = File.read(FileName)
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 ReplaceTable.each do |k, v|
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 escaped_str = EscapeChar + "$\\#{v}$" + EscapeChar
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 code = code.gsub(k, escaped_str)
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 end
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 File.write(FileName.sub(/.agda$/, Suffix), code)