Code Block Shortcode

Settings for generate different functions Code Blocks

Code Example #

Block Content #

```
## This is the content
```

Will results:

## This is the content

Syntax Highlight #

Add languages after ```

```javascript
document.getElementById('demo').innerHTML = 'Hello JavaScript';
```

Will results:

document.getElementById("demo").innerHTML = "Hello JavaScript";

Display Line Numbers #

Line Numbers are not displayed by default.

Use linenos in parameters.

```javascript {linenos=true}
document.getElementById('demo').innerHTML = 'Hello JavaScript';
```

Will results:

1
2
document.getElementById("demo").innerHTML = "Hello JavaScript";
document.getElementById("demo").innerHTML = "Hello JavaScript";

Change Starting Line Number #

Use linenostart in parameters.

```python {linenos=true,linenostart=13}
```

Will results:

13
14
15
16
17
18
19
20
21
22
23
24
class BankAccount(object):
    def __init__(self, initial_balance=0):
        self.balance = initial_balance
    def deposit(self, amount):
        self.balance += amount
    def withdraw(self, amount):
        self.balance -= amount
    def overdrawn(self):
        return self.balance < 0
my_account = BankAccount(15)
my_account.withdraw(50)
print (my_account.balance, my_account.overdrawn())

Highlight Certain Lines #

Use hl_lines in parameters.

```ts {linenos=true,hl_lines=[3,"8-10"]}
```

Will results:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
interface User {
  name: string;
  id: number;
}

const user: User = {
  username: "Hayes",
Type '{ username: string; id: number; }' is not assignable to type 'User'.
  Object literal may only specify known properties, and 'username' does not exist in type 'User'.
Type '{ username: string; id: number; }' is not assignable to type 'User'.
  Object literal may only specify known properties, and 'username' does not exist in type 'User'.
  id: 0,
};

Without Line Number:

```ts {hl_lines=[3,"8-10"]}
```

Will results:

interface User {
  name: string;
  id: number;
}

const user: User = {
  username: "Hayes",
Type '{ username: string; id: number; }' is not assignable to type 'User'.
  Object literal may only specify known properties, and 'username' does not exist in type 'User'.
Type '{ username: string; id: number; }' is not assignable to type 'User'.
  Object literal may only specify known properties, and 'username' does not exist in type 'User'.
  id: 0,
};
Code Block Shortcode was last edited on 2021-01-13 @16a6725 : update formatting