1.

Syntax Highlighting

Answer»

We can highlight code syntaxes using markdown by using a backtick(``) symbol before and after the code block. For multiline code formatting, we can also use 3 backticks for the purpose as illustrated in the example below.

  • Example for single line code:

This is an example of a `code` block.

Output:

This is an example of a code block.

  • Example for multiline code:

```
This is an
example of
multiline code block.
```

Output:


This is an
example of
multiline code block.

Code Highlighting:


  • We can highlight code snippets using the 3 backticks:

  • Syntax:

```
int x = 10;
cout << x << endl;
```
Output:

int x = 10;
cout << x << endl;

Code Highlighting with Language specified:


  • We can highlight code snippets for a specific language too, along with syntax highlighting by specifying the language name along with the 3 backticks. By doing this, the data types and variables will be highlighted in different colours for differentiating between them and for better visibility.

  • Example Syntax for C++:

```C++
int x = 10;
cout << x << endl;
```
Output:

int x = 10;
cout << x << endl;


Discussion

No Comment Found