The rule is:
Don't change the behavior of his code
If his code is missing a {
or ,
don't add it as this may be the cause of the issue, thus the asked question. But if there is some local images and the issue is not related to these images you may update the links to use placeholder one.
We need also to pay attention to the order, if the OP shared different blocks of code including JS, don't add a snippet unless you are sure about the order of his code. Maybe he's having an issue because he's including the JS before the HTML.
For me adding a snippet should be done if and only if these conditions are present:
- The OP shared his full code including all the relevant HTML/CSS/JS.
- The converted snippet should reflect the behavior described by the OP even if it's an error.
Some of the edits I usually do when converting to snippet:
- Remove
html
, body
,head
tags and doctype declaration
- Remove useless comments
- Remove unused CSS declaration
- Add missing libraries only when am sure about them
- In some rare cases, I add minor styles like border or background to better highlight some behaviors (overflow, width, etc).
UPDATE
For users with reputation <2K better avoid some of the above edits as they may get rejected because we may have significant difference between the initial code and the final code even if at the end the output is still the same.