|
1 |
| -Annotations allow you to change how the code is displayed and also to add interactivity. |
2 |
| - |
3 |
| -<CH.Spotlight lineNumbers={true}> |
4 |
| - |
5 |
| -````mdx mark=1[7:13],5[1:7] |
6 |
| -```py focus=2 |
7 |
| -print(1) |
8 |
| -print(2) |
9 |
| -print(3) |
10 |
| -# focus |
11 |
| -print(4) |
12 |
| -print(5) |
| 1 | +```js |
| 2 | +foo |
| 3 | +// link(1:2) https://codehike.org |
| 4 | +const hi = 'hi' |
| 5 | +const hi = 'hi' |
| 6 | +const hi = 'hi' |
| 7 | +// link[2:18] https://codehike.org |
| 8 | +hello world |
| 9 | +hello |
13 | 10 | ```
|
14 |
| -```` |
15 |
| - |
16 |
| -There are two ways to add annotations: |
17 |
| - |
18 |
| ---- |
19 |
| - |
20 |
| -```mdx mark=1[7:13],5[1:7] focus=1 |
21 |
| - |
22 |
| -``` |
23 |
| - |
24 |
| -- using the codeblock metastring |
25 |
| - |
26 |
| ---- |
27 |
| - |
28 |
| -```mdx mark=1[7:13],5[1:7] focus=5 |
29 |
| - |
30 |
| -``` |
31 |
| - |
32 |
| -- using comments inside the code |
33 |
| - |
34 |
| -</CH.Spotlight> |
35 |
| - |
36 |
| -_`focus`_ is only one of the possible annotations. The full list is: |
37 |
| - |
38 |
| -- _`focus`_: keep the targeted code bright while dimming the rest |
39 |
| -- _`mark`_: add a background color to the targeted tokens |
40 |
| -- _`link`_: add links inside the code |
41 |
| - |
42 |
| -First let's see the syntax to target different parts of the code. |
43 |
| - |
44 |
| -## Targeting lines and columns |
45 |
| - |
46 |
| -<CH.Spotlight maxZoom={1.5} lineNumbers={true} > |
47 |
| - |
48 |
| -<CH.Code lineNumbers={true}> |
49 |
| - |
50 |
| -```text |
51 |
| -123456789 |
52 |
| -123456789 |
53 |
| -123456789 |
54 |
| -123456789 |
55 |
| -123456789 |
56 |
| -123456789 |
57 |
| -123456789 |
58 |
| -``` |
59 |
| - |
60 |
| -</CH.Code> |
61 |
| - |
62 |
| ---- |
63 |
| - |
64 |
| -```text focus=2 |
65 |
| -123456789 |
66 |
| -123456789 |
67 |
| -123456789 |
68 |
| -123456789 |
69 |
| -123456789 |
70 |
| -123456789 |
71 |
| -123456789 |
72 |
| -``` |
73 |
| - |
74 |
| -To select a specific line, use the line number: |
75 |
| -_`focus=2`_ |
76 |
| - |
77 |
| ---- |
78 |
| - |
79 |
| -```text focus=3:5 |
80 |
| -123456789 |
81 |
| -123456789 |
82 |
| -123456789 |
83 |
| -123456789 |
84 |
| -123456789 |
85 |
| -123456789 |
86 |
| -123456789 |
87 |
| -``` |
88 |
| - |
89 |
| -To select a range of lines use a colon: |
90 |
| -_`focus=3:5`_ |
91 |
| - |
92 |
| ---- |
93 |
| - |
94 |
| -```text focus=5[3:6] |
95 |
| -123456789 |
96 |
| -123456789 |
97 |
| -123456789 |
98 |
| -123456789 |
99 |
| -123456789 |
100 |
| -123456789 |
101 |
| -123456789 |
102 |
| -``` |
103 |
| - |
104 |
| -Select a range of column from a line using brackets: |
105 |
| -_`focus=5[3:6]`_ |
106 |
| - |
107 |
| ---- |
108 |
| - |
109 |
| -```text focus=1,3:5,7[1:4,7:9] |
110 |
| -123456789 |
111 |
| -123456789 |
112 |
| -123456789 |
113 |
| -123456789 |
114 |
| -123456789 |
115 |
| -123456789 |
116 |
| -123456789 |
117 |
| -``` |
118 |
| - |
119 |
| -Combine selectors using a comma separated list: |
120 |
| -_`focus=1,3:5,7[1:4,7:9]`_ |
121 |
| - |
122 |
| -</CH.Spotlight> |
123 |
| - |
124 |
| -## Comment syntax |
0 commit comments