I was browsing around and helping people with coding issues, and I was embedding code in codeblocks like below as a visual and textual support.
"main": "file.js",
And just a few minutes ago I was also browsing around on StackOverflow to see if there are anything HTML/CSS/JS related I could help with, and it hit me that we don’t have code snippets here! It would help with newbies and beginners to just paste a bit of code and have them be able to execute there and then without having to copy and paste that code into their project to test it!
My idea was to have it similar to codeblocks were you’re still enclosing the code with some starting and ending element with [html], [css], and [js] or [javascript] and in the preview of actual post, they all combine into one code snippet. And maybe also include [package.json] for Node previews?
As a forum feature that’d have to be something discourse offers, but as far as I know SO snippets work because they have a secondary domain (stacksnippets dot net) that they use to host and run content from, so that untrusted code doesn’t get access to things like stackoveflow cookies etc.
That makes it much less likely that discourse offers a similar feature (at least one that I’d trust to enable) but if you know of options there, throw them in the thread and we can see if any of those might be something we can add.