Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

1.8 KB
Raw Blame
import {
	MarkdownHeading,
	MarkdownBloquote,
	MarkdownList,
	MarkdownListItem,
	MarkdownBr,
	MarkdownCode,
	MarkdownCodeSpan,
	MarkdownTable,
	MarkdownHtml,
	MarkdownParagraph,
	MarkdownLink,
	MarkdownText,
	MarkdownDfn,
	MarkdownDel,
	MarkdownEm,
	MarkdownHr,
	MarkdownStrong,
	MarkdownImage,
	MarkdownSpace,
	MarkdownInlineKatex,
	MarkdownBlockKatex,
} from './components';

import { Lexer } from './marked.esm.js';
import Slugger from 'github-slugger';
import type { SvelteComponent } from 'svelte';

export type MarkdownOptions = {
	/**
	 * The base path to your application.
	 * This is required when the application does not run in root context to generate the links properly.
	 */
	baseUrl: `/${string}`;

	/**
	 * The slugger used to generate header IDs in marked.
	 *
	 * It is discouraged to set this option, because the slugger needs to be re-created when the source is changed.
	 */
	slugger: Slugger;
};

export function parse(src: string) {
	const lexer = new Lexer();
	return lexer.lex(src);
}

export type RendererType = string;

export type Renderers = Record<RendererType, typeof SvelteComponent>;

export const defaultRenderers = (): Renderers => ({
	heading: MarkdownHeading,
	blockquote: MarkdownBloquote,
	list: MarkdownList,
	list_item: MarkdownListItem,
	br: MarkdownBr,
	code: MarkdownCode,
	codespan: MarkdownCodeSpan,
	table: MarkdownTable,
	html: MarkdownHtml,
	paragraph: MarkdownParagraph,
	link: MarkdownLink,
	text: MarkdownText,
	def: MarkdownDfn,
	del: MarkdownDel,
	em: MarkdownEm,
	hr: MarkdownHr,
	strong: MarkdownStrong,
	image: MarkdownImage,
	space: MarkdownSpace,
	escape: MarkdownSpace,
	inlineKatex: MarkdownInlineKatex,
	blockKatex: MarkdownBlockKatex,
});

export const defaultOptions = (): MarkdownOptions => ({
	baseUrl: '/',
	slugger: new Slugger(),
});