@@ -223,29 +223,18 @@ canonical form that is closer to the user input.
223223** To get the non-canonical form** , use ` ce.box(expr, { canonical: false }) ` or
224224` ce.parse(s, { canonical: false }) ` .
225225
226- ``` js example
227- const expr = ce .parse (" 2(0+x\\ times x-1)" , {canonical: false });
228- console .log (expr .json );
229- // ➔ ["InvisibleOperator",
230- // 2,
231- // ["Delimiter",
232- // ["Sequence", ["Add", 0, ["Subtract", ["Multiply","x","x"],1]]]
233- // ]
234- // ]
226+ ``` live
227+ console.log(ce.parse("2(0+x\\times x-1)", {canonical: false}).json);
235228```
236229
237230** To get the full canonical form** , use ` ce.box(expr, { canonical: true }) ` or
238231` ce.parse(s, { canonical: true }) ` . The ` canonical ` option can be omitted
239232as it is ` true ` by default.
240233
241- ``` js example
242- const expr = ce .parse (" 2(0+x\\ times x-1)" ,
243- {canonical: true }
244- ).print ();
245- // ➔ ["Multiply", 2, ["Subtract", ["Square", "x"], 1]]
234+ ``` live
235+ console.log(ce.parse("2(0+x\\times x-1)", {canonical: true}).json);
246236
247- const expr = ce .parse (" 2(0+x\\ times x-1)" ).print ();
248- // ➔ ["Multiply", 2, ["Subtract", ["Square", "x"], 1]]
237+ console.log(ce.parse("2(0+x\\times x-1)").json);
249238```
250239
251240** To get a custom canonical form of an expression** , use the
@@ -257,12 +246,10 @@ and `ce.parse()`.
257246
258247** To order the arguments in a canonical order** , use ` ce.box(expr, { canonical: "Order" }) ` or ` ce.parse(s, { canonical: "Order" }) ` .
259248
260- ``` js example
261- const expr = ce .parse (" 0+1+x+2+\\ sqrt{5}" ,
249+ ``` live
250+ ce.parse("0+1+x+2+\\sqrt{5}",
262251 {canonical: "Order"}
263- );
264- expr .print ();
265- // ➔ ["Add", ["Sqrt", 5], "x", 0, 1, 2]
252+ ).print();
266253```
267254
268255Note in particular that the ` 0 ` is preserved in the expression, which is not
@@ -274,17 +261,14 @@ expression. See the documentation of
274261
275262For example:
276263
277- ``` js example
278- const latex = " 2(0+x \\ times x-1 )" ;
264+ ``` live
265+ const latex = "3(2+x )";
279266ce.parse(latex, {canonical: false}).print();
280- // -> ["InvisibleOperator",2,["Delimiter",["Sequence",["Add",0,["Subtract",["Multiply","x","x"],1]]]]]
281267
282268ce.parse(latex, {canonical: ["InvisibleOperator"]}).print();
283- // -> ["Multiply",2,["Add",0,["Subtract",["Multiply","x","x"],1]]]
284269
285270ce.parse(latex,
286271 {canonical: ["InvisibleOperator", "Add", "Order", ]}
287- );
288- // -> ["Multiply",2,["Subtract",["Multiply","x","x"],1]]
272+ ).print();
289273```
290274
0 commit comments