Site Logo
Kayal

Code Blocks Highlights

Posted on 1 min

This page provides examples on how to include code blocks with syntax highlighting.

Inline Code

To include inline code, use single backticks:

This is `Inline code`.

Rendered as:

This is Inline Code.

Code block with no highlights

For a basic code block without syntax highlighting, use the following:

```
// ... code
```

Rendered as:

#include <stdio.h>
int main(void)
{
    printf("Hello World\n");
    return 0;
}

Code block with highlights

Mention the language for syntax highlighting, right next to the opening code fence:

```c
// ... code
```

Rendered as:

#include <stdio.h>
int main(void)
{
    printf("Hello World\n");
    return 0;
}

Code block with highlights and line numbers

```c {linenos=true}
// ... code
```

Rendered as:

1
2
3
4
5
6
#include <stdio.h>
int main(void)
{
    printf("Hello World\n");
    return 0;
}
linenos=inline is not supported.

Code with highlighted lines.

```c {linenos=true, hl_lines=[1,4]}
// ... code
```
Rendered as:

1
2
3
4
5
6
#include <stdio.h>
int main(void)
{
    printf("Hello World\n");
    return 0;
}