File tree Expand file tree Collapse file tree 3 files changed +46
-3
lines changed Expand file tree Collapse file tree 3 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import type {PhrasingContent, BlockContent} from 'mdast'
33
44type DirectiveAttributes = Record < string , string >
55
6+ /* eslint-disable @typescript-eslint/consistent-type-definitions */
7+
68interface DirectiveFields {
79 name : string
810 attributes ?: DirectiveAttributes
@@ -33,3 +35,5 @@ declare module 'mdast' {
3335 leafDirective : LeafDirective
3436 }
3537}
38+
39+ /* eslint-enable @typescript-eslint/consistent-type-definitions */
Original file line number Diff line number Diff line change @@ -154,23 +154,35 @@ function exitAttributeIdValue(token) {
154154 const list = /** @type {Array.<[string, string]> } */ (
155155 this . getData ( 'directiveAttributes' )
156156 )
157- list . push ( [ 'id' , parseEntities ( this . sliceSerialize ( token ) ) ] )
157+ list . push ( [
158+ 'id' ,
159+ parseEntities ( this . sliceSerialize ( token ) , {
160+ attribute : true
161+ } )
162+ ] )
158163}
159164
160165/** @type {FromMarkdownHandle } */
161166function exitAttributeClassValue ( token ) {
162167 const list = /** @type {Array.<[string, string]> } */ (
163168 this . getData ( 'directiveAttributes' )
164169 )
165- list . push ( [ 'class' , parseEntities ( this . sliceSerialize ( token ) ) ] )
170+ list . push ( [
171+ 'class' ,
172+ parseEntities ( this . sliceSerialize ( token ) , {
173+ attribute : true
174+ } )
175+ ] )
166176}
167177
168178/** @type {FromMarkdownHandle } */
169179function exitAttributeValue ( token ) {
170180 const list = /** @type {Array.<[string, string]> } */ (
171181 this . getData ( 'directiveAttributes' )
172182 )
173- list [ list . length - 1 ] [ 1 ] = parseEntities ( this . sliceSerialize ( token ) )
183+ list [ list . length - 1 ] [ 1 ] = parseEntities ( this . sliceSerialize ( token ) , {
184+ attribute : true
185+ } )
174186}
175187
176188/** @type {FromMarkdownHandle } */
Original file line number Diff line number Diff line change @@ -197,6 +197,33 @@ test('markdown -> mdast', (t) => {
197197 'should support attributes'
198198 )
199199
200+ t . deepEqual (
201+ removePosition (
202+ fromMarkdown ( ':a{b=¶m c="¶m" d=\'¶m\'}' , {
203+ extensions : [ directive ( ) ] ,
204+ mdastExtensions : [ directiveFromMarkdown ]
205+ } ) ,
206+ true
207+ ) ,
208+ {
209+ type : 'root' ,
210+ children : [
211+ {
212+ type : 'paragraph' ,
213+ children : [
214+ {
215+ type : 'textDirective' ,
216+ name : 'a' ,
217+ attributes : { b : '¶m' , c : '¶m' , d : '¶m' } ,
218+ children : [ ]
219+ }
220+ ]
221+ }
222+ ]
223+ } ,
224+ 'should not support non-terminated character references'
225+ )
226+
200227 t . deepEqual (
201228 removePosition (
202229 fromMarkdown ( ':a{b\nc="d\ne"}' , {
You can’t perform that action at this time.
0 commit comments