Rendering Contentful Rich Text w/ JavaScript - Changing Parent Tag

I am rendering code snippets on a gatsby site following this article:

However, if I render a <code /> block, it is inside a <p />, since for the Rich Text entry, all things that are not a Heading (ie “Normal Text”) are a <p> tag.

Is there a way I can change this?

Bumping this topic. I can’t seem to find anything when searching for this issue either or find a solution myself. I have the same problem, but with

tags wrapping images. Any way to undo, manage or change this behavior? Thank you to anyone who can help!

I created a separate post, but I think this may help you as well. Finally found an article and in the last comment this did the trick for me: Hope it helps others!