You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-29Lines changed: 40 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,9 +79,11 @@ Add to your `gatsby-config.js` (all options are optional; defaults shown here):
79
79
80
80
Write code examples in your markdown file as usual:
81
81
82
-
```js
83
-
this.willBe(highlighted);
84
-
```
82
+
````md
83
+
```js
84
+
this.willBe(highlighted);
85
+
```
86
+
````
85
87
86
88
## Dark mode support via `prefers-color-scheme`
87
89
@@ -107,7 +109,8 @@ Generally, you probably don’t need or want to set all three `colorTheme` optio
107
109
108
110
The following can be used without specifying an extension to download from the marketplace:
109
111
110
-
#### Languages
112
+
### Languages
113
+
111
114
<details>
112
115
<summary>See all 55 languages</summary>
113
116
@@ -166,11 +169,13 @@ The following can be used without specifying an extension to download from the m
166
169
- XML
167
170
- XML XSL
168
171
- YAML
172
+
169
173
</details>
170
174
171
175
Language names are resolve case-insensitively by any aliases and file extensions listed in the grammar’s metadata. For example, a code fence with C++ code in it can use [any of these language codes](https://github.com/Microsoft/vscode/blob/da3c97f3668393ebfcb9f8208d7616018d6d1859/extensions/cpp/package.json#L20-L21). You could also check the [built-in grammar manifest](https://unpkg.com/gatsby-remark-vscode@1.0.3/lib/grammars/manifest.json) for an exact list of mappings.
172
176
173
-
#### Themes
177
+
### Themes
178
+
174
179
Pro tip: a good way to preview themes is by flipping through them in VS Code. Here’s the list of included ones:
175
180
176
181
- Abyss
@@ -221,7 +226,7 @@ Next time you `gatsby develop` or `gatsby build`, the extension will be download
221
226
222
227
Anonymous requests to the Visual Studio Marketplace are rate limited, so if you’re downloading a lot of extensions or running builds in quick succession in an environment where the extensions aren’t already cached on disk (like on a build server), you might see failed requests.
223
228
224
-
As a workaround, you can set the `extensionDataDirectory` plugin option to an absolute path pointing to a folder that you check into source control. After running a build locally, any extensions you’ve requested will appear in that directory. Then, in CI, gatsby-remark-vscode will check that directory and determine if anything needs to be downloaded. By checking including the extensions alongside your own source code, you can avoid making requests to the Visual Studio Marketplace in CI entirely.
229
+
As a workaround, you can set the `extensionDataDirectory` plugin option to an absolute path pointing to a folder that you check into source control. After running a build locally, any extensions you’ve requested will appear in that directory. Then, in CI, gatsby-remark-vscode will check that directory and determine if anything needs to be downloaded. By including the extensions alongside your own source code, you can avoid making requests to the Visual Studio Marketplace in CI entirely.
225
230
226
231
## Styles
227
232
@@ -278,31 +283,35 @@ Since the CSS for token colors is auto-generated, it’s fragile and inconvenien
278
283
279
284
`gatsby-remark-vscode` offers the same line-range-after-language-name strategy of highlighting or emphasizing lines as [gatsby-remark-prismjs](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-remark-prismjs):
280
285
281
-
```js{1,3-5}
282
-
this.isLine(1); // highlighted
283
-
this.isLine(2);
284
-
this.isLine(3); // highlighted
285
-
this.isLine(4); // highlighted
286
-
this.isLine(5); // highlighted
287
-
```
286
+
````md
287
+
```js{1,3-5}
288
+
this.isLine(1); // highlighted
289
+
this.isLine(2);
290
+
this.isLine(3); // highlighted
291
+
this.isLine(4); // highlighted
292
+
this.isLine(5); // highlighted
293
+
```
294
+
````
288
295
289
296
Comment directives are also supported:
290
297
291
-
```js
292
-
functionconstant(value) {
293
-
return () => value; // highlight-line
294
-
}
298
+
````md
299
+
```js
300
+
functionconstant(value) {
301
+
return () => value; // highlight-line
302
+
}
295
303
296
-
// highlight-next-line
297
-
constalwaysFour=constant(4);
304
+
// highlight-next-line
305
+
constalwaysFour=constant(4);
298
306
299
-
// highlight-start
300
-
constzero= [0, 1, 2, 3, 4, 5]
301
-
.map(alwaysFour)
302
-
.filter(x=> x !==4)
303
-
.length;
304
-
// highlight-end
305
-
```
307
+
// highlight-start
308
+
constzero= [0, 1, 2, 3, 4, 5]
309
+
.map(alwaysFour)
310
+
.filter(x=> x !==4)
311
+
.length;
312
+
// highlight-end
313
+
```
314
+
````
306
315
307
316
You need to pick your own background color, and optionally a left border width and color, for the highlighted lines. This can be done by setting CSS variables:
308
317
@@ -331,9 +340,11 @@ The `colorTheme` option can take a function instead of a constant value. The fun
331
340
332
341
Line numbers and ranges aren’t the only things you can pass as options on your code fence. A JSON-like syntax is supported:
`gatsby-remark-vscode` doesn’t inherently understand these things, but it parses the input and allows you to access it in the `colorTheme`, `wrapperClassName` and `getLineClassName` functions:
0 commit comments