Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adjust math delimiter to fix markdown import/export compatibility issue #6727

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions shared/editor/nodes/Math.ts
Expand Up @@ -69,9 +69,9 @@ export default class Math extends Node {
}

toMarkdown(state: MarkdownSerializerState, node: ProsemirrorNode) {
state.write("$$");
state.write("$");
state.text(node.textContent, false);
state.write("$$");
state.write("$");
}

parseMarkdown() {
Expand Down
4 changes: 2 additions & 2 deletions shared/editor/nodes/MathBlock.ts
Expand Up @@ -41,10 +41,10 @@ export default class MathBlock extends Node {
}

toMarkdown(state: MarkdownSerializerState, node: ProsemirrorNode) {
state.write("$$$\n");
state.write("$$\n");
state.text(node.textContent, false);
state.ensureNewLine();
state.write("$$$");
state.write("$$");
state.closeBlock(node);
}

Expand Down
6 changes: 3 additions & 3 deletions shared/editor/rules/math.ts
Expand Up @@ -6,8 +6,8 @@ export const REGEX_INLINE_MATH_DOLLARS = /\$\$(.+)\$\$/;

export const REGEX_BLOCK_MATH_DOLLARS = /\$\$\$\s+$/;

const inlineMathDelimiter = "$$";
const blockMathDelimiter = "$$$";
const inlineMathDelimiter = "$";
const blockMathDelimiter = "$$";

// test if potential opening or closing delimiter
// assumes that there is a "$" at state.src[pos]
Expand Down Expand Up @@ -85,7 +85,7 @@ function mathInline(state: StateInline, silent: boolean): boolean {
return true;
}

// check if we have empty content (ex. $$$$) do not parse
// check if we have empty content (ex. $$) do not parse
if (match - start === 0) {
if (!silent) {
state.pending += inlineMathDelimiter + inlineMathDelimiter;
Expand Down