Add a script for tidying up my twemoji
- ID
68b2aea- date
2024-01-02 09:53:33+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
45395d4- message
Add a script for tidying up my twemoji- changed files
3 files, 51 additions, 5 deletions
Changed files
config.fish (5535) → config.fish (5584)
diff --git a/config.fish b/config.fish
index 8369f33..2ba9ace 100644
--- a/config.fish
+++ b/config.fish
@@ -160,6 +160,7 @@ __create_python_script_alias images/images_only_pdf.py
__create_python_script_alias images/srgbify.py
__create_python_script_alias images/reborder.py
__create_python_script_alias images/tint_image.py
+__create_python_script_alias text/fix_twemoji.py
__create_python_script_alias text/fix_twitter_thread.py
__create_python_script_alias text/noplaylist.py
__create_python_script_alias text/sumsizes.py
text/README.md (6152) → text/README.md (6816)
diff --git a/text/README.md b/text/README.md
index 3af6d72..409fe0f 100644
--- a/text/README.md
+++ b/text/README.md
@@ -25,9 +25,16 @@ scripts = [
""",
},
{
+ "usage": "fix_twemoji.py [PATH]",
+ "description": """
+ when I copy/paste a tweet into Obsidian, often any emoji get replaced by "twemoji" – links to Twitter’s custom emoji artwork.
+ This script replaces those links with vanilla emoji characters.
+ """,
+ },
+ {
"usage": "fix_twitter_thread.py [PATH]",
"description": """
- when I copy/paste a Twitter thread into Obsidian, this does some
+ when I copy/paste a Twitter thread into Obsidian, this does some
initial tidying up of the formatting for me.
""",
},
@@ -43,11 +50,11 @@ scripts = [
},
{
"usage": "natsize < [NUMBER]",
- "description": "prints a numeric file size as a human-readable string, e.g. `32036032` becomes `32.0 MB`",
+ "description": "prints a numeric file size as a human-readable string, e.g. `32036032` becomes `32.0 MB`",
},
{
"usage": "noplaylist.py < [URL]",
- "description": "removes the `list` query parameter from a YouTube URL; I use it with `youtube-dl`",
+ "description": "removes the `list` query parameter from a YouTube URL; I use it with `youtube-dl`",
},
{
"name": "r",
@@ -102,12 +109,22 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
</dd>
<dt>
+ <a href="https://github.com/alexwlchan/scripts/blob/main/text/fix_twemoji.py">
+ <code>fix_twemoji.py [PATH]</code>
+ </a>
+ </dt>
+ <dd>
+ when I copy/paste a tweet into Obsidian, often any emoji get replaced by "twemoji" – links to Twitter’s custom emoji artwork.
+ This script replaces those links with vanilla emoji characters.
+ </dd>
+
+ <dt>
<a href="https://github.com/alexwlchan/scripts/blob/main/text/fix_twitter_thread.py">
<code>fix_twitter_thread.py [PATH]</code>
</a>
</dt>
<dd>
- when I copy/paste a Twitter thread into Obsidian, this does some
+ when I copy/paste a Twitter thread into Obsidian, this does some
initial tidying up of the formatting for me.
</dd>
@@ -205,4 +222,4 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
"codepoints. This is a Docker wrapper around <a href="https://github.com/lunasorcery/utf8info">a tool of the same name</a> by @lunasorcery.
</dd>
</dl>
-<!-- [[[end]]] (checksum: 679627866c7239d6d4d5db3a8f03ab91) -->
\ No newline at end of file
+<!-- [[[end]]] (checksum: 1d5a76eaf2e7b0159fc349d7a4198453) -->
\ No newline at end of file
text/fix_twemoji.py (0) → text/fix_twemoji.py (667)
diff --git a/text/fix_twemoji.py b/text/fix_twemoji.py
new file mode 100755
index 0000000..5c88443
--- /dev/null
+++ b/text/fix_twemoji.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+"""
+When I copy/paste a tweet into Obsidian, often any emoji get replaced
+by "twemoji" – links to Twitter’s custom emoji artwork. e.g.
+
+ "Oh damn I need this book!"
+
+This script replaces those links with vanilla emoji characters.
+"""
+
+import sys
+
+from fix_twitter_thread import fix_emoji
+
+
+if __name__ == "__main__":
+ try:
+ path = sys.argv[1]
+ except IndexError:
+ sys.exit(f"Usage: {__file__} <PATH>")
+
+ with open(path) as in_file:
+ text = in_file.read()
+
+ text = fix_emoji(text)
+
+ with open(path, "w") as out_file:
+ out_file.write(text)