---
linkTitle: Code Blocks
title: Code Blocks & Highlighting
description: Testing code blocks in the context of paragraphs, and syntax highlighting of the same.
params:
  subtitle: Code blocks are complex and have a styling all their own.
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut venenatis tellus in metus
vulputate eu scelerisque felis imperdiet.

```rust
fn main() {
    println!("Hello world!");
}
```

Consequat semper viverra nam libero justo. Sit amet massa vitae tortor
condimentum lacinia quis vel. Massa massa ultricies mi quis hendrerit dolor
magna eget. Est sit amet facilisis magna etiam tempor orci eu lobortis. Cursus
turpis massa tincidunt dui ut ornare. Elit pellentesque habitant morbi tristique
senectus. Morbi blandit cursus risus at ultrices mi tempus imperdiet nulla. Odio
pellentesque diam volutpat commodo sed egestas egestas fringilla phasellus.
Cursus vitae congue mauris rhoncus.

```c
send(
    register short *to,
    register short *from,
    register count
) {
    register n = (count + 7) / 8;
    switch (count % 8) {
    case 0: do { *to = *from++;
    case 7:      *to = *from++;
    case 6:      *to = *from++;
    case 5:      *to = *from++;
    case 4:      *to = *from++;
    case 3:      *to = *from++;
    case 2:      *to = *from++;
    case 1:      *to = *from++;
            } while (--n > 0);
    }
}
```

Cras tincidunt lobortis feugiat vivamus at augue eget arcu dictum. Fermentum et
sollicitudin ac orci phasellus egestas tellus rutrum tellus. Fermentum leo vel
orci porta non pulvinar neque laoreet. Proin libero nunc consequat interdum
varius sit amet mattis vulputate. Semper viverra nam libero justo laoreet sit.
Consequat id porta nibh venenatis cras sed felis. Ultrices eros in cursus turpis
massa.

```python
def convert_number_to_all_bases(n):
    try:
        n = n.lower()
        if n.startswith('0x'):
            base = 16
        elif n.startswith('0o'):
            base = 8
        elif n.startswith('0b'):
            base = 2
        else:
            base = 10
        num = int(n, base=base)
    except ValueError:
        print(f'Error: cannot parse string as int: {n}', file=sys.stderr)
    else:
        return {
            'bin': str(bin(num)[2:]),
            'oct': str(oct(num)[2:]),
            'dec': str(num),
            'hex': str(hex(num)[2:]).upper(),
        }
```
