@elchika-inc/html-to-markdown
v0.1.0
Published
Convert HTML content to Markdown format
Maintainers
Readme
@elchika-inc/html-to-markdown
Convert HTML content to Markdown format using Cheerio.
Installation
npm install @elchika-inc/html-to-markdownUsage
import { HtmlToMarkdownConverter } from '@elchika-inc/html-to-markdown';
const html = '<h1>Hello World</h1><p>This is a <strong>paragraph</strong> with <em>formatting</em>.</p>';
// Basic conversion
const markdown = HtmlToMarkdownConverter.convert(html);
console.log(markdown);
// Output:
// # Hello World
//
// This is a **paragraph** with *formatting*.
// With title
const markdownWithTitle = HtmlToMarkdownConverter.convert(html, {
includeTitle: true,
title: 'My Document'
});Supported Elements
- Headings (h1-h6)
- Paragraphs (p)
- Links (a)
- Images (img)
- Lists (ul, ol)
- Blockquotes
- Code blocks and inline code
- Bold and italic text
- Line breaks and horizontal rules
API
HtmlToMarkdownConverter.convert(html, options?)
Convert HTML to Markdown.
Options:
includeTitle(boolean, default: false) - Include title at the beginningtitle(string) - Title to include ifincludeTitleis true
License
MIT
