it("must parse more complex math equations inline math", () => { const processor = remark().use(math); const targetText = "$p(\\theta_i \\thinspace | \\, \\{\\theta_{j \\neq i}\\}, D)$"; const ast = processor.parse(targetText); expect(ast).toEqual( u("root", [ u("paragraph", [ u( "inlineMath", { data: { hChildren: [ u( "text", "p(\\theta_i \\thinspace | \\, \\{\\theta_{j \\neq i}\\}, D)" ) ], hName: "span", hProperties: { className: "inlineMath" } } }, "p(\\theta_i \\thinspace | \\, \\{\\theta_{j \\neq i}\\}, D)" ) ]) ]) ); });
it("must not set inlineMathDouble class", () => { const processor = remark().use(math); const targetText = "$$\\alpha$$"; const ast = processor.parse(targetText); expect(ast).toEqual( u("root", [ u("paragraph", [ u( "math", { data: { hChildren: [u("text", "\\alpha")], hName: "div", hProperties: { className: "math" } } }, "\\alpha" ) ]) ]) ); });
it("must parse math block with indent", () => { const processor = remark().use(math); const targetText = [" $$$", " \\alpha", " $$$"].join("\n"); const ast = processor.parse(targetText); expect(ast).toMatchObject(u("root", [u("math", " \\alpha")])); });
it("must ignore everything just after opening/closing marker", () => { const processor = remark().use(math); const targetText = ["$$ must", "\\alpha", "$$ be ignored", ""].join("\n"); const ast = processor.parse(targetText); expect(ast).toMatchObject(u("root", [u("math", "\\alpha")])); });
it("must render super factorial to a math inline", () => { const processor = remark().use(math); const targetText = ["$$", "\\alpha\\$", "$$"].join("\n"); const ast = processor.parse(targetText); expect(ast).toMatchObject(u("root", [u("math", "\\alpha\\$")])); });
it("fooo must not parse allow inline to contain backticks", () => { const processor = remark().use(math); const targetText = "$`\\alpha`$"; const ast = processor.parse(targetText); expect(ast).toMatchObject( u("root", [u("paragraph", [u("inlineMath", "`\\alpha`")])]) ); });
it("must not parse a raw starting dollar", () => { const processor = remark().use(math); const targetText = "`$`\\alpha$"; const ast = processor.parse(targetText); expect(ast).toMatchObject( u("root", [u("paragraph", [u("inlineCode", "$"), u("text", "\\alpha$")])]) ); });
it("must escape all dollars with backslashes", () => { const processor = remark().use(math); const targetText = "\\$\\alpha\\$"; const ast = processor.parse(targetText); expect(ast).toMatchObject( u("root", [u("paragraph", [u("text", "$"), u("text", "\\alpha$")])]) ); });
it("must NOT escape a dollar with double backslashes", () => { const processor = remark().use(math); const targetText = "\\\\$\\alpha$"; const ast = processor.parse(targetText); expect(ast).toMatchObject( u("root", [u("paragraph", [u("text", "\\"), u("inlineMath", "\\alpha")])]) ); });
it("must parse inline math between double dollars", () => { const processor = remark().use(math); const targetText = "$$\\alpha$$"; const ast = processor.parse(targetText); expect(ast).toMatchObject( u("root", [u("paragraph", [u("math", "\\alpha")])]) ); });