Perseus

repository·main·Indexed 23 days ago

https://github.com/khan/perseus

Khan 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.

Tokens
51.4K
Snippets
63
Records
341
Agent score
76%

What's inside perseus

  1. What is Perseus?

    main

    Perseus is a specialized Markdown to React/HTML renderer designed for educational content. It extends standard Markdown with two primary capabilities:

    1. Beautiful Math Rendering: Seamlessly integrates with MathJax to display high-fidelity mathematical expressions using dollar sign delimiters (e.g., $y = mx + b$).
    2. Interactive Widgets: Renders custom React components called "widgets" that allow learners to interact with content (e.g., multiple-choice, graphing, numeric input) and provide answers.

    Widgets are embedded into Markdown using a "snowman placeholder" syntax: [[☃ widget-type 1]], where each widget has a unique ID.

  2. Overview of @khanacademy/perseus-utils

    main

    @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.

  3. Overview of @khanacademy/pure-markdown

    main

    @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.

  4. What is Perseus?

    main
    Perseus is Khan Academy's exercise system. It is designed to take problems in the Perseus format and provide the infrastructure to present them to learners, allow for interactive engagement, and grade the results of their work.
  5. Overview of @khanacademy/keypad

    main
    The @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.
  6. Overview of @khanacademy/perseus-linter

    main
    The @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.
  7. Overview of @khanacademy/math-input features

    main

    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:

    • Multiple keypad configurations: Supports various input types such as fractions, mixed numbers, and algebraic expressions.
    • Multi-page keypads: Includes swipeable page navigation for accessing more symbols.
    • Touch-optimized interactions: Supports touch-and-drag interactions similar to stock iOS and Android keypads.
    • Draggable cursor: Features a cursor with a detached handle for fine-grained control on touch devices.
    • Custom state transitions: Optimized editing experience to streamline expression entry.
  8. Use @khanacademy/kas for math expression manipulation

    main

    @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)"
  9. Understand the role of @khanacademy/perseus-editor

    main

    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/.