Skip to content

Commit

Permalink
Merge branch 'main' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
aarkue committed Aug 8, 2024
2 parents 9a620ef + b1cb440 commit e5f5449
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/tiptap-math-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "aarkue",
"homepage": "https://github.com/aarkue/tiptap-math-extension",
"license": "MIT",
"version": "1.3.3-beta.6",
"version": "1.3.3",
"description": "Math/LaTeX Extension for the TipTap Editor ",
"main": "dist/index.cjs.js",
"module": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/tiptap-math-extension/src/inline-math-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export const InlineMathNode = Node.create<MathExtensionOptions>({
export function getRegexFromOptions(mode: "inline" | "block", options: MathExtensionOption): string | undefined {
if (options.delimiters === undefined || options.delimiters === "dollar") {
if (mode === "inline") {
return String.raw`(?<!\$)\$(?![$\s,.])((?:[^$\\]|\\\$|\\)+?(?<![\\\s([]))\$`;
return String.raw`(?<!\$)\$(?![$\s,.])((?:[^$\\]|\\\$|\\)+?(?<![\\\s(["]))\$`;
} else {
return String.raw`\$\$(?!\s)(.*?(?<!\\))\$\$`;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/tiptap-math-extension/src/tests/regex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ test("Inline Dollar Math Regex", () => {
expect(r.exec(raw`I have $120 ($\$40$ from my allowance and $\$80$ from the card Grandma sent me on my birthday).`)[1]).toStrictEqual(raw`\$40`);
expect(r.exec(raw`I have $120 ($40 from my allowance and $\$80$ from the card Grandma sent me on my birthday).`)[1]).toStrictEqual(raw`\$80`);

expect(r.exec(raw`I gave Cynthia $5.00 and she said, "$5.00? That's really all you're good for?"`)).toStrictEqual(null);
expect(r.exec('${"x"}$')[1]).toStrictEqual('{"x"}');

// Tests with global regex (e.g., relevant for pasting)
const rg = new RegExp(getRegexFromOptions("inline", options), "g");
expect([...raw`I have $\$120$ ($40$ from my allowance and $80$ from the card Grandma sent me on my birthday).`.match(rg)]).toStrictEqual([raw`$\$120$`,raw`$40$`,raw`$80$`]);
Expand Down

0 comments on commit e5f5449

Please sign in to comment.