Skip to content

Commit d399868

Browse files
Laurie BarthLaurie Barth
authored andcommitted
prism-highlighting
1 parent 8cff147 commit d399868

22 files changed

+373
-18
lines changed

packages/prism/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ export default {
124124
}
125125
```
126126

127+
## Highlight support
128+
129+
This package supports highlighting inside code blocks. The following two syntaxes are supported:
130+
131+
```js
132+
let str = "highlight" // highlight-line
133+
```
134+
135+
```js
136+
// highlight-start
137+
let str = "highlight"
138+
// highlight-end
139+
```
140+
141+
The highlight styling is controlled in `styles.pre`.
142+
127143
## Additional Languages
128144

129145
Please note that `@theme-ui/prism` uses [`prism-react-renderer`](https://github.com/FormidableLabs/prism-react-renderer), [which does not include all languages supported in Prism](https://github.com/FormidableLabs/prism-react-renderer/blob/master/src/vendor/prism/includeLangs.js) by default. So, if you happen to use one of the missing languages, your code block simply won't show up as highlighted.

packages/prism/presets/dracula.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@
2828
},
2929
".attr-name": {
3030
"color": "rgb(241, 250, 140)"
31+
},
32+
".highlight": {
33+
"background": "hsla(0, 0%, 30%, .5)"
3134
}
3235
}

packages/prism/presets/duotone-dark.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@
3636
},
3737
".important": {
3838
"color": "#c4b9fe"
39+
},
40+
".highlight": {
41+
"background": "hsla(0, 0%, 30%, .5)"
3942
}
4043
}

packages/prism/presets/duotone-light.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@
3939
},
4040
".important": {
4141
"color": "#896724"
42+
},
43+
".highlight": {
44+
"background": "hsla(0, 0%, 70%, .5)"
4245
}
4346
}

packages/prism/presets/github.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@
2828
},
2929
".tag,.selector,.keyword": {
3030
"color": "#00009f"
31+
},
32+
".highlight": {
33+
"background": "hsla(0, 0%, 70%, .5)"
3134
}
3235
}

packages/prism/presets/night-owl-light.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,8 @@
4444
},
4545
".boolean": {
4646
"color": "rgb(188, 84, 84)"
47+
},
48+
".highlight": {
49+
"background": "hsla(0, 0%, 70%, .5)"
4750
}
4851
}

packages/prism/presets/night-owl.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,8 @@
5050
},
5151
".namespace": {
5252
"color": "rgb(178, 204, 214)"
53+
},
54+
".highlight": {
55+
"background": "hsla(0, 0%, 30%, .5)"
5356
}
5457
}

packages/prism/presets/oceanic-next.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,8 @@
5151
},
5252
".namespace": {
5353
"opacity": 0.7
54+
},
55+
".highlight": {
56+
"background": "hsla(0, 0%, 40%, .5)"
5457
}
5558
}

packages/prism/presets/prism-coy.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,8 @@
4444
},
4545
".tab:not(:empty):before,.cr:before,.lf:before": {
4646
"color": "#e0d7d1"
47+
},
48+
".highlight": {
49+
"background": "hsla(0, 0%, 70%, .5)"
4750
}
4851
}

packages/prism/presets/prism-dark.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@
3636
},
3737
".deleted": {
3838
"color": "red"
39+
},
40+
".highlight": {
41+
"background": "hsla(0, 0%, 70%, .5)"
3942
}
4043
}

0 commit comments

Comments
 (0)