Fix rmagic for cells ending in comment.

Closes gh-5579

Simplest possible fix, because rmagic is being moved out to rpy2. But it's not released there yet, so it's still worth us fixing this.