mathsy-mdx
v1.0.0
Published
MDX utilities for Mathsy applications
Readme
Mathsy MDX
MDX utilities for parsing and processing markdown documents in Mathsy applications.
Installation
npm install mathsy-mdx
# or
yarn add mathsy-mdxUsage
import { parseMdx, splitByEntity, MmdDocument } from 'mathsy-mdx';
// Parse a markdown document with frontmatter
const doc = `
---
title: My Document
theme: dark
type: worksheet
---
Content goes here...
`;
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 = `
~~~maths
content1
~~~
~~~physics
content2
~~~
`;
const entities = splitByEntity(multiDoc);
// ["content1", "content2"]Available Types and Functions
MmdDocument: Type definition for parsed markdown documentstitle: string- Document titletheme: 'light' | 'dark'- Document themecontent: string- Document contentrawHeader: string- Raw frontmatter headertype: 'generic' | 'worksheet'- Document type
parseMdx(doc: string): MmdDocument- Parse a markdown document with frontmattersplitByEntity(doc: string): string[]- Split a document by entity markers
Development
- Clone the repository
- Install dependencies:
yarn install - Build the package:
yarn build
License
MIT
