It’s the backtick code blocks inside list which are not standardized across implementations (the preview and output differing seems like a real bug though). But you can use indented code blocks as a workaround until Discourse switches to markdown-it (which supports what you are trying to do).
1. first
size(x, y);
print(1);
2. second
size(x, y);
print(1);
3. third
4. and so on
-
first
size(x, y); print(1); -
second
size(x, y); print(1); -
third
-
and so on