Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Paul Dietrich
Paul Dietrich
4,557 Points

How to type code in the forum

Hi guys,

I think I've asked this about three times or so already, and I keep forgetting: how do I add code to the forum and place it in a box? I've seen that it's maybe < code> </ code> or putting " ``` " before the text, but those don't work for me.

Is there a way to have a feature where you can highlight the code in the textbox and hit a "Code Tag" button? I'm perfectly fine with writing the code myself, but I just keep forgetting the actual command to do so.

Thanks.

<strong>test</strong

Viraj Kokane
Viraj Kokane
17,531 Points

<Body> <p>hello world</p> </body>

Viraj Kokane
Viraj Kokane
17,531 Points

`<Body> <p>hello world</p> </body>'

Viraj Kokane
Viraj Kokane
17,531 Points
<body>
  <p>hello world</p>
</body>
Viraj Kokane
Viraj Kokane
17,531 Points
<body>
  <p>hello world</p>
</body>
Cameron O'Brien
Cameron O'Brien
11,564 Points
telnet httpbin.org 80
GET / HTTP/1.1
Host: httpbin.org

test

108 Answers

James Barnett
James Barnett
39,199 Points

Paul Dietrich - There are 3.5 different ways to format code on the forum, here's a primer for you.

Option 1) Inline code like this code use the ` key to enclose your string of code

Option 2) Indent each line of code by one tab or 4 spaces

<Body>
  <p>hello world</p>
</body>

Option 3) Code fences, you need a blank line before your code fence

Enter this:

```
<body>
  <p>hello world</p>
</body>
```

It will give you this:

<body>
  <p>hello world</p>
</body>

Option 3b) Syntax highlighting, use the code fences and specify a language:

Enter this:

```ruby
def my_method(syntax)
  syntax.is_highlighted?
end
```

It will give you this:

def my_method(syntax)
  syntax.is_highlighted?
end
Zac Gordon
Zac Gordon
Treehouse Guest Teacher

Test 1:

<article>
  <h1><?php the_title(); ?></h1>
  <?php the_excerpt(); ?>
  <br>
</article>

Test 2:

<article>
  <h1><?php the_title(); ?></h1>
  <?php the_excerpt(); ?>
  <br>
</article>
Adam Waite
Adam Waite
3,996 Points

Test code block:

var myVar;

undefined = true;
Patrick Koch
Patrick Koch
40,496 Points

Test <html> <title>Code Block Test</title> <body> </body> </html>

Patrick Koch
Patrick Koch
40,496 Points
<body>
  <p>hello world</p>
</body>

Test

CELLS = []
for x in range(0,10):
    for y in range(0,10):
        CELLS.append((x,y))
Alberto Castro
Alberto Castro
9,311 Points
<Body>
  <p>hello world</p>
</body>
Spen Taylor
Spen Taylor
13,027 Points

as in :

code?

4 spaces should the trick, although I find I have to go back and edit some lines of code, but thats probably my bad anyway!

James Barnett
James Barnett
39,199 Points

Paul Dietrich - Your issue with '```' is probably you aren't putting the necessary, 1 line of white space between your text and the start of your code block.

This is how I imagine Prof Stephen Hawkins to type by default :/

test
    <html>
        <title>Code Block Test</title>
        <body>
        </body>
    </html>
<html>
    <head>
           <title>Something</title>
    </head>
    <body>
        <p>Something Else</p>
    </body>
   </html>
<code>
Viraj Kokane
Viraj Kokane
17,531 Points

`<html> <head> <title>Something</title> </head> <body> <p>Something Else</p> </body> </html>'

James Barnett
James Barnett
39,199 Points

Here are a few other Github-flavored markdown tricks:

You can use numbers for reference-style link definitions

You can even create reference-style links with parentheses in them


Strike through with ~~done~~

done


H1

Headers with equal signs underneath.

Alt-H1

this is only a test

Mike Casteel
Mike Casteel
7,960 Points
<body>
  <p>hello world</p>
</body>

TEST

Paul Yorde
Paul Yorde
10,497 Points
<html>

<!-- A < a -->

</html>

test

def my_method(syntax)

  syntax.is_highlighted?

end
<html>
  <title>
  </title>
</html>
Andy Simmons
PLUS
Andy Simmons
Courses Plus Student 3,734 Points

Test

<html>
    <head attr="someValue">
    </head>
    <body>
        Some text
    </body>
</html>
Carlos Fernando Gómez Carrero
Carlos Fernando Gómez Carrero
46,984 Points

test

<html>
    <head>
    </head>
    <body>
        <p>HELLO</p>
    </body>
</html>
<body>
    <p>Hello World</p>
</body>
<p> 
HELLOOO
</p>
Arsallan Shirvani
Arsallan Shirvani
3,852 Points

Testing...

<html>
    <head>
        <title>The Grid</title>
    </head>
    <body>
        <p>
            The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? Motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day... I got in.
        </p>
    </body>
</html>
Alice Barton
Alice Barton
1,053 Points
<body>
  <p>hi there, this is a test</p>
</body>
Chris Scott
Chris Scott
7,673 Points
<body>
  <p>hi there, this is a test</p>
</body>
Megan Boyd
Megan Boyd
1,210 Points

test

<body>
  <p>hi there, this is a test</p>
</body>
<body> 
       <p>Hello Test!</p>
</body>
<!DOCTYPE html>
<head>
    <title>This is only a test</title>
</head>
<body>
    <p> This is a paragraph </p>
</body>

Test 2

<?php 
    $args = array(
        'post_type' => 'work'
    );

    $the_query = new WP_Query( $args );
?>
Umar Alkhamis
Umar Alkhamis
1,068 Points

This is a test

<body>
    <h1>This is a level 1 headline</h1>
</body>

Testing!

<p>Hello hello </p>

=-

<body>
   <p>test</p>
</body>
Jonathan Carroll
Jonathan Carroll
3,438 Points
<body>

<p> hello world </p>

</body>
Will Vincent
Will Vincent
2,594 Points

<body>

<p> hello world </p>

</body

Will Vincent
Will Vincent
2,594 Points

this is a test:

<body> <h1>This is A test</h1>

Test

<h1>Hello</h1>
  <p>hello world test</p>

Test test test

<h1>I'm So Cool</h1>
    <p>Treehouse rules!</p>
Vernon Watson
Vernon Watson
8,854 Points

TEST

SELECT movies.title, IFNULL(AVG(score),0) AS average 
FROM reviews RIGHT OUTER JOIN movies 
ON movies.id = reviews.movie_id 
GROUP BY movie_id HAVING average < 2;
<h1>Test</h1>

This is a test

@property(strong,nonatomic) NSMutableArray *arrayTest;

Awesome lol

Testing...

    #copyright {
      border-top: 8px solid;
      border-color: #2A0400;
}

One more...

    #copyright {
      border-top: 8px solid;
      border-color: #2A0400;
}

Doesn't the simple Markdown code block notation of a tab (or 4 spaces) work?

James Barnett
James Barnett
39,199 Points

James Gill - As I noted in option 2, yes it does a tab or 4 spaces works the same way as using a single backtick. If you want to do multiple lines you need a code fence or a set of 3 backticks as I noted in option 3.

Any questions?

trying to put a block of code here...

<body>
<p>A paragraph</p>
</body>

round two <body> <p>A paragraph</p> <body>

used 4 spaces... we'll see!

????

<body>
<p>A paragraph.</p>
<body>

ahhhh... that works.

Erik McClintock
Erik McClintock
45,783 Points
<html>
    <head>
        <title>Testing</title>
    </head>
    <body>
        <p>Here's another test.</p>
    </body>
</html>
Erik McClintock
Erik McClintock
45,783 Points
<html>
<head>
<title>Test w/o Indentation</title>
</head>
<body>
<p>Does it look right?</p>
</body>
</html>
John Schnettgoecke
John Schnettgoecke
2,012 Points

test

''' <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Smells Like Bakin' Cupcake Company</title> <link rel="stylesheet" href="css/normalize.css" type="text/css" media="screen"> <link rel="stylesheet" href="css/grid.css" type="text/css" media="screen"> </head> '''

John Schnettgoecke
John Schnettgoecke
2,012 Points

'''html

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Smells Like Bakin' Cupcake Company</title> <link rel="stylesheet" href="css/normalize.css" type="text/css" media="screen"> <link rel="stylesheet" href="css/grid.css" type="text/css" media="screen"> </head> '''

Chase Lee
Chase Lee
29,275 Points

John Schnettgoecke you need to use a backtick `. You're using a single quote.

Just a test!

@media screen and (max-width: 300px) {
    #myItem li:nth-child(2n+1) {
    clear: left;
  }
}
Alastair Halliday
Alastair Halliday
249 Points

even more testing

void addTwo(){
   // float alpha = 1.11;
    float beta = 2.22;
    //float result = alpha + beta;
    printf("result is %f\n", beta);
}

test

float addTwo (float a, float b);

float addTwo (float a, float b){
return a + b;
}
Tamsin Waters
Tamsin Waters
6,116 Points
         test 
       <li>
        <a href="img/summer.JPG">
            <img src="img/summer.JPG" alt="">
            <p>Summer Album</p>
        </a>
    </li> '

Just a test!

<body>
  <p>hello world</p>
</body>
Kirk Woodill
Kirk Woodill
7,078 Points

Test

<html>
<body>
  <div>
    <p>Hello!</p>
  </div>
</body>
</html>
Julio Pereira
Julio Pereira
7,459 Points

'''html <body> <p>hello world</p> </body> ''''

This is a Venezuelan Test!

Juan Martin
Juan Martin
14,335 Points

<Body> <p>hello world</p> </body>

def my_method(syntax)
  syntax.is_highlighted?
end
Juan Martin
Juan Martin
14,335 Points

test

def my_method(syntax)
  syntax.is_highlighted?
end
Juan Martin
Juan Martin
14,335 Points

test

def my_method(syntax)
  syntax.is_highlighted?
end
Juan Martin
Juan Martin
14,335 Points

<p>hello</p>

def my_method(syntax)
  syntax.is_highlighted?
end
Juan Martin
Juan Martin
14,335 Points

