Last active
October 9, 2022 18:45
-
-
Save angelogladding/308bc227e33529eb76bee69bb10856f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| def autotag(match): | |
| tag = match.groups()[0] | |
| return f"<a href=https://jamesg.blog/tag/{tag}>{tag}</a>" | |
| def autopersontag(match): | |
| person = match.groups()[0] | |
| return ( | |
| f"<a href=https://jamesg.blog/tag/{people[person][1]}>{people[person][0]}</a>" | |
| ) | |
| note = "I am presently having coffee with @example. #coffee #lunch #breakfast " * 10000 | |
| people = { | |
| "example": ("Example Person", "example.com/bio"), | |
| } | |
| note = re.sub(r"#(\w+)", autotag, note) | |
| note = re.sub(r"@(\w+)", autopersontag, note) | |
| print(note) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment