Formatting source code in posts

edited January 2015 in UC Berkeley CS160

This forum uses Markdown, so you can create preformatted code spans and code blocks in the usual way.

To post code within a normal paragraph, wrap it in backtick quotes (`).

    Use the `printf()` function.

To post a block of code, simply indent every line of the block by at least 4 spaces or 1 tab. (One level of indentation — 4 spaces or 1 tab — is removed from each line of the code block.)

    // Wait 400ms for the data to become available
    sensorUtils.mdelay( 400 );

    // Read the data from the sensor, formatted as a JSON-encoded string
    var rawValue = serial.readAll( pins, "'jsonstring'" );
Sign In or Register to comment.