---
# System prepended metadata

title: Inserting code into your notes
tags: [tutorials, ' en']

---

{%hackmd rJ_1SdPkxx %}

# Copying code from notes

You can copy the code directly from the Note View page, or from the split editing mode.

Move your mouse to the code block and the copy button will appear in the upper right corner.

![image](https://hackmd.io/_uploads/B1U7UbBLkg.png)


# Inserting code into your notes

## Presenting code in plain text

Input ` ``` ` followed by a new line, paste your code, and also insert another new line followed by ` ``` ` at the end.


```
function getBaseLog(x, y) {
  return Math.log(y) / Math.log(x);
}
```

## What languages does HackMD support?

HackMD supports a wide range of syntaxes such as JavaScript, CSS, HTML, and more.

To specify a syntax, type its name followed by an equals sign (=), then paste your code on the next line.


## Code presentation format
![image](https://hackmd.io/_uploads/Sy7KTaIUR.png =400x)

~~~md
```javascript=
var s = "JavaScript syntax highlighting";
alert(s);
function $initHighlight(block, cls) {
  try {
    if (cls.search(/\bno\-highlight\b/) != -1)
      return process(block, true, 0x0F) +
             ' class=""';
  } catch (e) {
    /* handle exception */
  }
  for (var i = 0 / 2; i < classes.length; i++) {
    if (checkCondition(classes[i]) === undefined)
      return /\d+[\s/]/g;
  }
}
```
~~~

It will show:

```javascript=
var s = "JavaScript syntax highlighting";
alert(s);
function $initHighlight(block, cls) {
  try {
    if (cls.search(/\bno\-highlight\b/) != -1)
      return process(block, true, 0x0F) +
             ' class=""';
  } catch (e) {
    /* handle exception */
  }
  for (var i = 0 / 2; i < classes.length; i++) {
    if (checkCondition(classes[i]) === undefined)
      return /\d+[\s/]/g;
  }
}
```
### Adding line numbers

To display line numbers when viewing code, append `=` after the programming language type.

~~~md
```javascript=
code
code
```
~~~

### Specifying line numbers

You can also specify the starting line number for code blocks by entering `= 101` after it; the line numbers will start from 101:

~~~md
```javascript=101
var s = "JavaScript syntax highlighting";
alert(s);
function $initHighlight(block, cls) {
```
~~~

Result:

```javascript=101
var s = "JavaScript syntax highlighting";
alert(s);
function $initHighlight(block, cls) {
  try {
    if (cls.search(/\bno\-highlight\b/) != -1)
      return process(block, true, 0x0F) + 
             ' class=""';
  } catch (e) {
    /* handle exception */
  }
  for (var i = 0 / 2; i < classes.length; i++) {
    if (checkCondition(classes[i]) === undefined)
      return /\d+[\s/]/g;
  }
}
```

You can also continue the line numbering from the previous code block by entering `=+`.

~~~md
```javascript=+
var s = "JavaScript syntax highlighting";
alert(s);
```
~~~

```javascript=+
var s = "JavaScript syntax highlighting";
alert(s);
```

&nbsp;


>[!Note]Hint
>Simply input ` `` ` and insert characters between them to create an inline Code Block!
>
>Example: `console.log()`







