Questions tagged [stack-snippets]
Stack Snippets are runnable inline code samples (currently HTML, CSS, and JavaScript are supported, but more languages are apparently on the roadmap). Use this tag for bug reports, feature requests, and discussions explicitly relevant to these snippets and their underlying technologies.
449
questions
3
votes
1
answer
73
views
Snippet formatting issue when editing/submitting an answer [duplicate]
This snippet is a valid "Question" but it's an invalid "Answer" on Stack Overflow.
Keep getting this error when I try to submit this code snippet as an answer:
Your post appears ...
6
votes
1
answer
111
views
Is it possible for a Stack Snippet to get information about the post it's running in?
Stack Snippets have many uses, and while I don't use them that often on Stack Overflow (I haven't been active for while, let alone in the javascript tag), they also have their uses on other sites in ...
2
votes
0
answers
96
views
Sass in stack snippets [duplicate]
Most of you have probably seen stack snippets, like the one below.
function clickMe() {
alert("Button clicked!");
}
button {
background-color: rgb(29 78 216);
border: none;
border-radius: ...
6
votes
3
answers
210
views
How do I create a Vue.js Stack Snippet?
I found detailed instructions here on how to create a Stack Snippet for React, but I have been unable to figure out how to do so for a Vue.js component.
How do I create a runnable Stack Snippet of a ...
20
votes
1
answer
2k
views
Is this 'Run code snippet' with payload an attempt to infect SO users' machines with a virus?
Just wondering if there's a risk to a user's machine by clicking "Run Snippet" in questions like this one
I'm suspicious because on the face of it the question doesn't look like it needs to ...
2
votes
0
answers
63
views
Close button when trying snippets on full screen might not be noticable
On my recent question, since I was trying the stack overflow snippet in full screen for the first time I couldn't notice that there was a close button on the top right corner, and that would be the ...
3
votes
1
answer
62
views
Running Snippet in full screen as reviewer then clicking back arrow redirects me to another question
I recently got my 500 rep points and had access to the reviewing actions, but one of the questions I was reviewing had a PHP related snippet. I tried to test that snippet on full screen which doesn't ...
5
votes
0
answers
45
views
Full screen snippets has an incorrect z-index in post revisions
Example post with a snippet https://stackoverflow.com/posts/71191950/revisions
Click "Run code snippet" and then click the "Full page" link
The top bar, side bar, and post ...
6
votes
0
answers
62
views
Moderator Redaction flags does not display collapsed code snippets
The moderator redaction tool does not display the redacted diff if the redacted bit was in a collapsed code snippet, so we cannot see what was redacted for approval. There aren't any buttons to expand ...
-9
votes
1
answer
134
views
Displaying HTML first on Stack Overflow snippets [closed]
Currently, code snippets are displayed JavaScript first, then CSS and finally HTML. Regardless of the order they appear in the post source or anything.
This does not make any sense to me. Does it for ...
-13
votes
0
answers
117
views
Can we have Runnable Python Snippet? [duplicate]
Since Python language is getting more popular, can we have Runnable Python Snippet implemented in SO?
Why Python?
It was ranked second to JavaScript/HTML/CSS in most popular technologies in 2021.
It ...
-26
votes
1
answer
196
views
WebAssembly should be usable in code snippets
I don't see any way to use WebAssembly in snippets; just HTML, JavaScript and CSS. Allowing WebAssembly would let any compilable language be indirectly used for snippets. It's not complicated to let ...
-19
votes
1
answer
136
views
Tests for stack snippets
When we ask users to add their code as a minimal reproducible example via Stack Snippets and tell us what they expect the code to do, the snippet is quite helpful but we have no way to verify if an ...
3
votes
0
answers
49
views
Code snippets feel inconsistent
Could we combine "Expand snippet" and "Full page" into a single and consistent experience?
If not then at least improve the general wonkiness?
Expand snippet
I can run code in ...
3
votes
1
answer
124
views
Code snippet console scrolling issue in Chrome
I recently provided this answer and was trying to see if my output string is valid but the console window seems to cut off after a certain point.
Could we make this re-sizable, expandable, or scroll-...
2
votes
0
answers
113
views
Is this Moment.js plugin broken, or are Stack Snippets not working?
I was updating my self-answer to Filter out non-contiguous date using momentjs and twix.js and tried to make use of Stack Snippets, but it's not working.
I'm trying to understand if the Moment.js ...
6
votes
1
answer
262
views
The “Close” button for the snippet “Full page” doesn’t work when site isolation is enabled
If you create a snippet in a question or an answer and click on “Full page” then the “Close” button is not clickable. Am I the only one to whom this happens? This was tested in Firefox, Safari and ...
2
votes
2
answers
114
views
How do I correctly include the latest Babel and React libraries in a code snippet? [duplicate]
I would like to include both the latest Babel (for async/await syntax support) and the latest ReactJS (for hooks) in my code snippet, but I get the following error:
"message": "...
-1
votes
2
answers
225
views
How do I add CSS libraries to my Stack Snippet? [duplicate]
When I asked the question I wanted to include a Stack Snippet, but the images, fonts and the Bootstrap grid were giving me issues, so I'm asking if there is a way that could be fixed.
This is what I'm ...
2
votes
2
answers
205
views
Is it possible to embed DartPad into a Stack Overflow post?
I'm wondering if there is a way to embed DartPad in the Stack Overflow question and answer like mentioned here in the Embedding Guide.
I tried to embed but failed, this would be helpful to test code ...
-8
votes
2
answers
291
views
Can we disable Stack Snippets for New Users?
Runnable code snippets (a.k.a. "Stack Snippets") are a great feature. However, they are also being misused (increasingly frequently, in my experience) by new users, who are using the "...
5
votes
0
answers
92
views
Why does the Stack snippets console error not show the correct line number?
When there is an error in a Stack snippet JavaScript code, an error message is displayed, but the "lineno" in the message is incorrect.
In the following snippet, it Shows the error is on ...
7
votes
0
answers
89
views
Stack snippets external file validation needs to be fixed
I went to edit a question that was linking to Google Fonts with http://fonts.googleapis.com/css?family=Poppins:400,300,500,600,700 and when clicking the "Add an external library" the snippet ...
-15
votes
1
answer
225
views
Add a warning about snippets being dangerous when they are run
WARNING: Do not run the code samples below. They are potentially destructive, and can crash a computer/server.
Stack Snippets is not entirely secure. Some server-crashing scripts can still run:
var ...
37
votes
1
answer
755
views
How are Stack Snippets implemented?
The runnable snippets on Stack Overflow for JavaScript, HTML and CSS are a very convenient feature.
I was wondering how is it implemented.
From what I could find on this link, Stack Overflow ...
5
votes
0
answers
148
views
Auto-save for Stack Overflow code-snippets (Stack Snippets)
I was editing a Stack Snippet and the page froze and I lost all my work (it was a lot).
Could there be some kind of autosave when editing code snippets? (the ones with HTML, CSS, and JS that you can ...
2
votes
0
answers
69
views
Code copied from Snippet editor results in only a hyphen when pasted to JS Fiddle and VS Code
A number of times recently, I have attempted to copy code from the Snippet editor in order to paste it into either JS Fiddle (which I prefer for code experimentation) or VS Code. In many situations – ...
2
votes
0
answers
42
views
Allow the snippet editor's areas for code and results to be resized by the user
I've answered a question on Stack Overflow. I wanted to move one of the borders between the HTML, JavaScript, CSS, and Result panes in the snippet editor, but I couldn't move it. In other words, I ...
-17
votes
1
answer
96
views
Is there an option to run my code snippet automatically when opening Stack Overflow questions?
Is it possible to autorun a code snippet?
I would like to run my snippet automatically in the question below:
How to add a nice stroke to shining text with given font?
-10
votes
1
answer
160
views
Removing Fiddle links [duplicate]
We all (hopefully) know, that questions or anwser containing code lines should use a stacksnippet to demonstrate the code. A fiddle (codepen etc.) link might change, getting deleted or the content ...
1
vote
0
answers
43
views
Can we re-open code (stack snippets) in the code editor? [duplicate]
For example, given the following code snippet, how does one edit the question or answer and open the existing example inside the code editor again?
console.log('example')
h1 {
color: deeppink;
}...
5
votes
0
answers
96
views
Bug (?) with stack-snippets within three backticks
First off: I'm not sure if that's actually a bug. Just seemed really odd.
I was reviewing some suggested edits and came across the following edit (which I rejected):
Then I decided to view the ...
3
votes
0
answers
90
views
Is indentation in answer editor broken?
I edited this answer, and by the look of the things, I cannot understand what went wrong. The code is indented with spaces, but they somehow disappear in preview.
What did I do wrong?
(It's very ...
2
votes
0
answers
98
views
User setting to allow disable Esc key on snippet editor? It causes an infinite popup loop [duplicate]
When I'm writing code on my editor and I need to skip or close IntelliSense suggestions, I press the Esc key in order to keep writing freely. So, I've got this habit of writing some stuff and ...
-12
votes
1
answer
106
views
Runnable snippets: Extension is missing
I use htmx which uses this URL for their JavaScript:
https://unpkg.com/htmx.org@1.1.0
This gets rejected, if I try to add it to a runnable stack snippet.
What should I do now?
It gets rejected:
6
votes
0
answers
67
views
Can we add support for React 16.8 (or latest) in Stack Snippets?
Currently Stack Snippets supports up to 16.6.3. It will be great to add the support for 16.8 as this is a major release because of React hooks support.
Now the alternative is each time manually add ...
1
vote
0
answers
58
views
Hat showing on top of snippet [duplicate]
When running the snippet in this answer, the user's hat didn't move with their profile image, and instead floated over top of the snippet.
7
votes
1
answer
83
views
Code snippet console render BigInt incorrectly
The console.log in code snippet currently does not support BigInt. To reproduce this problem, you may simply run this code snippet. The console shows null instead of 42. And it should show something ...
5
votes
0
answers
103
views
Can't post edit with NULL (U+0000) character in Stack Snippet
When a Stack Snippet contains a NULL (U+0000) character in its body, various errors start to arise:
Automatic POST requests to /posts/validate-body return a 418 No Reason Phrase error.
Trying to run ...
11
votes
1
answer
578
views
How to reduce complicated code on runnable code example sites to a sensible stack snippet?
I sometimes see questions with a link to a runnable code site like CodePen or JSFiddle that contains some complicated computation of the resulting page. Currently, the worst are tools like CodeSandbox,...
10
votes
1
answer
485
views
How to add open source React libraries to Stack Overflow code snippet
I'm trying to add some React libraries (react-draggable, react-xarrows, and react-zoom-pan-pinch), which I normally would just install via npm, to the code snippet section on Stack Overflow. There is ...
-5
votes
4
answers
276
views
How can I insert a PHP code snippet in markdown of Stack Overflow? [duplicate]
I want to write a PHP code snippet in the question or answer. I searched that but Stack Overflow can insert only HTML, CSS, JavaScript snippet code.
How can I insert a PHP code snippet like below?
...
7
votes
2
answers
148
views
Too many console log messages causes content to get hidden
I found a "bug" which causes content to get hidden behind the console log messages.
Take a look at this answer. Run the code example and enter some values in the input field to trigger the ...
15
votes
2
answers
151
views
Update JS-Beautify Snippet formatter
Having a Javascript snippet like:
async function foo() {
await import('./module.js');
}
and then tidying via the Tidy button, you end up with:
async function foo() {
await
import ('./foo.js');
}...
5
votes
2
answers
85
views
Why can JavaScript execute in the browser's console but not in a Stack Overflow snippet?
I can execute the four JavaScript statements in a browser's developers console:
var content = '<p>test</p><script type="text/javascript">somany lines and \n\
...
2
votes
1
answer
147
views
How to make JavaScript execute in Stack Overflow's "run code snippet"
div#html,div#css,div#js,div#run{
border:1px solid red;
height:80px;
width:80px;
float:left;
}
div#content{
clear:both;
width:400px;
height:200px;
border:1px solid black;...
2
votes
0
answers
46
views
Stack snippets: are there any official guides on this function? [duplicate]
I've seen some users using snippets but I'm not sure how to do it myself. Might sound trivial but I'd like to know.
Using JSFiddle or CodePen to show working code doesn't seem as effective as using ...
5
votes
1
answer
109
views
Is there a way to only show the console in Stack Snippets?
I was asking a question on Stack Overflow, and I needed to insert a Stack Snippet. The snippet only logged one thing to the console. The console only took a little bit of the screen; the rest of the ...
55
votes
1
answer
1k
views
Unrunnable/useless Stack Snippets in Suggested Edits
Lately, I’ve seen some suggested edits from a particular user that simply change a code block into a Stack Snippet. (Almost all of their suggestions are just this). Sometimes, the snippet isn’t even ...
23
votes
0
answers
279
views
Please Fix Stack Snippets
Please fix the many outstanding issues with Stack Snippets:
Why won't this snippet with async await work here on Stack Overflow snippet editor?
Update the version of Babel Standalone (and others) ...