comparison Paper/escape_agda.rb @ 8:35d15c091cfd

fix Makefile export .agda.replaced,and main document
author ryokka
date Mon, 23 Apr 2018 21:44:32 +0900
parents
children
comparison
equal deleted inserted replaced
7:06a1339fbda4 8:35d15c091cfd
1 #!/usr/bin/env ruby
2
3 Suffix = '.agda.replaced'
4 EscapeChar = '@'
5 FileName = ARGV.first
6
7 ReplaceTable = {
8 '->' => 'rightarrow',
9 '⊔' => 'sqcup',
10 '∷' => 'text{::}',
11 '∙' => 'circ',
12 '≡' => 'equiv',
13 '×' => 'times',
14 '⟨' => 'langle',
15 '⟩' => 'rangle',
16 '₁' => 'text{1}',
17 'ℕ' => 'mathbb{N}',
18 '∎' => 'blacksquare'
19 }
20
21 code = File.read(FileName)
22 ReplaceTable.each do |k, v|
23 escaped_str = EscapeChar + "$\\#{v}$" + EscapeChar
24 code = code.gsub(k, escaped_str)
25 end
26
27 File.write(FileName.sub(/.agda$/, Suffix), code)