Post

Crossposter progress update: I was using regex-based parsing for links, images, @handles, etc. It started out simple but became increasingly confusing as I tried to synchronize this regex-based parsing for Bluesky posts with the optimal splitting code.

I decided to go all-in and rewrote everything using a proper Markdown AST parser. I had to make a plugin for @handle support, but the mistune library was actually quite nice to work with.

The biggest issue was that LLMs kept hallucinating it as markdown-it, so I had to double-check and write everything by hand. BTW, Bluesky API is amazing!

0 reposts1 like

It supports full Markdown-style links, so the link text doesn’t have to be the URL itself (e.g., https://...), but can be proper HTML-style links with actual text. It's funny, because there's no way to do this using the official web client - but it’s definitely possible via the API.

This AST-based rewrite turned out to be the biggest task so far. Every single part of the app had to be rewritten, but now I have Python TypedDicts for LinkTokens and ImageTokens. It was worth the time - the codebase is really nice to read now.