visitor-pattern-usage

Customize HTML-to-Markdown conversion with visitor hooks for HTML node types.

836|66|Updated Feb 3, 2025
One-click install
npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill visitor-pattern-usage
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: visitor-pattern-usage
Source: https://github.com/kreuzberg-dev/html-to-markdown/tree/main/.codex/skills/visitor-pattern-usage
Command: npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill visitor-pattern-usage

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill allows developers to deeply customize the HTML-to-Markdown conversion process by intercepting and modifying the handling of specific HTML elements.

Core Features & Use Cases

  • Extensible Hooks: Define custom logic for over 60 HTML element types.
  • Flexible Control: Override default conversion, skip elements, or provide entirely custom Markdown output.
  • Use Case: Automatically add specific Markdown formatting to all <code> blocks based on their language attribute, or transform all <a> tags into reference-style Markdown links.

Quick Start

Implement the HtmlVisitor trait and pass an instance to the convert_with_visitor function.

Frequently Asked Questions about visitor-pattern-usage

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

FAQPage Schema
How do I customize HTML to Markdown conversion for specific elements like code blocks and links?

Customizing HTML to Markdown conversion uses a visitor pattern to intercept specific HTML node types. Developers define custom behaviors for elements like code blocks or links by implementing visitor logic, allowing them to override default conversion or provide entirely custom Markdown output.

What is the visitor pattern for HTML to Markdown conversion?

The visitor pattern for HTML to Markdown conversion provides extensible hooks that allow developers to define custom logic for over 60 HTML element types. It intercepts the conversion pipeline to modify the handling of specific HTML elements like headings, images, and lists.

Can I use asynchronous visitors when converting HTML to Markdown?

Asynchronous visitors are supported during HTML to Markdown conversion. The implementation accommodates both synchronous and asynchronous visitor patterns, allowing developers to handle I/O-bound operations or remote data fetching within their custom node handling logic.

How do I start implementing custom HTML to Markdown conversion?

To start customizing HTML to Markdown conversion, implement the `HtmlVisitor` trait and pass an instance to the `convert_with_visitor` function. This allows you to define specific behaviors for various HTML node types within the conversion pipeline.

Does the HTML to Markdown visitor pattern support skipping elements?

The HTML to Markdown visitor pattern supports skipping elements entirely. Developers can override default conversion, skip elements, or provide entirely custom Markdown output for any of the over 60 supported HTML element types.