A comprehensive library for parsing HTML and converting markdown to HTML in Node.js, with added functionalities for fetching web content, sanitizing it, and extracting text.
- Fetch and parse HTML from a URL
- Sanitize HTML content to prevent XSS attacks
- Convert markdown to HTML with customizable options
- Extract plain text from HTML content
Install serene-leaf-parser using npm:
npm install serene-leaf-parser
const { fetchAndParseHTML } = require('serene-leaf-parser');
async function demoFetch () {
const html = await fetchAndParseHTML('https://example.com');
console.log(html);
}
demoFetch();
const { parseHTML } = require('serene-leaf-parser');
// Assume `html` contains the HTML string to be sanitized and parsed
const sanitizedHtml = parseHTML(html);
console.log(sanitizedHtml);
const { markdownToHTML } = require('serene-leaf-parser');
const html = markdownToHTML('# Hello World');
console.log(html);
const { extractTextFromHTML } = require('serene-leaf-parser');
// Assume `html` contains the HTML string
const text = extractTextFromHTML(html);
console.log(text);
Contributions, issues, and feature requests are welcome!
MIT