Line break should not happen after/before math if there is no whitespace

I don’t understand. Posts are in a container if text does not fit it wraps. Same as it wraps on this line which is this.

I don't understand. Posts are in a container if text does not fit it wraps. Same as it wraps on this line which is this.

Can you explain what you are expecting here?