#!/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 = `

Welcome to cli-html

This is a powerful library for rendering HTML in the terminal.

It supports italic, bold, inline code, and much more!

`; console.log(renderHTML(basicHTML)); // Example 2: Lists console.log('\n=== Example 2: Lists ===\n'); const listsHTML = `

Shopping List

Todo List

  1. Wake up
  2. Write code
  3. Deploy to production
`; console.log(renderHTML(listsHTML)); // Example 3: Code blocks with syntax highlighting console.log('\n=== Example 3: Code Blocks ===\n'); const codeHTML = `

JavaScript Example


function greet(name) {
  console.log(\`Hello, \${name}!\`);
  return true;
}

greet('World');

Python Example


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 = `

User Information

Name Email Role
John Doe john@example.com Admin
Jane Smith jane@example.com User
Bob Johnson bob@example.com Moderator
`; console.log(renderHTML(tableHTML)); // Example 5: Blockquotes console.log('\n=== Example 5: Blockquotes ===\n'); const blockquoteHTML = `

Quote of the Day

"The only way to do great work is to love what you do."

— Steve Jobs

`; console.log(renderHTML(blockquoteHTML)); // Example 6: Links console.log('\n=== Example 6: Links ===\n'); const linksHTML = `

Useful Resources

`; console.log(renderHTML(linksHTML)); // Example 7: Custom Inline Styles with data-cli-* attributes console.log('\n=== Example 7: Custom Inline Styles ===\n'); const customStylesHTML = `

Custom Colors and Styles

This paragraph demonstrates red text, blue bold text, and green italic text.

Magenta Bold Header with Triangle

Cyan Header with Dots

This is a yellow blockquote with custom marker.

Text styles: red bold, blue italic, bright yellow mark

`; console.log(renderHTML(customStylesHTML));