Social media cards should not display raw markdown
simonw opened this issue · 6 comments
simonw commented
e.g. https://twitter.com/simonw/status/1661869062836846592

HTML is:
<meta name="twitter:description" content="Today I noticed that [Datasette](https://datasette.io/) wasn't serving a `Access-Control-Max-Age` header.
This meant that any `OPTIONS` CORS pre-flight requests would be repeated for every request, ">
simonw commented
I think the best way to implement this is at build time, writing out a description field into the database table.
simonw commented
GPT-4 suggestion:
from markdown import markdown
from bs4 import BeautifulSoup
def markdown_to_text(markdown_string):
html = markdown(markdown_string)
text = ''.join(BeautifulSoup(html, "html.parser").stripped_strings)
return text
I have both of those dependencies already.
simonw commented
I use the first paragraph for the summaries on https://til.simonwillison.net/python
I think first paragraph with HTML stripped will work here.
simonw commented
Oops, that triggered a full regeneration of all of the screenshots because the hash of the template file changed.
https://github.com/simonw/til/actions/runs/5092870560/jobs/9154783613
simonw commented