Skip to content

Commit b4f9ae0

Browse files
committed
fix(Code): set lowest priority for inline code mark
1 parent 395f97b commit b4f9ae0

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

src/extensions/markdown/Code/index.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,32 @@ export type CodeOptions = {
1717

1818
export const Code: ExtensionAuto<CodeOptions> = (builder, opts) => {
1919
builder
20-
.addMark(code, () => ({
21-
spec: {
22-
code: true,
23-
parseDOM: [{tag: 'code'}],
24-
toDOM() {
25-
return ['code'];
20+
.addMark(
21+
code,
22+
() => ({
23+
spec: {
24+
code: true,
25+
parseDOM: [{tag: 'code'}],
26+
toDOM() {
27+
return ['code'];
28+
},
2629
},
27-
},
28-
toYfm: {
29-
open(_state, _mark, parent, index) {
30-
return backticksFor(parent.child(index), -1);
30+
toYfm: {
31+
open(_state, _mark, parent, index) {
32+
return backticksFor(parent.child(index), -1);
33+
},
34+
close(_state, _mark, parent, index) {
35+
return backticksFor(parent.child(index - 1), 1);
36+
},
37+
escape: false,
3138
},
32-
close(_state, _mark, parent, index) {
33-
return backticksFor(parent.child(index - 1), 1);
39+
fromYfm: {
40+
tokenSpec: {name: code, type: 'mark', noCloseToken: true},
41+
tokenName: 'code_inline',
3442
},
35-
escape: false,
36-
},
37-
fromYfm: {
38-
tokenSpec: {name: code, type: 'mark', noCloseToken: true},
39-
tokenName: 'code_inline',
40-
},
41-
}))
43+
}),
44+
builder.Priority.Lowest,
45+
)
4246
.addAction(codeAction, ({schema}) => createToggleMarkAction(codeType(schema)));
4347

4448
if (opts?.codeKey) {

0 commit comments

Comments
 (0)