/
greeklit.ls
executable file
·55 lines (49 loc) · 1000 Bytes
/
greeklit.ls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env livescript
# Sort of “leet speak” stuff, but for russian letters.
#
# greeklit 'привет'
# # => 'nρuвеm' is copied to clipboard.
#
# Could be freely distributed under the terms of MIT License.
# Copyright (c) 2012 Paul Miller (paulmillr.com)
prelude = require 'prelude-ls'
prelude.installPrelude(global)
chars =
'а': 'α'
'б': '6'
'в': null
'г': 'r'
'д': 'g'
'е': 'е'
'ж': null
'з': 'ʒ'
'и': 'u'
'к': null
'л': 'ʌ'
'м': 'ʍ'
'н': null
'о': 'о'
'п': 'n'
'р': 'ρ'
'с': 'с'
'т': 'm'
'у': 'у'
'ф': null
'х': null
'ш': 'ɯ'
'щ': 'ϣ'
'ч': null
'э': null
'ю': null
'я': null
replace = (list-of-chars) ->
list-of-chars |> map ((char) -> chars[char] ? char)
read-stdin = ->
process.open-stdin!
process.stdin.on 'data', (buffer) ->
process.stdout.write "#{replace buffer.to-string!}"
text = process.argv[2]
if text?
process.stdout.write "#{replace text}\n"
else
read-stdin!