1
1
const fs = require ( 'fs' )
2
2
3
- module . exports = function codeFrame ( md , options = { } ) {
3
+ module . exports = function snippet ( md , options = { } ) {
4
4
const root = options . root || process . cwd ( )
5
- function parser ( state , startLine , endLine , silent ) {
5
+ function parser ( state , startLine , endLine , silent ) {
6
6
const CH = '<' . charCodeAt ( 0 )
7
7
const pos = state . bMarks [ startLine ] + state . tShift [ startLine ]
8
8
const max = state . eMarks [ startLine ]
@@ -28,9 +28,9 @@ module.exports = function codeFrame(md, options = {}) {
28
28
const content = fs . existsSync ( filename ) ? fs . readFileSync ( filename ) . toString ( ) : 'Not found: ' + filename
29
29
const meta = rawPath . replace ( filename , '' )
30
30
31
- state . line = startLine + 1 ;
31
+ state . line = startLine + 1
32
32
33
- token = state . push ( 'fence' , 'code' , 0 )
33
+ const token = state . push ( 'fence' , 'code' , 0 )
34
34
token . info = filename . split ( '.' ) . pop ( ) + meta
35
35
token . content = content
36
36
token . markup = '```'
@@ -39,5 +39,5 @@ module.exports = function codeFrame(md, options = {}) {
39
39
return true
40
40
}
41
41
42
- md . block . ruler . before ( 'fence' , 'code-frame ' , parser )
42
+ md . block . ruler . before ( 'fence' , 'snippet ' , parser )
43
43
}
0 commit comments