External (GitHub) code in a post is duplicated at the top with all lines joined after loading the page twice

Open this post for the first time:

Reload:

Fixable only with a cache purge.

1 Like

I have no idea what the reason for this, but this looks fairly certainly like a Discourse bug. Could you report it upstream?

fwiw, we mods have a tool “Rebuild HTML” (I used it for example to add syntax highlighting to a post, now that the default language for code blocks is Typst) that made the embed in your post show up correctly, but it was incorrect again on reload. So I suspect the problem is in Discourse’s preview generation or rendering system.

For now, I recommend just not putting links to Github code into their own paragraphs, suppressing the full preview. For example:

See lilaq/src/style/styling.typ at 1e38c166eeb674a293ea1821993e9cd1afa3da95 · lilaq-project/lilaq · GitHub


That may only be my impression, but I seldom find code embedded in the preview super useful anyway; same goes for issues. For example, in this post of yours the preview looks like this:

the cut off description (and also the rest of the metadata in the preview) imo don’t add much to the post, so this would be easier to read and convey the same thing:

The bug is tracked at Horizontal stacks shift right margin · Issue #6275 · typst/typst · GitHub

It only happens in specific situations.

I like that it shows the status of the thing, so if I feel it would be nice to see if it was closed, then you can look at it directly from the forum, saving you an extra click. Though it doesn’t say that it’s a duplicate.

Unless I’m missing something about discord, it only shows the status at posting time (I’d have to test to confirm though). To get up-to-date info, someone would need to press the “Rebuild HTML” button.


In fact, I’ll test it now:

If the text “THIS IS ONLY FOR TESTING AND WILL BE REMOVED IMMEDIATELY!” at some point disappears, it seems that Discourse will regenerate the HTML sporadically.

*Discourse, of course. Not editing the post again, since that also rerenders the preview.

It would be interesting to know what situations that are, but I doubt they’re specific to this Discourse instance.

You what?? That sounds like a stupid feature. The whole point of additional metadata is to provide up-to-date info.

I guess we can wait a few days, or ask it directly. But if it doesn’t auto update, then that’s just silly, and has no meaning. I don’t expect moderators to hit that magic button on each post every day or something.

You misunderstand the feature. Link preview is for convenience when writing a post. Once you’ve written the post, it is supposed to stay as it is. You, the author, have finished writing it, after all. Expecting a forum to act as an on-demand data fetching service for its users is not reasonable here and would be a waste of resources, since most content is static. Caching indefinitely is the way to go.

Neither is Discourse. It’s not supposed to update. The feature is working as designed. (Well, at least as I would have designed it. I’m not going to try and check Discourse’s design notes.)