Skip to content

Commit 0836d56

Browse files
committed
minor: Support "%" as comment marker
1 parent 4509098 commit 0836d56

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/katex-ex/__tests__/transform.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,34 @@ describe("parseMathTransform", () => {
3434
}
3535
`);
3636
});
37+
38+
it("comment", () => {
39+
expect(
40+
parseMathTransform(
41+
["x", "= x^2", "~ x^3", "% comment", "- x^4", " % comment2"].join(
42+
"\n",
43+
),
44+
),
45+
).toMatchInlineSnapshot(`
46+
{
47+
"first": "x",
48+
"steps": [
49+
{
50+
"formula": "x^2",
51+
"prefix": "= ",
52+
},
53+
{
54+
"formula": "x^3",
55+
"prefix": "\\sim ",
56+
},
57+
{
58+
"formula": "x^4",
59+
"prefix": "\\iff ",
60+
},
61+
],
62+
}
63+
`);
64+
});
3765
});
3866

3967
describe("makeMathTransform1Column", () => {

src/katex-ex/transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type MathTransform = {
1111
};
1212

1313
export const parseMathTransform = (v: string): MathTransform => {
14-
const lines = v.split("\n");
14+
const lines = v.split("\n").filter((e) => !e.match(/^\s*%/));
1515
const spaces = Math.min(
1616
...lines
1717
.filter((e) => !e.match(/^\s*$/))

0 commit comments

Comments
 (0)