- Home /
[meta] Cannot post code - gets cut off
I'm trying to post some example code, but every time I try the text gets cut off. I can paste regular sentences fine. But whenever I copy and paste my code example....it will show up in the preview window fine....but then after clicking save it all gets cut off at the '<' expression. I paste the code, select all the code text, click the code sample button, and this doesn't work either. Same effect where everything gets cut off.....
for(int i=0;i
for(int i=0;i
UPDATE: Used the markdown manually and same effect....gets cut off...
Your first for-loop is just indented by 1 space... 1 space is not 4.
I'd suggest trying a different web browser. I've never seen the code button not work personally, but to be fair the code parsing on this site is kinda messed up and has been for a while.
Answer by Bunny83 · Aug 07, 2012 at 10:08 PM
That's because you didn't marked your code as code. Just highlight all text that is code and press the "101 010" button above the edit field.
This button just do this:
It will insert an empty line before and after your code to seperate it from the normal text.
It will indent each line with 4 spaces. This will cause the editor to recognise the lines as code.
Just click the "?" at the right side of the editor which shows the basic markdown. At the end of that page there's a like to a more detailed documentation. Alternatively you can also take a look at the documentation of the StackOverflow which is quite similar to the markdown used here on UA.
As final note: don't try to put a code block right below a bullet-list. It won't work ;) instert at least one normal line in between.
yeah i did that...im not that clueless....it doesnt work thats why im posting about it
It always works pretty well as long as you don't forget any of the two points. It even works here in comments. There is no button, but you can still indent it manually like this:
This is a code block
This line was originally indented by 4 and now it's indented by 8
12 indents
The first 4 spaces will not be shown in your code block. They are used to recognise code. Each other character will be displayed as it is:
// code
GetComponent<FooBar>()
Answer by aldonaletto · Aug 08, 2012 at 12:19 AM
This is happening because this site "thinks" that a < signal followed by any character but a space is a tag, and swallows the whole text after it until a > signal closes the imaginary tag. Place a blank space after < and the code will magically reappear (unless there's another < in your text).
I usually format code using the tag <pre>: skip a blank line, place the tag <pre>, the code and a closing </pre> - always skip a blank line before the <pre> tag, or this will not work. This kind of formatting also suffers from the < syndrome, thus be sure to insert a blank space after every <
I don't know how much the browser or OS influences this - I'm using a PC with Google Chrome, and always have this same problem.
EDITED: The <pre> tag ended being a big headache - @Bunny83's suggestion is what works fine: select the text and click the 101010 button (or press Ctrl-K).
i tried and , and couldnt get it to work, and i also tried putting a space after the initial '<' in my code....but it still treated it like a tag
i thought maybe i couldnt see some characters in the text field because of my color scheme but even changing that i still cannot tell whats going on with the tags
That's how the text looks for me while editing:
<pre>
var someVar: boolean;
function Update(){
someVar = !someVar;
}
</pre>
Notice that there's a blank line before the <pre> tag, but it's not necessary to place a blank line before or after the closing </pre> tag.
The text above shows in UA like this:
var someVar: boolean;
function Update(){ someVar = !someVar; } The pre tag keeps the code exactly like you write or paste, except for the damned < character, which needs a blank after it in order to not be considered a tag.
Your answer
Follow this Question
Related Questions
change between two values (If /Else) 2 Answers
Changing the code from collision to button 5 Answers
multiple inputs 2 Answers
How can I make a gui with buttons pop up in javasript? 1 Answer