Code Blocks

To create code blocks, indent every line of the block by at least four spaces or one tab.

Optionally you can also use Fenced Code Blocks, you’ll use three backticks (```) or three tildes (~~~) on the lines before and after the code block. This way you don’t have to indent any lines!

```
{
    "firstName": "John",
    "lastName": "Smith",
    "age": 25
}
```
{
    "firstName": "John",
    "lastName": "Smith",
    "age": 25
}

Syntax Highlighting

You can also use syntax highlighting with Fenced Code Blocks. For this you only have to add the language after the backticks.

```json
{
    "firstName": "John",
    "lastName": "Smith",
    "age": 25
}
```
{
    "firstName": "John",
    "lastName": "Smith",
    "age": 25
}

Here is a list of all the languages that can get syntax styling.

You can add line numbers by adding lineos=true. You can even mark/highlight part of the code by adding hl_lines with the according lines you want to highlight:

```json {title="JSON", hl_lines=["2-3", 6], linenos=true}
{
    "firstName": "John",
    "lastName": "Smith",
    "age": 25,
    "residence": "Amsterdam",
    "occupation": "Developer
}
```
JSON
1{
2    "firstName": "John",
3    "lastName": "Smith",
4    "age": 25,
5    "residence": "Amsterdam",
6    "occupation": "Developer"
7}

It’s also possible to set lineos=table if you want to have table html for the line numbers:

Table
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
package ci

import (
	"path"
	"encoding/yaml"
	"tool/file"

	// initialised at the start of this guide, followed by the relative path from the repository root to the `github` directory.
	"github.com/cue-examples/github-actions-example/internal/ci/github"
)

Other options that can be added after defining a language can be found here.

Attributes

We’ve added some custom attributes on the code fence block.

title
optional - Title of the codeblock.
type
optional - Editor type Can be ‘default’ or ’terminal’. For default you can also omit this attribute
codeToCopy
optional - By default the copy button copies the inner content. You can change that by passing in code with this attribute. Make sure it’s base64 encoded when you pass something to this attribute. You can also set it to false to hide the copy button.
```json {title="JSON" codeToCopy=false
{
    "firstName": "John",
    "lastName": "Smith",
    "age": 25
}
```
JSON
{
    "firstName": "John",
    "lastName": "Smith",
    "age": 25
}
```json {title="TERMINAL" type="terminal"}
$ cue vet schema.cue  data.yaml
languages.1.name: invalid value “dutch” (does not compute or something)
     ./schema.cue:3:8
     ./data.yaml:5:12
```
TERMINAL
$ cue vet schema.cue  data.yaml
languages.1.name: invalid value “dutch” (does not compute or something)
     ./schema.cue:3:8
     ./data.yaml:5:12

Single Column

The above examples are created by using the columns and columns-separator shortcode. Of course it is also possible to have a code example that is page-wide.

```bash
brew install cue-lang/tap/cue
```
brew install cue-lang/tap/cue

With title

```vshell {title="V shell"}
brew install cue-lang/tap/cue
```
V shell
brew install cue-lang/tap/cue