mirror of
https://github.com/priyanshujain/margin-docs.git
synced 2026-10-03 03:27:05 +00:00
Let a code span carry the emphasis marks, so bold code opens at all
This commit is contained in:
1 parent
343b18ff57
commit
1b31e2f189
9 files changed
+131
-16
No files matched your search
@@ -240,10 +240,13 @@ describe("inline", () => {
|
||||
expect(link.toJSON()).toEqual({ type: "link", attrs: { href: "./a.md", title: "A" } });
|
||||
});
|
||||
|
||||
it("lets a code span sit inside a link but not inside emphasis", () => {
|
||||
it("lets a code span sit inside a link and inside emphasis", () => {
|
||||
const code = m.code.create();
|
||||
expect(code.isInSet(m.link.create({ href: "./a.md" }).addToSet([code]))).toBeTruthy();
|
||||
expect(m.strong.create().addToSet([code])).toEqual([code]);
|
||||
for (const outer of [m.strong, m.em, m.strikethrough]) {
|
||||
const set = outer.create().addToSet([code]);
|
||||
expect([outer.name, set.map((mark) => mark.type.name)]).toEqual([outer.name, [outer.name, "code"]]);
|
||||
}
|
||||
});
|
||||
|
||||
it("treats math and images as inline atoms", () => {
|
||||
|
||||
+8
-2
@@ -433,10 +433,16 @@ export const marks: { [name in MarkName]: MarkSpec } = {
|
||||
toDOM: () => ["s", 0],
|
||||
},
|
||||
|
||||
// A code span is literal, so it excludes the emphasis marks, but not link: [`x`](y) is valid.
|
||||
// A code span's own content is literal, so nothing can be emphasised inside one, but a code span
|
||||
// can itself be emphasised or linked: `**\`x\`**` and `[\`x\`](y)` are both ordinary markdown and
|
||||
// both render on GitHub. Marks are a flat set here, so those two readings are the same set and
|
||||
// the direction is decided once, by the serializer: src/markdown/serialize.ts puts code innermost
|
||||
// and writes the emphasis around it. Excluding the formatting group instead, which this mark did
|
||||
// until a document holding `**\`x\`**` could not be opened at all, is not a narrower rule but a
|
||||
// wrong one: the bridge kept building the set the file described and every such document failed
|
||||
// `doc.check()` on the way into the editor.
|
||||
code: {
|
||||
code: true,
|
||||
excludes: "formatting code",
|
||||
parseDOM: [{ tag: "code" }],
|
||||
toDOM: () => ["code", 0],
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user