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
@@ -392,12 +399,28 @@ unless explicitly overridden by the `promptUser` and `promptHost` options in the
392
399
393
400
### Diff code blocks
394
401
395
-
You can specify language for `diff` code blocks by using `diff-[language]` to enable syntax highlighting in diffs:
402
+
You can specify language for `diff` code blocks by using `diff-[language]` to enable syntax highlighting in diffs. Canonically, when writing code _diffs_, the code should be indented by two characters. If the code is being changed, the first character should be a `+`, `-`, or `!` otherwise left a space. The second character should always be a space. Git-style file-location coordinates need not be indented.
396
403
397
404
````
398
405
```diff-javascript
406
+
@@ -4,6 +4,5 @@
407
+
const doTheThing = aParm => {
408
+
+ console.log(`Parm is: ${aParm}`)
409
+
- console.log('Hit this function')
410
+
! console.log('Rubber duck debugging anybody?')
411
+
return true
412
+
}
413
+
```
399
414
````
400
415
416
+
The default rendering style for diff code blocks will be a colored `+` or `-` symbol and _not_ full line-length highlighting. This is depicted in the **first** example here: https://prismjs.com/plugins/diff-highlight/
417
+
418
+
This plugin supports a configuration parameter, `showDiffHighlight`, which will add full line-length highlighting to _all_ Diff code blocks used by your Gatsby site with the format: `+` -> Highlight green, `-` -> highlight red, and `!` -> bolded line. Simply pass the configuration parameter with `true` and add the following to your `gatsby-browser.js` (_after_ the require for your chosen theme):
As well as highlighting lines, it's possible to _hide_ lines from the rendered output. Often this is handy when using `gatsby-remark-prismjs` along with [`gatsby-remark-embed-snippet`](https://www.gatsbyjs.org/packages/gatsby-remark-embed-snippet/).
@@ -520,6 +543,10 @@ throw our overflow and background on `.gatsby-highlight`, and use
520
543
`display:block` on `.gatsby-highlight-code-line` – all of this coming together
521
544
to facilitate the desired line highlight behavior.
522
545
546
+
**NOTE:** This is _not_ the same as the Diff code-block full line-length
547
+
highlighting for diff'd lines. Those "line highlights" work great beyond
548
+
the above.
549
+
523
550
### Line numbering
524
551
525
552
Because [the line numbering PrismJS plugin][7] runs client-side, a few adaptations were required to make it work:
0 commit comments