Note: Answers will occasionally be moved to the Sandbox archive when there are too many of them. When using them to report bugs, keep an eye.
As per Jeff's suggestion in this comment:
You can use this question as a formatting sandbox. You can:
- edit this question itself (Community Wiki questions such as this one require 100 reputation to edit)
- post answers to this question (This question might be protected, requiring earning 10 reputation on this site to answer)
- post comments to this question or its answers
- test suspected bugs with the editor or the rendering
- post ponies (only when mods are asleep)
Beware that since the changes to syntax highlighting in December 2010, and the inline hints added in March 2011, no syntax highlighting is applied unless the question's tags or an inline hint enable it. So, to test highlighting here in the sandbox:
As of January 8, 2019, you can use GitHub-flavor fenced code blocks in your posts, specifying the language after the opening fence:
```html While not hinted otherwise: <html></html> source <b>goes</b> "here". ```
```js var a = 3; while (not (a > 0)) { alert("JavaScript code <b>goes</b> here."); } ```
(The traditional way) On the start of a line, specify a language inline using
<!-- language: lang -->
hints, and indent the code 4 spaces as usual. There is a full list of hints (scroll down a little).<!-- language: lang-html --> While not hinted otherwise: <html></html> source <b>goes</b> "here".
<!-- language: lang-js --> var a = 3; while (not (a > 0)) { alert("JavaScript code <b>goes</b> here."); }
Or:
Create code blocks in either way (see above).
Save your post.
Use your browser's developer tools to edit the resulting HTML. To open developer tools, press F12, or ⌥⌘ I on Mac.
Find the
<pre>
element and add the attributeclass="prettyprint"
, or change it into one of the valid syntax hints linked above, likeclass="lang-vb prettyprint"
.Run the following in the location bar:
javascript:prettyPrint();
orprettyPrint()
in the console.
Answers that are considered annoying or obnoxious, or that cause breakage for users, will be deleted. This is codified as a policy as of March 29, 2018.