This is an example link ```ruby def my_method(syntax) syntax.is_highlighted? end

Juan Martin
Juan Martin
14,335 Points

This is an example link

def my_method(syntax)
  syntax.is_highlighted?
end
<!DOCTYPE html>
<html>
</html>
<p> test code</p>
<p> this is just a test </p>
Travis DePriest
Travis DePriest
696 Points

Test

<body>
  <p>hello world</p>
</body>
Kristopher Keen
Kristopher Keen
9,992 Points

This is a test.

shopping_list = []

def show_help():
  print("What should we pick up at the store?")
  print("Enter DONE to stop. Enter HELP for this help. Enter SHOW to show list")

def add_to_list(item):
  shopping_list.append(item)
  print("Added! List has {} items.".format(len(shopping_list)))


def show_list():
  print("Here's you list:")
  for item in shopping_list:
    print(item)

hope it works.

Eric Vandenberg
Eric Vandenberg
9,095 Points
<button type="button">Test</button>
Philip Campbell
Philip Campbell
15,324 Points

Testing.

<body>
    <p>Test</p>
</body>
Dominik Sikiric
Dominik Sikiric
2,059 Points
var userNumber = prompt("write down one number");
parseInt(userNumber);
var sve = Math.random()*userNumber;
Math.floor(sve);
alert(Math.random()*userNumber);
Adam Bell
Adam Bell
1,176 Points

'test <li> <a href="img/summer.JPG"> <img src="img/summer.JPG" alt=""> <p>Summer Album</p> </a> <'

Adam Bell
Adam Bell
1,176 Points

String firstName = "Gordon";

// string lastName = "Sumner";

// console.printf("Hello %s", firstName)

// band = console.readLine("Which band?  ");
Adam Bell
Adam Bell
1,176 Points

^ was just practicing

<?php
require "vendor/autoload.php";

  date_default_timezone_set("America/Cancun");

  use Monolog\Logger;
  use Monolog\Handler\StreamHandler;

  $log = new Logger('name');
  $log->pushHandler(new StreamHandler('app.txt', Logger::WARNING));

  $log->addWarning('Warning!.');

  echo "Hello World!";
Juan Martin
Juan Martin
14,335 Points
<p></p>
var a = "hello";
public class Game {
  private String mAnswer;
  /// final means cannot be changed alcaps MAS_MISSES means constant\\\\\
  public static final int MAX_MISSES =7;
  private String mMisses;
  private String mHits;
  //constructor\\\
  public Game(String answer)  {
    mAnswer = answer;
    mHits = "";
    mMisses = "";
    }
  // private method\\\
  private char validateGuess (char letter) {
  if (! Character.isLetter(letter)) {
    throw new IllegalArgumentException("A letter is required");
    }
    letter = Character.toLowerCase(letter);
    if (mMisses.indexOf(letter) >= 0 || mHits.indexOf(letter) >=0) {
      throw new IllegalArgumentException(letter + "has already been guessed");
     }
        return letter;    
  }              
  ///method\\\
  public boolean applyGuess(char letter) {
    letter = validateLetter(letter);
    boolean isHit = mAnswer.indexOf(letter) >=0;
        if (isHit) {
        mHits += letter; 
   } else {
     mMisses += letter;
   }
   return isHit;
  }
public String getCurrentProgress() {
 String progress ="";
  for (char letter: mAnswer.toCharArray()) {
    char display = '-';
    if (mHits.indexOf(letter) >= 0) {
      display = letter;
  }
    progress += display;
    }
    return progress;
  }

  public int getRemainingTries() {
  return MAX_MISSES - mMisses.length(); 
  }

        }

'' test ''

'' test ''

´´´´´gdfgdfg´´´´

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Objects</title>
  <link rel="stylesheet" href="css/styles.css">
</head>
<body>
<h1>Objects</h1>
<div id="output">

</div>
<script src="js/object.js"></script>
</body>
</html>
Anthony Rice
Anthony Rice
7,976 Points

Test

<body>
<p>hello world</p>
</body>

test

angular.js
angular.module("todoListApp",[])

.controller("mainCtrl", function($scope, dataService){

    $scope.addTerm = function(){ };

    dataService.getCloudTerms(
        function(response) {            
            console.log(response.data);
            $scope.cloudTerms = response.data;
            console.log($scope.cloudTerms);
        }
    );

})

.service("dataService", function($http){

    this.getCloudTerms = function(callback){
        $http.get('data/cloudTerms.json')
        .then(callback);
    }

})

'<p>This is only a test</p>'

Kyle Vassella
Kyle Vassella
9,033 Points

I think they really need to include the Markdown Cheatsheet link into the dialogue box when you are trying to start a thread from a video's question section. That would be a (seemingly) easy, huge improvement to the site's functionality.

Michelle Wood
Michelle Wood
1,667 Points

'''python

test = this_is_a

'''

Philip Schultz
Philip Schultz
11,437 Points

test

do
{
     System.out.println("Please enter your name: ");
     name = ScannerObject.nextln();

     if(!(name.matches["a-zA-Z+"]))
      {
      System.out.println("Sorry, the name can only consist of alphabetical characters... please try again");
      }
}while(!(name.matches["a-zA-Z+"]))// this while loop 

Hi there this is just another html test:

<body>
<p>Hello world I am a paragraph just like those Lorem ipsums</p>
<ul>
 <li>tomatoes</li>
 <li>oranges</li>
</ul>
</body>

... <body> <p>testing<p> ...

... <body> <p>Hello world I am a paragraph just like those Lorem ipsums</p> <ul> <li>tomatoes</li> <li>oranges</li> </ul> </body> ...

<p>This is code!<p>

just a test ...

<body>
<p>"Hello"</p>
</body>

Just for practice.

<!DOCTYPE html> 
<html>
  <head>
    <title>The Moon</title>
  </head>
  <body>
  <figure>
    <img src="img/moon.jpg" alt="Hello snitch">
    <figcaption>Hello snitch</figcaption>
  </figure>
  </body>
</html>