Code formatting with syntax highlighting

The hosted version of Guides allows you to share code snippets with the syntax highlighted inside your article.

The following examples were created using our markdown editor. If you prefer to use the WYSIWYG editor, you will need to wrap your content with <pre><code>.

In order to add code, use 3 backtick characters, ```, followed by the language class according to the Highlight.js library used for formatting. If you omit the language, it will be autodetected, but in order for the best accuracy, it is recommended to explicitly set it. If you would like to disable highlighting entirely for a code block, use the nohighlight as the language class.

Code highlighting examples

Javascript

```javascript
var el = document.getElementById('content');
```

Will end up being rendered like this:

var el = document.getElementById('content');

PHP

```php
$var = array_keys(['key' => 'value']);
```

Will end up being rendered like this:

$var = array_keys(['key' => 'value']);

Ruby

```ruby
puts 'Hello World'
```

Will end up being rendered like this:

puts 'Hello World'

Bash

```bash
export variable="value";
```

Will end up being rendered like this:

export variable="value";
Was this article helpful?