#!/usr/bin/env node /** * Basic HTML rendering example * * This example demonstrates how to use cli-html as a library * to render HTML content in the terminal. */ import { renderHTML } from '../../index.js'; // Example 1: Simple HTML with headings and paragraphs console.log('=== Example 1: Basic HTML ===\n'); const basicHTML = `
This is a powerful library for rendering HTML in the terminal.
It supports italic, bold, inline code, and much more!
function greet(name) {
console.log(\`Hello, \${name}!\`);
return true;
}
greet('World');
def factorial(n):
if n <= 1:
return 1
return n * factorial(n - 1)
print(factorial(5))
`;
console.log(renderHTML(codeHTML));
// Example 4: Tables
console.log('\n=== Example 4: Tables ===\n');
const tableHTML = `
| Name | Role | |
|---|---|---|
| John Doe | john@example.com | Admin |
| Jane Smith | jane@example.com | User |
| Bob Johnson | bob@example.com | Moderator |
`; console.log(renderHTML(blockquoteHTML)); // Example 6: Links console.log('\n=== Example 6: Links ===\n'); const linksHTML = `"The only way to do great work is to love what you do."
— Steve Jobs
This paragraph demonstrates red text, blue bold text, and green italic text.
This is a yellow blockquote with custom marker.
Text styles: red bold, blue italic, bright yellow mark
`; console.log(renderHTML(customStylesHTML));