File tree 2 files changed +30
-1
lines changed
2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ module.exports = function front_matter_plugin(md, cb) {
115
115
token . hidden = true ;
116
116
token . markup = state . src . slice ( startLine , pos ) ;
117
117
token . block = true ;
118
- token . map = [ startLine , pos ] ;
118
+ token . map = [ startLine , nextLine + ( auto_closed ? 1 : 0 ) ] ;
119
119
token . meta = state . src . slice ( start_content , start - 1 ) ;
120
120
121
121
state . parentType = old_parent ;
Original file line number Diff line number Diff line change @@ -107,4 +107,33 @@ describe('Markdown It Front Matter', () => {
107
107
108
108
assert . equal ( foundFrontmatter , 'x: 1\n---' ) ;
109
109
} ) ;
110
+
111
+ it ( 'Should set correct map for front-matter token' , ( ) => {
112
+ {
113
+ const tokens = md . parse ( [
114
+ '----' ,
115
+ 'x: 1' ,
116
+ '---' ,
117
+ '# Head'
118
+ ] . join ( '\n' ) ) ;
119
+
120
+ assert . strictEqual ( tokens [ 0 ] . type , 'front_matter' ) ;
121
+ assert . deepStrictEqual ( tokens [ 0 ] . map , [ 0 , 4 ] ) ;
122
+ }
123
+ {
124
+ const tokens = md . parse ( [
125
+ '----' ,
126
+ 'title: Associative arrays' ,
127
+ 'people:' ,
128
+ ' name: John Smith' ,
129
+ ' age: 33' ,
130
+ 'morePeople: { name: Grace Jones, age: 21 }' ,
131
+ '---' ,
132
+ '# Head'
133
+ ] . join ( '\n' ) ) ;
134
+
135
+ assert . strictEqual ( tokens [ 0 ] . type , 'front_matter' ) ;
136
+ assert . deepStrictEqual ( tokens [ 0 ] . map , [ 0 , 8 ] ) ;
137
+ }
138
+ } ) ;
110
139
} ) ;
You can’t perform that action at this time.
0 commit comments