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

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