Example #1
0
  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)"
          )
        ])
      ])
    );
  });
Example #2
0
  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"
          )
        ])
      ])
    );
  });
Example #3
0
  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")]));
  });
Example #4
0
  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")]));
  });
Example #5
0
  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\\$")]));
  });
Example #6
0
  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`")])])
    );
  });
Example #7
0
  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$")])])
    );
  });
Example #8
0
  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$")])])
    );
  });
Example #9
0
  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")])])
    );
  });
Example #10
0
  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")])])
    );
  });