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.

Filter by
Sorted by
Tagged with
2 votes
0 answers
36 views

Broken snippet rendering [duplicate]

This question (in revision 1) has a really weird StackSnippet content that doesn't want to display properly. In the question it renders nested scrollbars: Scrolling down to the bottom of the outer ...
  • 614k
1 vote
0 answers
129 views

Why does Stack Overflow's code snippet show a different result compared with a normal editor?

Today, when I was answering a question, I observed that the result from the code snippet Stack Overflow give us is different from other editors. For example, this and this both shows the right result, ...
  • 165
2 votes
1 answer
147 views

How can I include Tailwind CSS as external source in a Stack Snippet?

The recommended way of directly including Tailwind CSS according to their documentation is to add <script src="https://cdn.tailwindcss.com"></script> to the HTML head. But when ...
  • 16.1k
15 votes
1 answer
283 views

Feature request to allow executable XSLT code snippets

For questions related to HTML/JavaScript/CSS, Stack Overflow allows you to embed executable code snippets in a question and/or answer. I would suggest to allow that too for XSLT questions: XSLT 1.0 is ...
3 votes
2 answers
69 views

How do I hide the HTML preview for a Stack Snippet?

I have a simple JavaScript code snippet that displays an alert message. alert("Hello world!") Running the code snippet shows the alert as expected, but it also displays a white empty box ...
  • 22.7k
-3 votes
1 answer
95 views

SO Snippet should warn about wrong HTML usage

Considering this question about a not-working CSS :first-child selector. The OP posted a question with a full HTML structure in the question, and later it was edited into an SO Snippet showing that ...
  • 40.4k
3 votes
0 answers
50 views

Add toggle line wrap in snippet editor

I pasted a really long line of code into the snippet editor—so long that the editor decided to ignore the rest of it. Here you can see that it has overflowed to the next line (for some reason, there's ...
  • 21k
0 votes
0 answers
72 views

When you click on "Tidy", "/>" from "<img/>" goes to the next line if there are too many characters

It's just a little thing, but I noticed that if an img element is closed like <img /> and you click on the Tidy button, the /> is put on the next line when there are too much characters ...
  • 2,105
2 votes
0 answers
85 views

Add more languages to Stack Snippets [duplicate]

Stack snippets are a great feature. They greatly increase the reproducibility of answers in JavaScript, HTML, and CSS, as well as supported frameworks like React. Already, many answers link to ...
  • 6,539
5 votes
0 answers
113 views

Show a warning when on Stack Snippets throwing errors

Tl;Dr: Make use of the Ask question warnings to reduce the misuse of Stack Snippets. Automatically run it in the background when the user click the "Review your questions button", if there ...
  • 33.8k
6 votes
1 answer
126 views

In Stack Snippets, "console.log(map)" prints "{}" instead of the contents of the Map

When answering this question, I tried to put my JS-only code into a snippet. Here's the snippet: const lines = ['The foo is black', 'The bar barks']; let wordCount = new Map(); for (let i = 0; i &...
  • 8,372
0 votes
0 answers
69 views

Why am I seeing two snippet buttons? [duplicate]

I just noticed there are two snippet buttons!? Clicking either of them works as expected. Pressing the shortcut Ctrl + M opens both modal dialogs at the same time.
  • 5,956
12 votes
1 answer
190 views

I see two snippet buttons in the editor

I'm using Firefox 104.0.1 (64-bit). I see this in Private tabs, too. I also see it in Chrome. It only shows up on the "Ask Question" page (both in the question editor, and also in the answer ...
27 votes
2 answers
489 views

Should I suggest edits to transform code blocks into Stack Snippets for HTML/CSS/JS questions?

I occasionally come across questions which contain HTML/CSS/JS which are formatted using the standard code blocks (backticks or indentation) that would be better as a runnable snippet. Is it good ...
5 votes
2 answers
169 views

TypeScript in Stack Snippets

Lately, I have seen various questions that use TypeScript in Stack Snippets. They look like this: There is a problem with my code. Instead of doing x, it does y. Here is my code: function ...
  • 461
5 votes
0 answers
48 views

Tidy button on Stack Overflow code snippet tool breaks optional chaining in JavaScript code [duplicate]

Bug report: Create a code snippet and try and use optional chaining. Click Tidy and see it add erroneous spaces to the code around the ? in the optional chaining portion. //optional chainging ...
  • 4,632
1 vote
0 answers
58 views

Strange behavior in Stack Overflow: unwanted scrolling of the page on Run code snippet button click [duplicate]

When I edit a new question or answer, if I insert a code snippet and then I click on Run code snippet blue button, to check if it works as expected, I noticed that such an action triggers a wrong ...
  • 1,370
4 votes
0 answers
337 views

How can I include HTML and JavaScript code on Stack Overflow? [duplicate]

I want to post my first question here, and I would like to insert HTML and JavaScript code. I've been checking questions to different answers, and there is a "run code" button that runs both ...
  • 1
3 votes
1 answer
75 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 ...
  • 653
6 votes
1 answer
117 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 ...
  • 21.6k
2 votes
0 answers
101 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: ...
7 votes
3 answers
438 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 ...
  • 71.6k
2 votes
0 answers
64 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 ...
  • 1,085
3 votes
1 answer
64 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 ...
  • 1,085
5 votes
0 answers
47 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 ...
  • 75.5k
6 votes
0 answers
63 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 ...
  • 75.5k
-9 votes
1 answer
140 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 ...
  • 1,197
-13 votes
0 answers
119 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 ...
  • 5,956
-26 votes
1 answer
201 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
151 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 ...
  • 5,429
3 votes
0 answers
50 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 ...
  • 20.3k
3 votes
1 answer
140 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-...
  • 20.3k
2 votes
0 answers
121 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
119 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": "...
  • 52.7k
-1 votes
2 answers
234 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
241 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 ...
  • 833
-8 votes
2 answers
295 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 "...
  • 48.7k
5 votes
0 answers
99 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 ...
  • 406
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 ...
  • 202k
-15 votes
1 answer
231 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 ...
38 votes
1 answer
807 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 ...
  • 53
5 votes
0 answers
156 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 ...
  • 780
2 votes
0 answers
71 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
45 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 ...
  • 446
-17 votes
1 answer
99 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?
  • 6,962
-10 votes
1 answer
171 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 ...
  • 9,292
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; }...
  • 43k
5 votes
0 answers
106 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 ...
  • 6,433

1
2 3 4 5
10