x


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...

more ▼

asked Aug 07 '12 at 09:56 PM

mononull gravatar image

mononull
38 1 5 7

Your first for-loop is just indented by 1 space... 1 space is not 4.

Aug 07 '12 at 11:12 PM Bunny83

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.

Aug 08 '12 at 12:01 AM Eric5h5
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Aug 07 '12 at 10:08 PM

Bunny83 gravatar image

Bunny83
45.5k 11 49 207

yeah i did that...im not that clueless....it doesnt work thats why im posting about it

Aug 07 '12 at 10:11 PM mononull

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>()
Aug 07 '12 at 11:09 PM Bunny83
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Aug 08 '12 at 12:19 AM

aldonaletto gravatar image

aldonaletto
41.5k 16 42 197

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

Aug 08 '12 at 03:23 PM mononull

seem to work fine on that last comment though....okaaay

Aug 08 '12 at 03:23 PM mononull

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.

Aug 09 '12 at 12:56 AM aldonaletto
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x790
x539
x36

asked: Aug 07 '12 at 09:56 PM

Seen: 274 times

Last Updated: Aug 09 '12 at 12:59 AM