File tree 5 files changed +145
-2
lines changed
5 files changed +145
-2
lines changed Original file line number Diff line number Diff line change @@ -154,4 +154,64 @@ body mark {
154
154
background-color: #058ecd;
155
155
color: #fff;
156
156
}
157
+ .hljs {
158
+ display: block;
159
+ overflow-x: auto;
160
+ padding: 0.5em;
161
+ background: #272822;
162
+ color: #ddd
163
+ }
164
+ .hljs-tag,
165
+ .hljs-keyword,
166
+ .hljs-selector-tag,
167
+ .hljs-literal,
168
+ .hljs-strong,
169
+ .hljs-name {
170
+ color: #f92672
171
+ }
172
+ .hljs-code {
173
+ color: #66d9ef
174
+ }
175
+ .hljs-class .hljs-title {
176
+ color: white
177
+ }
178
+ .hljs-attribute,
179
+ .hljs-symbol,
180
+ .hljs-regexp,
181
+ .hljs-link {
182
+ color: #bf79db
183
+ }
184
+ .hljs-string,
185
+ .hljs-bullet,
186
+ .hljs-subst,
187
+ .hljs-title,
188
+ .hljs-section,
189
+ .hljs-emphasis,
190
+ .hljs-type,
191
+ .hljs-built_in,
192
+ .hljs-builtin-name,
193
+ .hljs-selector-attr,
194
+ .hljs-selector-pseudo,
195
+ .hljs-addition,
196
+ .hljs-variable,
197
+ .hljs-template-tag,
198
+ .hljs-template-variable {
199
+ color: #a6e22e
200
+ }
201
+ .hljs-comment,
202
+ .hljs-quote,
203
+ .hljs-deletion,
204
+ .hljs-meta {
205
+ color: #75715e
206
+ }
207
+ .hljs-keyword,
208
+ .hljs-selector-tag,
209
+ .hljs-literal,
210
+ .hljs-doctag,
211
+ .hljs-title,
212
+ .hljs-section,
213
+ .hljs-type,
214
+ .hljs-selector-id {
215
+ font-weight: bold
216
+ }
157
217
`
Original file line number Diff line number Diff line change 66
66
"dependencies" : {
67
67
"app-root-path" : " ^2.0.1" ,
68
68
"electron-is-dev" : " ^0.1.2" ,
69
+ "highlight.js" : " ^9.11.0" ,
69
70
"next" : " ^3.0.0-beta5" ,
70
71
"prop-types" : " ^15.5.10" ,
71
72
"pulse-editor" : " ^1.0.0" ,
Original file line number Diff line number Diff line change @@ -3,9 +3,17 @@ import { Base } from 'pulse-editor/buttons'
3
3
import { ipcRenderer } from 'electron'
4
4
import { string , func } from 'prop-types'
5
5
import Icon from 'react-icons/lib/fa/file-code-o'
6
+ import highlight from 'highlight.js'
6
7
import createParser from '@platzi/markdown'
7
8
8
- const parser = createParser ( )
9
+ const parser = createParser ( {
10
+ highlight ( code , lang ) {
11
+ if ( lang && highlight . getLanguage ( lang ) ) {
12
+ return highlight . highlight ( lang , code ) . value ;
13
+ }
14
+ return highlight . highlightAuto ( code ) . value ;
15
+ }
16
+ } )
9
17
10
18
export default class NewButton extends Component {
11
19
static contextTypes = {
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
15
15
Heading ,
16
16
Youtube
17
17
} from 'pulse-editor/buttons'
18
+ import highlight from 'highlight.js'
18
19
19
20
import Save from '../components/save-button'
20
21
import Open from '../components/open-button'
@@ -157,7 +158,16 @@ export default class extends Component {
157
158
158
159
< div className = 'PulseEditor-content' >
159
160
< Field />
160
- < Preview />
161
+ < Preview
162
+ parser = { {
163
+ highlight ( code , lang ) {
164
+ if ( lang && highlight . getLanguage ( lang ) ) {
165
+ return highlight . highlight ( lang , code ) . value ;
166
+ }
167
+ return highlight . highlightAuto ( code ) . value ;
168
+ }
169
+ } }
170
+ />
161
171
</ div >
162
172
163
173
< EmojiBar />
@@ -459,6 +469,66 @@ export default class extends Component {
459
469
background-color: #058ecd;
460
470
color: #fff;
461
471
}
472
+ .hljs {
473
+ display: block;
474
+ overflow-x: auto;
475
+ padding: 0.5em;
476
+ background: #272822;
477
+ color: #ddd
478
+ }
479
+ .hljs-tag,
480
+ .hljs-keyword,
481
+ .hljs-selector-tag,
482
+ .hljs-literal,
483
+ .hljs-strong,
484
+ .hljs-name {
485
+ color: #f92672
486
+ }
487
+ .hljs-code {
488
+ color: #66d9ef
489
+ }
490
+ .hljs-class .hljs-title {
491
+ color: white
492
+ }
493
+ .hljs-attribute,
494
+ .hljs-symbol,
495
+ .hljs-regexp,
496
+ .hljs-link {
497
+ color: #bf79db
498
+ }
499
+ .hljs-string,
500
+ .hljs-bullet,
501
+ .hljs-subst,
502
+ .hljs-title,
503
+ .hljs-section,
504
+ .hljs-emphasis,
505
+ .hljs-type,
506
+ .hljs-built_in,
507
+ .hljs-builtin-name,
508
+ .hljs-selector-attr,
509
+ .hljs-selector-pseudo,
510
+ .hljs-addition,
511
+ .hljs-variable,
512
+ .hljs-template-tag,
513
+ .hljs-template-variable {
514
+ color: #a6e22e
515
+ }
516
+ .hljs-comment,
517
+ .hljs-quote,
518
+ .hljs-deletion,
519
+ .hljs-meta {
520
+ color: #75715e
521
+ }
522
+ .hljs-keyword,
523
+ .hljs-selector-tag,
524
+ .hljs-literal,
525
+ .hljs-doctag,
526
+ .hljs-title,
527
+ .hljs-section,
528
+ .hljs-type,
529
+ .hljs-selector-id {
530
+ font-weight: bold
531
+ }
462
532
` } </ style >
463
533
</ Editor >
464
534
)
Original file line number Diff line number Diff line change @@ -2659,6 +2659,10 @@ hawk@~3.1.3:
2659
2659
hoek "2.x.x"
2660
2660
sntp "1.x.x"
2661
2661
2662
+ highlight.js@^9.11.0 :
2663
+ version "9.11.0"
2664
+ resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.11.0.tgz#47f98c7399918700db2caf230ded12cec41a84ae"
2665
+
2662
2666
hmac-drbg@^1.0.0 :
2663
2667
version "1.0.1"
2664
2668
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
You can’t perform that action at this time.
0 commit comments