File tree 3 files changed +46
-3
lines changed
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'
3
3
4
4
type DirectiveAttributes = Record < string , string >
5
5
6
+ /* eslint-disable @typescript-eslint/consistent-type-definitions */
7
+
6
8
interface DirectiveFields {
7
9
name : string
8
10
attributes ?: DirectiveAttributes
@@ -33,3 +35,5 @@ declare module 'mdast' {
33
35
leafDirective : LeafDirective
34
36
}
35
37
}
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) {
154
154
const list = /** @type {Array.<[string, string]> } */ (
155
155
this . getData ( 'directiveAttributes' )
156
156
)
157
- list . push ( [ 'id' , parseEntities ( this . sliceSerialize ( token ) ) ] )
157
+ list . push ( [
158
+ 'id' ,
159
+ parseEntities ( this . sliceSerialize ( token ) , {
160
+ attribute : true
161
+ } )
162
+ ] )
158
163
}
159
164
160
165
/** @type {FromMarkdownHandle } */
161
166
function exitAttributeClassValue ( token ) {
162
167
const list = /** @type {Array.<[string, string]> } */ (
163
168
this . getData ( 'directiveAttributes' )
164
169
)
165
- list . push ( [ 'class' , parseEntities ( this . sliceSerialize ( token ) ) ] )
170
+ list . push ( [
171
+ 'class' ,
172
+ parseEntities ( this . sliceSerialize ( token ) , {
173
+ attribute : true
174
+ } )
175
+ ] )
166
176
}
167
177
168
178
/** @type {FromMarkdownHandle } */
169
179
function exitAttributeValue ( token ) {
170
180
const list = /** @type {Array.<[string, string]> } */ (
171
181
this . getData ( 'directiveAttributes' )
172
182
)
173
- list [ list . length - 1 ] [ 1 ] = parseEntities ( this . sliceSerialize ( token ) )
183
+ list [ list . length - 1 ] [ 1 ] = parseEntities ( this . sliceSerialize ( token ) , {
184
+ attribute : true
185
+ } )
174
186
}
175
187
176
188
/** @type {FromMarkdownHandle } */
Original file line number Diff line number Diff line change @@ -197,6 +197,33 @@ test('markdown -> mdast', (t) => {
197
197
'should support attributes'
198
198
)
199
199
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
+
200
227
t . deepEqual (
201
228
removePosition (
202
229
fromMarkdown ( ':a{b\nc="d\ne"}' , {
You can’t perform that action at this time.
0 commit comments