MDX utilities for Mathsy applications
npm install mathsy-mdxbash
npm install mathsy-mdx
or
yarn add mathsy-mdx
`
Usage
`typescript
import { parseMdx, splitByEntity, MmdDocument } from 'mathsy-mdx';
// Parse a markdown document with frontmatter
const doc =
;
const parsedDoc: MmdDocument = parseMdx(doc);
console.log(parsedDoc.title); // "My Document"
console.log(parsedDoc.theme); // "dark"
console.log(parsedDoc.type); // "worksheet"
console.log(parsedDoc.content); // "Content goes here..."
// Split a document by entities
const multiDoc =
;
const entities = splitByEntity(multiDoc);
// ["content1", "content2"]
`
Available Types and Functions
- MmdDocument: Type definition for parsed markdown documents
- title: string - Document title
- theme: 'light' | 'dark' - Document theme
- content: string - Document content
- rawHeader: string - Raw frontmatter header
- type: 'generic' | 'worksheet' - Document type
- parseMdx(doc: string): MmdDocument - Parse a markdown document with frontmatter
- splitByEntity(doc: string): string[] - Split a document by entity markers
Development
1. Clone the repository
2. Install dependencies: yarn install
3. Build the package: yarn build`