Get started with mammoth CDN

BSD-2-Clause licensed

Mammoth: library for converting Office docs to HTML, Markdown, PDF.

Tags:
  • docx
  • html
  • office
  • word
  • markdown
  • md

Stable version

Copied!

How to start using mammoth CDN


// Import Mammoth library
const loadMammoth = () => new Promise((resolve) => {
  const script = document.createElement('script');
  script.src = 'https://cdn.cdnhub.io/mammoth/1.7.0/mammoth.browser.min.js';
  script.onload = () => {
    resolve(Mammoth.getSlate);
  };
  document.head.appendChild(script);
});

// Function to convert Markdown to HTML
async function markdownToHtml(markdown) {
  const converter = await loadMammoth();
  const doc = converter.convertMarkdownToHTML(markdown);
  return doc.documentElement.outerHTML;
}

// Usage
const markdown = `
# Heading
**Bold text**
_Italic text_
> Blockquote

Copied!
Copied!

All versions