To format text to appear as a highlighted code snippet, install and activate the plugin Highlighting Code Block.
An example of what you can display in your post is shown below:
const app = () => {
console.log("That's come nice code highlighting you got there.")
}
document.addEventListener("DOMContentLoaded", app)
The code block above uses the Highlighting Code Block block which is provided by the namesake plugin.
The settings for the plugin in this instance are set to disable the display of line numbers, code language and quick copy button, but you can enable these settings if you prefer.
The dark mode is also enabled however a CSS overwrite was used to set the background color to match the theme.