Skip to content

Commit fa89fde

Browse files
committed
Refactor code-style
1 parent 9618771 commit fa89fde

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

index.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type {
2-
Data,
3-
Parent,
42
BlockContent,
3+
Data,
54
DefinitionContent,
5+
Parent,
66
PhrasingContent
77
} from 'mdast'
88

@@ -13,20 +13,20 @@ export {directiveFromMarkdown, directiveToMarkdown} from './lib/index.js'
1313
*/
1414
interface DirectiveFields {
1515
/**
16-
* Directive name.
16+
* Directive attributes.
1717
*/
18-
name: string
18+
attributes?: Record<string, string | null | undefined> | null | undefined
1919

2020
/**
21-
* Directive attributes.
21+
* Directive name.
2222
*/
23-
attributes?: Record<string, string | null | undefined> | null | undefined
23+
name: string
2424
}
2525

2626
/**
2727
* Markdown directive (container form).
2828
*/
29-
export interface ContainerDirective extends Parent, DirectiveFields {
29+
export interface ContainerDirective extends DirectiveFields, Parent {
3030
/**
3131
* Node type of container directive.
3232
*/
@@ -76,7 +76,7 @@ export interface LeafDirectiveData extends Data {}
7676
/**
7777
* Markdown directive (text form).
7878
*/
79-
export interface TextDirective extends Parent, DirectiveFields {
79+
export interface TextDirective extends DirectiveFields, Parent {
8080
/**
8181
* Node type of text directive.
8282
*/

lib/index.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ export function directiveFromMarkdown() {
8787
*/
8888
export function directiveToMarkdown() {
8989
return {
90+
handlers: {
91+
containerDirective: handleDirective,
92+
leafDirective: handleDirective,
93+
textDirective: handleDirective
94+
},
9095
unsafe: [
9196
{
9297
character: '\r',
@@ -103,12 +108,7 @@ export function directiveToMarkdown() {
103108
inConstruct: ['phrasing']
104109
},
105110
{atBreak: true, character: ':', after: ':'}
106-
],
107-
handlers: {
108-
containerDirective: handleDirective,
109-
leafDirective: handleDirective,
110-
textDirective: handleDirective
111-
}
111+
]
112112
}
113113
}
114114

@@ -196,9 +196,7 @@ function exitAttributeIdValue(token) {
196196
assert(list, 'expected `directiveAttributes`')
197197
list.push([
198198
'id',
199-
parseEntities(this.sliceSerialize(token), {
200-
attribute: true
201-
})
199+
parseEntities(this.sliceSerialize(token), {attribute: true})
202200
])
203201
}
204202

@@ -211,9 +209,7 @@ function exitAttributeClassValue(token) {
211209
assert(list, 'expected `directiveAttributes`')
212210
list.push([
213211
'class',
214-
parseEntities(this.sliceSerialize(token), {
215-
attribute: true
216-
})
212+
parseEntities(this.sliceSerialize(token), {attribute: true})
217213
])
218214
}
219215

0 commit comments

Comments
 (0)