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.
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 toapplication/ld+json
, get thesource
and thencontent
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.