tessl install tessl/npm-marked@17.0.0A markdown parser built for speed
Optimize Marked for your use case.
import { marked } from "marked";
const cache = new Map();
function cachedParse(markdown) {
if (cache.has(markdown)) {
return cache.get(markdown);
}
const html = marked.parse(markdown);
cache.set(markdown, html);
return html;
}import { marked } from "marked";
const parser = new marked.Parser();
const renderer = new marked.Renderer();
parser.renderer = renderer;
// Parse multiple documents
const htmls = documents.map(doc => {
const tokens = marked.lexer(doc);
return parser.parse(tokens);
});// Only use async when needed
marked.setOptions({ async: false }); // Fasterconsole.time('parse-with-extension');
const html = marked.parse(markdown);
console.timeEnd('parse-with-extension');