@desmodder/text-mode-core
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Text Mode Core

This module is currently still quite entangled with DesModder, so the API is terrible and very much subject to change.

Here's what you probably want to use for now, assuming a global Desmos API instance Desmos and calculator Calc:

import {
  buildConfigFromGlobals,
  textToRaw,
  rawToText,
} from "@desmodder/text-mode-core";

const cfg = buildConfigFromGlobals(Desmos, Calc);

console.log(textToRaw(cfg, "y = sin(x)"));

console.log(rawToText(cfg, Calc.getState()));

If you don't have access to those, then text-mode-core can assume good defaults for most options found in the config. However, it does not have its own LaTeX parser, so you cannot convert from raw graph states to other formats.

import { buildConfig, textToRaw, rawToText } from "@desmodder/text-mode-core";

const cfg = buildConfig({});

console.log(textToRaw(cfg, "y = sin(x)"));

// WARNING: This will error because parseDesmosLatex is not defined.
// There's try-catches, so it will give a (useless) object.
rawToText(cfg, {
  version: 10,
  expressions: {
    list: [
      {
        type: "expression",
        id: "1",
        color: "#c74440",
        latex: "y=\\sin\\left(x\\right)",
      },
    ],
  },
});

Readme

Keywords

Package Sidebar

Install

npm i @desmodder/text-mode-core

Weekly Downloads

5

Version

0.1.1

License

MIT

Unpacked Size

236 kB

Total Files

4

Last publish

Collaborators

  • jared-hughes