Overview of @khanacademy/perseus-core
main@khanacademy/perseus and @khanacademy/math-input.repository·main·Indexed 23 days ago
https://github.com/khan/perseusKhan Academy's exercise system framework for rendering, interacting with, and grading learner exercises. The ecosystem includes @khanacademy/kas for mathematical expression manipulation and evaluation, @khanacademy/kmath for geometric calculations and numeric utilities, @khanacademy/math-input for web-based expression editing, and @khanacademy/perseus-core for foundational utilities and types.
@khanacademy/perseus and @khanacademy/math-input.Perseus is a specialized Markdown to React/HTML renderer designed for educational content. It extends standard Markdown with two primary capabilities:
$y = mx + b$).Widgets are embedded into Markdown using a "snowman placeholder" syntax: [[☃ widget-type 1]], where each widget has a unique ID.
@khanacademy/perseus-utils is a container package providing shared utilities used across most of the Perseus ecosystem.
Important Constraint for Contributors/Integrators: This package is designed to be a low-level dependency and must not depend on any other Perseus packages to avoid circular dependencies and maintain a clean dependency graph.
@khanacademy/pure-markdown is a Node-compatible wrapper around @khanacademy/simple-markdown. It provides markdown-related functions implemented in pure JavaScript, extracted from perseus-markdown.jsx.
Important Usage Note: This package is designed to be used in standalone Node.js environments. To ensure compatibility and avoid dependency issues, do not import anything from Perseus when using this package.
@khanacademy/perseus is the primary package in the Perseus monorepo used to power Exercises and Articles at Khan Academy. It provides the core components required to render Perseus items in an application.@khanacademy/keypad package is a utility designed to resolve communication issues between the mobile MathInput keypad and the MathInput Mathquill input wrapper. It provides a context layer that enables these two components to interact correctly on mobile devices.@khanacademy/perseus-linter package provides a set of linting rules designed for Perseus JSON content. Much like ESLint is used for JavaScript, this linter helps content creators by identifying common pitfalls and errors within Perseus JSON structures, allowing editors to catch issues before they are published.The @khanacademy/math-input package is an expression editor for the web, used within the Perseus exercise framework. It is built using React, MathQuill, and Aphrodite.
Key features include:
@khanacademy/kas is a lightweight JavaScript Computer Algebra System (CAS) designed for parsing, evaluating, comparing, and transforming mathematical expressions and equations. It supports plain text math, LaTeX, or a combination of both.
// Example of parsing and printing
var expr = KAS.parse("3x \\frac{42}{42} sin^2y").expr;
expr.print();
// "3*x*42/42*sin(y)^(2)"The @khanacademy/perseus-editor package provides components specifically designed for editing Perseus content. Note that this package is not intended for rendering Perseus content on its own; it is tightly coupled to perseus-core.
For every core Perseus widget type, there is a corresponding editor component located in perseus-editor/widgets/.