Pamasich / kbin-kes

Add-on manager and scripting framework for kbin
MIT License
0 stars 0 forks source link

Change fix-codeblocks to request the original post instead #56

Open Pamasich opened 9 months ago

Pamasich commented 9 months ago

Lemmy posts include a special "source" field which includes the actual markdown source code. And requesting the json of a Lemmy post via its kbin url does actually work and reply with Lemmy's reply.

As such, it should be possible to get the accurate original user input by requesting the post's url with the Accept header set to application/ld+json, get the source and then content field of the response object, and search it for codeblocks.

Users should be able to choose between this approach (which might slow down page load due to the additional requests) and the current one, and to mitigate the overhead it might be worth too to let them choose between a manual and an automatic mode. The existing method should work best for automatic mode while requesting the post from Lemmy would be ideal for the manual mode.