Initial commit
This commit is contained in:
commit
009dd95b2a
3 changed files with 27 additions and 0 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "smiley"]
|
||||
path = smiley
|
||||
url = git@git.anduin.net:ltning/emoji_to_smiley
|
||||
23
conv.py
Normal file
23
conv.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from smiley import smiley
|
||||
from html.entities import codepoint2name
|
||||
|
||||
def retrohtml(text):
|
||||
new_text_list = []
|
||||
for character in text:
|
||||
code_point = ord(character)
|
||||
if code_point < 128:
|
||||
new_text_list.append(character)
|
||||
else:
|
||||
try:
|
||||
new_text_list.append(f"&{codepoint2name[code_point]};")
|
||||
except KeyError:
|
||||
# And fall back to a numeric entity
|
||||
new_text_list.append(f"&#{code_point};")
|
||||
return "".join(new_text_list).strip()
|
||||
|
||||
for line in sys.stdin:
|
||||
line=smiley.replace_emoji(line)
|
||||
line=retrohtml(line)
|
||||
print(line)
|
||||
1
smiley
Submodule
1
smiley
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 483da44672613d011dac1025899e344830a841bd
|
||||
Loading…
Add table
Add a link
Reference in a new issue