0.4.14 • Published 1 year ago
fastrender v0.4.14
fastrender
Real-time Markdown and LaTeX rendering library using WebAssembly.
Features
- Fast Markdown rendering using WebAssembly
- LaTeX support via KaTeX
- Mixed content support (Markdown with inline and display LaTeX)
- Caching for improved performance
- TypeScript support
Installation
npm install fastrender
# or
yarn add fastrender
# or
bun add fastrenderUsage
import fastrender from 'fastrender';
// Create an instance
const fastrender = new fastrender({
debug: false,
katexOptions: {
throwOnError: false
}
});
// Render Markdown
const markdown = await fastrender.renderMarkdown(`
# Hello World
This is **bold** text.
`);
// Render LaTeX
const latex = fastrender.renderLatex('\\frac{1}{2}');
// Render mixed content
const mixed = await fastrender.renderMixed(`
# Math Example
Here's an inline equation: $E = mc^2$
And a display equation:
$$
\\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}
$$
`);API
new fastrender(options?)
Creates a new fastrender instance.
Options:
debug?: boolean- Enable debug modekatexOptions?: KatexOptions- KaTeX rendering options
renderMarkdown(content: string): Promise<string>
Renders Markdown content to HTML.
renderLatex(content: string, displayMode?: boolean): string
Renders LaTeX content to HTML.
renderMixed(content: string): Promise<string>
Renders mixed Markdown and LaTeX content to HTML.
clearCache(): void
Clears the internal render cache.
Examples
Pure Markdown
const markdown = await fastrender.renderMarkdown(`
# Hello World
This is a **bold** statement.
`);Pure LaTeX
const latex = fastrender.renderLatex('\\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}', true);Mixed Content
const mixed = await fastrender.renderMixed(`
# Math and Text Combined
Here's the quadratic formula: $ax^2 + bx + c = 0$
The solution is:
$$x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}$$
And here's Einstein's famous equation: $E = mc^2$
`);Development
# Install dependencies
bun install
# Run development server
bun run dev
# Run tests
bun run test
# Run benchmarks
bun run benchmarkLicense
MIT
0.4.9
1 year ago
0.4.8
1 year ago
0.3.9
1 year ago
0.4.10
1 year ago
0.4.13
1 year ago
0.4.14
1 year ago
0.4.11
1 year ago
0.4.12
1 year ago
0.3.0
1 year ago
0.2.1
1 year ago
0.4.5
1 year ago
0.3.6
1 year ago
0.2.7
1 year ago
0.1.8
1 year ago
0.4.4
1 year ago
0.3.5
1 year ago
0.2.6
1 year ago
0.1.7
1 year ago
0.4.7
1 year ago
0.3.8
1 year ago
0.2.9
1 year ago
0.4.6
1 year ago
0.3.7
1 year ago
0.2.8
1 year ago
0.1.9
1 year ago
0.4.1
1 year ago
0.3.2
1 year ago
0.2.3
1 year ago
0.1.4
1 year ago
0.3.1
1 year ago
0.2.2
1 year ago
0.4.3
1 year ago
0.3.4
1 year ago
0.2.5
1 year ago
0.1.6
1 year ago
0.4.2
1 year ago
0.3.3
1 year ago
0.2.4
1 year ago
0.1.5
1 year ago
0.1.3
1 year ago
0.1.2
1 year ago
0.1.1
1 year ago
0.1.0
1 year ago