Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-fences-unquote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@stackoverflow/stacks-editor": patch
---

Remove the blockquote from code fence lines when toggling a blockquote off in markdown mode
2 changes: 1 addition & 1 deletion src/commonmark/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export function matchLeadingBlockCharacters(text: string) {
// If text is not an ordered list block, check for other block types
if (!match) {
// TODO HACK assumes all non-ordered list block types are non-letter characters followed by a single space
match = /^[^a-zA-Z0-9]+\s{1}(?=[a-zA-Z0-9_*[!]|$)+/.exec(text)?.[0];
match = /^[^a-zA-Z0-9]+\s{1}(?=[a-zA-Z0-9_*[!`~]|$)+/.exec(text)?.[0];
}

return match || "";
Expand Down
17 changes: 17 additions & 0 deletions test/commonmark/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,18 @@ some text`;
"\nth"
);
});

it("multi line, selection spanning a fenced code block", () => {
const content = "> ```\n> Some code\n> ```";
const state = createState(content, 0, content.length);
const command = commands.setBlockTypeCommand(">");

expect(state).transactionSuccess(
command,
"```\nSome code\n```",
"```\nSome code\n```"
);
});
});

/* SWAP */
Expand Down Expand Up @@ -605,6 +617,11 @@ some text`;

expect(command).toBe("## ");
});

it("return blockquote leading characters before a code fence", () => {
expect(commands.matchLeadingBlockCharacters("> ```")).toBe("> ");
expect(commands.matchLeadingBlockCharacters("> ~~~")).toBe("> ");
});
});

describe("insertTagLinkCommand", () => {
Expand Down