Skip to content

Latest commit

 

History

History
75 lines (56 loc) · 1.54 KB

File metadata and controls

75 lines (56 loc) · 1.54 KB
title description icon
Code Blocks
Display code with optional syntax highlighting
code
```javascript Code Block Example
const hello = "world";
```

Basic Code Block

Use fenced code blocks by enclosing code in three backticks.

helloWorld();
```
helloWorld();
```

Syntax Highlighting

Put the name of your programming language after the three backticks to get syntax highlighting.

We use Prism for syntax highlighting. Test Drive Prism lists all the languages supported.

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
```java
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
```

Names

You can add more text after the programming language to set the name of your code example. The text can be anything as long as its all in one line.

const hello = "world";
```javascript Code Block Example
const hello = "world";
```

Code Groups

Want to display multiple code examples in one code box? Check out the Code Group docs:

Read the reference for the Code Group component