Open FIRST Resources


Document -> Additional Features for Code Blocks

Normally in Markdown, you specify code blocks like this:

``` /** * Create a string that describes how long a build took. * @param {Date} startTime when the build was started */ function getBuildDurationString(startTime) { var timeDiff = (new Date() - startTime); var millis = Math.floor(timeDiff % 1000); var seconds = Math.floor((timeDiff/1000) % 60); var minutes = Math.floor(timeDiff/60000); return (minutes ? minutes + 'm ' : '') + (seconds ? seconds + 's ': '') + millis + 'ms'; } ```

which results in

/** * Create a string that describes how long a build took. * @param {Date} startTime when the build was started */ function getBuildDurationString(startTime) { var timeDiff = (new Date() - startTime); var millis = Math.floor(timeDiff % 1000); var seconds = Math.floor((timeDiff/1000) % 60); var minutes = Math.floor(timeDiff/60000); return (minutes ? minutes + 'm ' : '') + (seconds ? seconds + 's ': '') + millis + 'ms'; }

With GitHub and OFR, you can also specify a language to do syntax highlighting:

```javascript ...code... ```

which results in

/** * Create a string that describes how long a build took. * @param {Date} startTime when the build was started */ function getBuildDurationString(startTime) { var timeDiff = (new Date() - startTime); var millis = Math.floor(timeDiff % 1000); var seconds = Math.floor((timeDiff/1000) % 60); var minutes = Math.floor(timeDiff/60000); return (minutes ? minutes + 'm ' : '') + (seconds ? seconds + 's ': '') + millis + 'ms'; }

OFR extends that syntax of things after the ```s (unfortunately it cannot contain spaces):

```#

1 2 3 4 5 6 7 8 9 10 11 12
/** * Create a string that describes how long a build took. * @param {Date} startTime when the build was started */ function getBuildDurationString(startTime) { var timeDiff = (new Date() - startTime); var millis = Math.floor(timeDiff % 1000); var seconds = Math.floor((timeDiff/1000) % 60); var minutes = Math.floor(timeDiff/60000); return (minutes ? minutes + 'm ' : '') + (seconds ? seconds + 's ': '') + millis + 'ms'; }

```javascript#42

42 43 44 45 46 47 48 49 50 51 52 53
/** * Create a string that describes how long a build took. * @param {Date} startTime when the build was started */ function getBuildDurationString(startTime) { var timeDiff = (new Date() - startTime); var millis = Math.floor(timeDiff % 1000); var seconds = Math.floor((timeDiff/1000) % 60); var minutes = Math.floor(timeDiff/60000); return (minutes ? minutes + 'm ' : '') + (seconds ? seconds + 's ': '') + millis + 'ms'; }

```@4@6,hi@1@9

2 1 hi 3
/** * Create a string that describes how long a build took. * @param {Date} startTime when the build was started */ function getBuildDurationString(startTime) { var timeDiff = (new Date() - startTime); var millis = Math.floor(timeDiff % 1000); var seconds = Math.floor((timeDiff/1000) % 60); var minutes = Math.floor(timeDiff/60000); return (minutes ? minutes + 'm ' : '') + (seconds ? seconds + 's ': '') + millis + 'ms'; }

```javascript#42@4@6,hi@1@9

2 1 hi 3
42 43 44 45 46 47 48 49 50 51 52 53
/** * Create a string that describes how long a build took. * @param {Date} startTime when the build was started */ function getBuildDurationString(startTime) { var timeDiff = (new Date() - startTime); var millis = Math.floor(timeDiff % 1000); var seconds = Math.floor((timeDiff/1000) % 60); var minutes = Math.floor(timeDiff/60000); return (minutes ? minutes + 'm ' : '') + (seconds ? seconds + 's ': '') + millis + 'ms'; }