Discourse doesn't follow the CommonMark spec for HTML <pre> tags inside code spans

Right. The only reason I mentioned CommonMark is that it’s the only standard I can point to which explains the correct behavior.

Really though the current behavior of Discourse in this area is less than optimal regardless of whether you’re following CommonMark.