add a quick smartify script
- ID
fb75ea4- date
2025-09-23 14:46:02+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
b2f442f- message
add a quick smartify script- changed files
5 files, 54 additions, 37 deletions
Changed files
config.fish (6656) → config.fish (6702)
diff --git a/config.fish b/config.fish
index 0df11f2..9a09f45 100644
--- a/config.fish
+++ b/config.fish
@@ -195,6 +195,7 @@ __create_python_script_alias text/fix_twemoji.py
__create_python_script_alias text/fix_twitter_thread.py
__create_python_script_alias text/natsize.py
__create_python_script_alias text/noplaylist.py
+__create_python_script_alias text/smartify.py
__create_python_script_alias text/sumsizes.py
__create_python_script_alias web/download_instagram.py
__create_python_script_alias web/yt-dlp.py
requirements.in (248) → requirements.in (260)
diff --git a/requirements.in b/requirements.in
index 99ab26b..72368e8 100644
--- a/requirements.in
+++ b/requirements.in
@@ -14,6 +14,7 @@ pygments # Used as 'pygmentize' in 'pp_xml.sh'
pypdf
pytest
ruff
+smartypants
sqlite-utils
termcolor
tqdm
requirements.txt (3550) → requirements.txt (3137)
diff --git a/requirements.txt b/requirements.txt
index b01b75e..030f39f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,7 +2,7 @@
# uv pip compile requirements.in --output-file requirements.txt
aiofiles==24.1.0
# via datasette
-anyio==4.10.0
+anyio==4.11.0
# via httpx
argcomplete==3.6.2
# via pipx
@@ -10,17 +10,13 @@ asgi-csrf==0.11
# via datasette
asgiref==3.9.1
# via datasette
-backports-tarfile==1.2.0
- # via jaraco-context
beautifulsoup4==4.13.5
# via -r requirements.in
certifi==2025.8.3
# via
# httpcore
# httpx
-cffi==1.17.1
- # via cryptography
-click==8.1.8
+click==8.3.0
# via
# click-default-group
# datasette
@@ -33,14 +29,8 @@ click-default-group==1.2.4
# sqlite-utils
cogapp==3.6.0
# via -r requirements.in
-cryptography==45.0.7
- # via secretstorage
datasette==0.65.1
# via -r requirements.in
-exceptiongroup==1.3.0
- # via
- # anyio
- # pytest
flexcache==0.3
# via datasette
flexparser==0.4
@@ -66,8 +56,6 @@ idna==3.10
# anyio
# httpx
# hyperlink
-importlib-metadata==8.7.0
- # via keyring
iniconfig==2.1.0
# via pytest
iterm2==2.10
@@ -84,10 +72,6 @@ jaraco-context==6.0.1
# via keyring
jaraco-functools==4.3.0
# via keyring
-jeepney==0.9.0
- # via
- # keyring
- # secretstorage
jinja2==3.1.6
# via datasette
keyring==25.6.0
@@ -96,7 +80,7 @@ markupsafe==3.0.2
# via jinja2
mergedeep==1.3.4
# via datasette
-more-itertools==10.7.0
+more-itertools==10.8.0
# via
# jaraco-classes
# jaraco-functools
@@ -112,6 +96,8 @@ pillow==11.3.0
# pillow-heif
pillow-heif==1.1.0
# via -r requirements.in
+pip==25.2
+ # via datasette
pipx==1.7.1
# via -r requirements.in
platformdirs==4.4.0
@@ -123,10 +109,8 @@ pluggy==1.6.0
# datasette
# pytest
# sqlite-utils
-protobuf==6.32.0
+protobuf==6.32.1
# via iterm2
-pycparser==2.22
- # via cffi
pygments==2.19.2
# via
# -r requirements.in
@@ -143,10 +127,12 @@ pyyaml==6.0.2
# via datasette
ruff==0.13.1
# via -r requirements.in
-secretstorage==3.3.3
- # via keyring
+setuptools==80.9.0
+ # via datasette
six==1.17.0
# via python-dateutil
+smartypants==2.0.2
+ # via -r requirements.in
sniffio==1.3.1
# via anyio
soupsieve==2.8
@@ -159,30 +145,20 @@ tabulate==0.9.0
# via sqlite-utils
termcolor==3.1.0
# via -r requirements.in
-tomli==2.2.1
- # via
- # pipx
- # pytest
tqdm==4.67.1
# via -r requirements.in
typing-extensions==4.15.0
# via
# anyio
- # asgiref
# beautifulsoup4
# datasette
- # exceptiongroup
# flexcache
# flexparser
- # pypdf
- # uvicorn
userpath==1.9.2
# via pipx
-uvicorn==0.35.0
+uvicorn==0.37.0
# via datasette
websockets==15.0.1
# via iterm2
-yt-dlp==2025.9.5
+yt-dlp==2025.9.23
# via -r requirements.in
-zipp==3.23.0
- # via importlib-metadata
text/README.md (6188) → text/README.md (6505)
diff --git a/text/README.md b/text/README.md
index 55b1257..5b5581e 100644
--- a/text/README.md
+++ b/text/README.md
@@ -73,6 +73,10 @@ scripts = [
"description": "prints the lines of text, but in reverse order.",
},
{
+ "usage": "smartify.py [PATH]",
+ "description": "apply smart typography to a text file."
+ },
+ {
"usage": "sumsizes.py < [PATH]",
"description": """
prints a human-readable data size for the numbers passed on stdin.
@@ -193,6 +197,15 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
</dd>
<dt>
+ <a href="https://github.com/alexwlchan/scripts/blob/main/text/smartify.py">
+ <code>smartify.py [PATH]</code>
+ </a>
+ </dt>
+ <dd>
+ apply smart typography to a text file.
+ </dd>
+
+ <dt>
<a href="https://github.com/alexwlchan/scripts/blob/main/text/sumsizes.py">
<code>sumsizes.py < [PATH]</code>
</a>
@@ -213,4 +226,4 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
prints a tally of lines in the given text.
</dd>
</dl>
-<!-- [[[end]]] (sum: EFc4U28jPc) -->
\ No newline at end of file
+<!-- [[[end]]] (sum: FyzA8+tT8Q) -->
\ No newline at end of file
text/smartify.py (0) → text/smartify.py (560)
diff --git a/text/smartify.py b/text/smartify.py
new file mode 100755
index 0000000..aa44e2f
--- /dev/null
+++ b/text/smartify.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+"""
+Given the name of a file, apply SmartyPants to get nice typographical
+quotes etc.
+"""
+
+import sys
+
+import smartypants
+
+
+if __name__ == "__main__":
+ if len(sys.argv) != 2:
+ sys.exit(f"Usage: {__file__} PATH")
+
+ path = sys.argv[1]
+
+ with open(path) as in_file:
+ old_text = in_file.read()
+
+ attrs = smartypants.Attr.default | smartypants.Attr.u
+ new_text = smartypants.smartypants(old_text, attrs)
+
+ if new_text != old_text:
+ with open(path, "w") as out_file:
+ out_file.write(new_text)