• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

marekdedic / prosemirror-remark / 14286002573

05 Apr 2025 09:34PM UTC coverage: 73.113% (-8.5%) from 81.604%
14286002573

Pull #509

github

marekdedic
Migrated syntax extension tests to vitest
Pull Request #509: Switched to vitest

54 of 125 branches covered (43.2%)

310 of 424 relevant lines covered (73.11%)

14.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/src/syntax-extensions/InlineCodeExtension.ts
1
import type { InlineCode, Text } from "mdast";
2
import type { InputRule } from "prosemirror-inputrules";
3
import type {
4
  DOMOutputSpec,
5
  MarkSpec,
6
  Node as ProseMirrorNode,
7
  Schema,
8
} from "prosemirror-model";
9
import type { Command } from "prosemirror-state";
10

11
import { toggleMark } from "prosemirror-commands";
4✔
12
import { MarkExtension, MarkInputRule } from "prosemirror-unified";
4✔
13

14
/**
15
 * @public
16
 */
17
export class InlineCodeExtension extends MarkExtension<InlineCode> {
4✔
18
  public override processConvertedUnistNode(convertedNode: Text): InlineCode {
19
    return { type: this.unistNodeName(), value: convertedNode.value };
4✔
20
  }
21

22
  public override proseMirrorInputRules(
23
    proseMirrorSchema: Schema<string, string>,
24
  ): Array<InputRule> {
25
    return [
8✔
26
      new MarkInputRule(
27
        /`([^\s](?:.*[^\s])?)`([\s\S])$/u,
28
        proseMirrorSchema.marks[this.proseMirrorMarkName()],
29
      ),
30
    ];
31
  }
32

33
  public override proseMirrorKeymap(
34
    proseMirrorSchema: Schema<string, string>,
35
  ): Record<string, Command> {
36
    const markType = proseMirrorSchema.marks[this.proseMirrorMarkName()];
8✔
37
    return {
8✔
38
      "Ctrl-`": toggleMark(markType),
39
    };
40
  }
41

42
  public override proseMirrorMarkName(): string {
43
    return "code";
50✔
44
  }
45

46
  public override proseMirrorMarkSpec(): MarkSpec {
47
    return {
8✔
48
      inclusive: false,
49
      parseDOM: [{ tag: "code" }],
50
      toDOM(): DOMOutputSpec {
51
        return ["code", 0];
×
52
      },
53
    };
54
  }
55

56
  public override unistNodeName(): "inlineCode" {
57
    return "inlineCode";
24✔
58
  }
59

60
  public override unistNodeToProseMirrorNodes(
61
    node: InlineCode,
62
    proseMirrorSchema: Schema<string, string>,
63
  ): Array<ProseMirrorNode> {
64
    return [
4✔
65
      proseMirrorSchema
66
        .text(node.value)
67
        .mark([proseMirrorSchema.marks[this.proseMirrorMarkName()].create()]),
68
    ];
69
  }
70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc