4792 posts
  • Elite Author
  • Community Moderator
  • Sold between 100 000 and 250 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
  • United Kingdom
+5 more
felt_tips Volunteer moderator says

Hi there,

‘Scuse the cross post…I put this in VideoHive originally, then realised it’s probably relevant to all market places.

I was just trying to type a code fragment in to one of these threads. When I did, it removed all of my formatting. Not only was it difficult to read, but where I had commented the code at the end of a line, it changed the functionality too.

Is this a bug or is there something I’m missing. I thought the whole point of a code block was that it kept verbatim everything you typed in without recognising any of the symbols as text formatting.

-felt.

2541 posts
  • United States
  • Attended a Community Meetup
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Has been a member for 5-6 years
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
+4 more
CreatingDrew says
Hi there,

‘Scuse the cross post…I put this in VideoHive originally, then realised it’s probably relevant to all market places.

I was just trying to type a code fragment in to one of these threads. When I did, it removed all of my formatting. Not only was it difficult to read, but where I had commented the code at the end of a line, it changed the functionality too.

Is this a bug or is there something I’m missing. I thought the whole point of a code block was that it kept verbatim everything you typed in without recognising any of the symbols as text formatting.

-felt.

Code tags are to signify that the text contained is code, it is good and relevant markup, but it will parse code in between the tags, php code for example. You need to convert the html entities (a less than tag become < ) or use a syntax highlighting plugin.

4792 posts
  • Elite Author
  • Community Moderator
  • Sold between 100 000 and 250 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
  • United Kingdom
+5 more
felt_tips Volunteer moderator says

Thanks Creating Drew,

Do you know how I force a line break and a tab?

-f.

<
707 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Has been a member for 5-6 years
  • Exclusive Author
  • Microlancer Beta Tester
ChillThemes says
Do you know how I force a line break and a tab?
&nbsp; /* Non-breaking space */ <br /> /* Line break */

This simplifies the process: http://simplebits.com/cgi-bin/simplecode.pl

4792 posts
  • Elite Author
  • Community Moderator
  • Sold between 100 000 and 250 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
  • United Kingdom
+5 more
felt_tips Volunteer moderator says

Thanks guys… that simplebits link looks great, but I’ve just pasted the results in below… and it’s coming out completely unformatted to me. How does it look to you? Is this some issue with the Envato forums parsing?

-felt.

tX = 20; //chars per line<br /> tY = 10; //no of lines<br /> <br /> tText = ""; //initialise text<br /> <br /> for (j = 0; j &lt; tY; j++) {&#160;&#160;//loop thru lines<br /> for (i = 0; i&lt;tX; i++) { //loop through chars<br /> t= random(100)&gt;50; //statement that is true half of the time<br /> t = (t?"1":"0"); //convert to string<br /> tText += t; //append to text<br /> }<br /> tText += "\r"; //add line break<br /> }<br /> <br /> tText;<br /> <br />
4792 posts
  • Elite Author
  • Community Moderator
  • Sold between 100 000 and 250 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
  • United Kingdom
+5 more
felt_tips Volunteer moderator says

Worked it out! It’s the

 
that I was looking for.. :)

tX = 20; //chars per line
tY = 10; //no of lines

tText = ""; //initialise text

for (j = 0; j < tY; j++) {  //loop thru lines
    for (i = 0; i<tX; i++) { //loop through chars
        t= random(100)>50; //statement that is true half of the time
        t = (t?"1":"0"); //convert to string
        tText += t; //append to text
    }
     tText += "\r"; //add line break
}

tText;
2541 posts
  • United States
  • Attended a Community Meetup
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Has been a member for 5-6 years
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
+4 more
CreatingDrew says
Worked it out! It’s the <pre> </pre> that I was looking for.. :)
tX = 20; //chars per line
tY = 10; //no of lines

tText = ""; //initialise text

for (j = 0; j < tY; j++) {  //loop thru lines
    for (i = 0; i<tX; i++) { //loop through chars
        t= random(100)>50; //statement that is true half of the time
        t = (t?"1":"0"); //convert to string
        tText += t; //append to text
    }
     tText += "\r"; //add line break
}

tText;

Oh lol, I didn’t know you were referring to posting code on these forums. Yup, just wrap them in pre tags and then those in code tags. Demo:


<?php $doh = array('I', 'misunderstood', 'you');
echo implode(' ', $doh);
?>

by
by
by
by
by
by