npm.io
1.0.4 • Published 2 years ago

serene-leaf-parser

Licence
MIT
Version
1.0.4
Deps
3
Size
4 kB
Vulns
2
Weekly
0

serene-leaf-parser

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.

Features

  • 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

Installation

Install serene-leaf-parser using npm:

npm install serene-leaf-parser

Usage

Fetch and Parse HTML from URL
const { fetchAndParseHTML } = require('serene-leaf-parser');

async function demoFetch () {
  const html = await fetchAndParseHTML('https://example.com');
  console.log(html);
}

demoFetch();
Sanitize and Parse HTML
const { parseHTML } = require('serene-leaf-parser');

// Assume `html` contains the HTML string to be sanitized and parsed
const sanitizedHtml = parseHTML(html);
console.log(sanitizedHtml);
Convert Markdown to HTML
const { markdownToHTML } = require('serene-leaf-parser');

const html = markdownToHTML('# Hello World');
console.log(html);
Extract Text from HTML
const { extractTextFromHTML } = require('serene-leaf-parser');

// Assume `html` contains the HTML string
const text = extractTextFromHTML(html);
console.log(text);

Contributing

Contributions, issues, and feature requests are welcome!

License

MIT

Keywords