| 1 | --- |
| 2 | name: line-numbers |
| 3 | description: Enable line numbering for code blocks globally or per-block |
| 4 | --- |
| 5 | |
| 6 | # Code Block Line Numbers |
| 7 | |
| 8 | Enable line numbering for code blocks. |
| 9 | |
| 10 | ## Global Setting |
| 11 | |
| 12 | Enable for all code blocks in headmatter: |
| 13 | |
| 14 | ```md |
| 15 | --- |
| 16 | lineNumbers: true |
| 17 | --- |
| 18 | ``` |
| 19 | |
| 20 | ## Per-Block Setting |
| 21 | |
| 22 | ````md |
| 23 | ```ts {6,7}{lines:true,startLine:5} |
| 24 | function add( |
| 25 | a: Ref<number> | number, |
| 26 | b: Ref<number> | number |
| 27 | ) { |
| 28 | return computed(() => unref(a) + unref(b)) |
| 29 | } |
| 30 | ``` |
| 31 | ```` |
| 32 | |
| 33 | ## Options |
| 34 | |
| 35 | - `lines: true/false` - Enable/disable line numbers |
| 36 | - `startLine: number` - Starting line number (default: 1) |
| 37 | |
| 38 | ## With Line Highlighting |
| 39 | |
| 40 | Use `{*}` as placeholder when combining with other features: |
| 41 | |
| 42 | ````md |
| 43 | ```ts {*}{lines:true,startLine:5} |
| 44 | // code here |
| 45 | ``` |
| 46 | ```` |
| 47 |