Skip to content

Instantly share code, notes, and snippets.

@angelogladding
Last active October 9, 2022 18:45
Show Gist options
  • Select an option

  • Save angelogladding/308bc227e33529eb76bee69bb10856f1 to your computer and use it in GitHub Desktop.

Select an option

Save angelogladding/308bc227e33529eb76bee69bb10856f1 to your computer and use it in GitHub Desktop.
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