libformat

Convert Markdown to sanitized HTML and ANSI-colored terminal output.

1|1|Updated Aug 7, 2025
One-click install
npx skills add https://github.com/copilot-ld/copilot-ld --skill libformat
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: libformat
Source: https://github.com/copilot-ld/copilot-ld/tree/main/packages/libformat
Command: npx skills add https://github.com/copilot-ld/copilot-ld --skill libformat

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides Markdown formatting utilities to render clean HTML and ANSI-colored terminal output from Markdown input, with safe sanitization for web display and easy integration into apps and CLIs.

Core Features & Use Cases

  • toHtml converts Markdown to sanitized HTML suitable for web apps.
  • toTerminal converts Markdown to ANSI-colored terminal output for CLIs.
  • Factories createHtmlFormatter and createTerminalFormatter enable dependency injection for testability and customization.

Quick Start

Import the libformat package and call toHtml on your Markdown to render sanitized HTML.

Frequently Asked Questions about libformat

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I render Markdown to sanitized HTML for a web app?

To render Markdown to sanitized HTML, use the toHtml utility to convert content while guarding against XSS. This ensures safe web UI rendering by applying HTML sanitization to block malicious scripts before display.

Can I convert Markdown to ANSI-colored terminal output for a CLI tool?

Yes, you can convert Markdown to ANSI-colored terminal output using the toTerminal utility. It formats common markdown features for CLI tools, applying terminal formatting to produce readable console output.

How does HTML sanitization work when formatting Markdown for web pages?

HTML sanitization works by stripping malicious scripts during the Markdown to HTML conversion. The toHtml formatter applies safe sanitization for web display, actively guarding against XSS vulnerabilities in the rendered output.

How do I inject a custom Markdown formatter for testing and customization?

You can inject a custom Markdown formatter using the createHtmlFormatter and createTerminalFormatter factories. These utilities enable dependency injection, allowing you to customize and test formatting logic without hardcoding dependencies.

What Markdown features are supported when rendering to terminal and HTML formats?

The formatters handle common markdown features while converting content to either sanitized HTML or ANSI-colored terminal output. They support standard syntax for web UI rendering, CLI tools, and agent response formatting.

Do I need external dependencies to use this Markdown formatting library?

No, you do not need external dependencies to use this Markdown formatting library. It operates with zero dependencies, exposing HtmlFormatter and TerminalFormatter utilities directly for safe rendering in web pages and terminal applications.