Questions tagged [stack-snippets]
Stack Snippets are runnable code sandboxes of the front-end languages HTML, CSS, and JS for use within a Stack Exchange post. Use this tag for bug reports, feature requests, and discussions explicitly relevant to these snippets and their underlying technologies.
473
questions
-17
votes
1
answer
101
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
173
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
108
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
91
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
113
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:
7
votes
0
answers
71
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
59
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
84
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
104
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
580
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
501
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
390
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
160
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 ...
20
votes
2
answers
210
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
87
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
344
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
133
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 ...
11
votes
4
answers
1k
views
Is it possible to have Python code snippets in Stack Overflow?
Is it currently possible to have Python snippets on Stack Overflow?
Python is getting increasingly popular and is also currently the most tagged language in Stack Overflow. It has got 1177 questions ...
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 ...
34
votes
0
answers
496
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) ...
5
votes
1
answer
90
views
Different results for code snippet in preview and after posting
I just encountered a strange situation. I want to post a code snippet but after submitting the result is different from what I have in the preview. I also tested this in the browser console which ...
4
votes
0
answers
58
views
Code Snippet - want to copy content with Shortcut CTRL-C (for external use)
Copying the code from the code snipptes is really annoying to select the right part of code (especially with long code parts with scrollbars) so it would be very helpful to have a shortcut like the ...
6
votes
0
answers
50
views
"Show code snippet" underline looks buggy
The link shows broken underline in some zoom levels.
Post taken from this answer and I am using Firefox 79.0.
-8
votes
1
answer
79
views
Allow to tweak with code snippets without adding it to an answer
Stack Overflow offers a great snippet tool to add HTML/JS/CSS to questions and answers, but sometimes we just want to try different test-cases to someone else's snippets or run whatever quick tests we ...
2
votes
0
answers
76
views
Feature Request: Language support for "Stack Snippets" [duplicate]
I was looking through this question on Meta, and I saw this comment. The comment says:
Added some notes to the post. (1) It's JS/CSS/HTML right now because that was the easiest. If it's successful we ...
10
votes
3
answers
262
views
I cannot edit the snippet after posting an answer
This is really annoying, but I no more see the edit snippet link to edit the code of my answer.
Is it probably related to the CommonMark migration?
It's happening for me here: How to make the image &...
4
votes
0
answers
47
views
Non-executable code snippets with custom text beside the drop down arrow
Background
A lot of the time I will have code that is relevant towards solving a problem, but including it with my question tends to make the question look cluttered. This is really common when ...
8
votes
1
answer
96
views
Should we edit stack snippets to regular code blocks for unsupported languages?
While reviewing new questions, should we convert code snippets to code blocks for unsupported languages (e.g. python)?
I've seen a number of posts suggesting that snippets shouldn't be used for ...
3
votes
0
answers
72
views
Code snippet editor auto adds a closing slash to <link> tags
When using the code snippet editor, and you want to add an external library by clicking on that button, it automatically adds a closing slash when it inserts a <link> tag. However, in HTML, a ...
5
votes
1
answer
170
views
How do you use `FileReader` or a web worker or similar that needs an external file in Stack Snippets?
I need to show an example of my problem using FileReader. How can I do that with Stack Snippets? They don't let you have multiple files. The same thing happens when I need to ask about something with ...
5
votes
0
answers
44
views
In the suggested edits queue, the stack snippet's "Run code snippet" button displays over the review bar [duplicate]
It seems in the suggested edits review queue, that the stack snippets run code button will display on top of the review bar (this is the name of the css class) at the top. Can this be fixed?
Here's a ...
8
votes
0
answers
217
views
imgur image not loading due to CORS policy [duplicate]
I am facing a very annoying issue that seems to happen only in a very particular case. When I use a transparent image hosted in imgur inide the mask property, it doesn't load.
Here is the concerned ...
5
votes
0
answers
80
views
Stack snippet with React and other npm libraries
I read through this great answer that shows how to create a stack snippet with React and JSX in it, but of course I want more. I'm currently working on a project that uses React and other libraries ...
-5
votes
1
answer
204
views
How do I add a code snippet that uses ReactJS 'useState()'? [duplicate]
I have a simple code snippet that runs fine. I need to add a call to 'useState()'. I tried using an import and using 'react.useState()', neither of which work. Is it even possible?
2
votes
0
answers
38
views
Document code snippet feature [duplicate]
When posting this question, I consulted this documentation looking for the syntax needed for the snippet feature, which was mostly added in this revision.
I reached that page by clicking "More" in ...
4
votes
1
answer
1k
views
Vue.js CDN in development mode
The insert "Stack Snippets" feature on Stack Overflow's WYSIWYG editor has the option to add Vue.js. When you add the library, it pulls in the un-minified development version of Vue.js. This ...
3
votes
2
answers
93
views
Is there a place to use Stack Snippets without asking/answering a SO question?
I love the Stack Snippets code sandbox on Stack Overflow, but if I want to just play around with some code and am not asking/answering a question, I have to click through a few screens to open one up. ...
-4
votes
1
answer
328
views
Example of Vue.js and Three.js in a code snippet
Is it possible to use Vue.js with Three.js library in a code snippet?
If yes, how should the Three.js be loaded and called in the snippet?
I tried to load it with:
<script src="https://threejs....
5
votes
0
answers
69
views
Stack Snippets don't allow opening new tabs/windows
From this answer of mine. The code works well on jsfiddle, but doesn't work on the Stackoverflow's snippet. By "works" I mean I want it to open https://www.google.com/ on a new tag, which is what the ...
4
votes
0
answers
58
views
Live-refresh breaks stack snippet buttons [duplicate]
If there is already a duplicate of this bug, I was unable to find it.
Anyway, the bug report:
If a post has a stack snippet embedded in it, and it is edited and the live-refresh 'button' clicked, ...
1
vote
0
answers
57
views
Why is code not highlighted and snippets not runnable after an edit? [duplicate]
When a post that contains code is edited and I click on the "An edit has been made to this post" link above it, I can see the edited post, but the code will not be highlighted unless I refresh the ...
50
votes
1
answer
835
views
Support JavaScript ES6 modules in code snippets
Update December 2020
This month Three.js is scheduled to go ES6 module support only. No more support for <script> tags for all the loaders/controls/postprocessing etc.
Three.js is fairly popular ...
1
vote
1
answer
122
views
Is it possible to link 2 different snippets in Stack Overflow?
When I'm creating 2 different snippets in the same question or answer like this:
Snippet for window 1:
function enableButton() {
document.getElementById('disabled').disabled = false;
...
13
votes
0
answers
317
views
Support Dart/Flutter as code snippets [duplicate]
This is a feature request to extend the "code snippet" feature, to support Dart/Flutter.
These two techs support running on the web (example), but are not in JS/HTML and therefore are incompatible ...
28
votes
2
answers
364
views
Snippets aren't working when refreshing an edit
Yes the title isn't very clear but here is the steps to reproduce the issue:
You are in a question page where a post (either the question or an answer) contain a snippet
An edit is made to the post ...
5
votes
0
answers
167
views
Prompt new users to try Stack Snippets
I've been using SO for a fair while now and only just learned today about how to make Stack Snippets. My initial impression was that code entered into a message/post would automatically become a ...
8
votes
0
answers
146
views
Snippet controls appear twice after completing a review
TL;DR:
Reproduction steps:
Find a post with a pending suggested edit to add a snippet; in my case, I handled the review from the "edit (1)" link rather than through /review.
Switch to "rendered ...