### Setup Project Dependencies and Build
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/contributing.md
Clone the repository, navigate to the project directory, and run the setup task to install dependencies, build the Rust extension, and set up commit hooks.
```bash
git clone https://github.com/xberg-io/html-to-markdown.git
cd html-to-markdown
task setup # installs deps, builds Rust extension, wires commit hooks
```
--------------------------------
### VisitDefinitionListStart Go Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-go.md
Call this method to visit the start of a definition list (
).
```go
result := instance.VisitDefinitionListStart(NodeContext{})
```
--------------------------------
### C/C++ Quick Start Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/crates/html-to-markdown-rs-ffi/README.md
A basic C program demonstrating how to include the html_to_markdown.h header. Refer to the main repository for detailed usage examples.
```c
#include "html_to_markdown.h"
int main(void) {
// See https://github.com/xberg-io/html-to-markdown for usage examples.
return 0;
}
```
--------------------------------
### Clone Repository and Setup Environment
Source: https://github.com/xberg-io/html-to-markdown/blob/main/CONTRIBUTING.md
Clones the repository and sets up the development environment, including installing dependencies, building Rust components, and installing pre-commit hooks.
```bash
git clone https://github.com/xberg-io/html-to-markdown.git
cd html-to-markdown
task setup
```
--------------------------------
### WASM Usage Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/installation.md
Verify the WASM installation by initializing the module and converting HTML to Markdown. Call init() once.
```javascript
import init, { convert } from '@xberg-io/html-to-markdown-wasm';
await init(); // load and instantiate the .wasm file — call once
const result = convert('
Hello
');
console.log(result.content);
// # Hello
```
--------------------------------
### Manual Testing Setup and Execution for Node.js
Source: https://github.com/xberg-io/html-to-markdown/blob/main/test_apps/README.md
Commands to install Node.js dependencies and run smoke and comprehensive tests locally using pnpm.
```bash
cd tests/test_apps/node
pnpm install
pnpm test:smoke
pnpm test:comprehensive
```
--------------------------------
### C# Usage Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/installation.md
Verify the C# installation by converting a simple HTML string to Markdown. The package bundles native binaries.
```csharp
using HtmlToMarkdown;
var result = HtmlToMarkdownConverter.Convert("
Hello
");
Console.WriteLine(result.Content);
// # Hello
```
--------------------------------
### Install CLI with Homebrew
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/cli.md
Install the html-to-markdown CLI using Homebrew after trusting the tap.
```bash
brew trust xberg-io/tap
brew install xberg-io/tap/html-to-markdown
```
--------------------------------
### Manual Testing Setup and Execution for Ruby
Source: https://github.com/xberg-io/html-to-markdown/blob/main/test_apps/README.md
Commands to install Ruby dependencies and run smoke and comprehensive tests locally using Bundler and RSpec.
```bash
cd tests/test_apps/ruby
bundle install
bundle exec rspec smoke_test.rb
bundle exec rspec comprehensive_test.rb
```
--------------------------------
### Install CLI html-to-markdown
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/index.md
Use this command to install the command-line interface tool.
```cli
cargo install html-to-markdown-cli
```
--------------------------------
### Visit Definition List Start (PHP)
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-php.md
Handles the start of a definition list (
).
```php
$result = $instance->visitDefinitionListStart(new NodeContext());
```
--------------------------------
### Install CLI Tool (Homebrew)
Source: https://github.com/xberg-io/html-to-markdown/blob/main/readme_templates/root.md
Install the html-to-markdown CLI tool using Homebrew.
```sh
brew install xberg-io/tap/html-to-markdown
```
--------------------------------
### R Usage Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/installation.md
Verify the R installation by converting HTML to Markdown. Available for Linux, macOS, and Windows.
```r
library(htmltomarkdown)
result <- htmltomarkdown::convert("
Hello
")
cat(result$content)
# # Hello
```
--------------------------------
### Install and Run Bun Tests
Source: https://github.com/xberg-io/html-to-markdown/blob/main/test_apps/bun/README.md
Installs project dependencies and runs the smoke tests using Bun. Ensure Bun 1.2+ is installed.
```bash
bun install
bun test
```
--------------------------------
### Swift Usage Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/installation.md
Verify the Swift installation by converting HTML to Markdown. Requires Swift 6.0+ and targets macOS 13+/iOS 16+.
```swift
import HtmlToMarkdown
let result = try convert("
Hello
", nil)
print(result.content()?.toString() ?? "")
```
--------------------------------
### Python Hello World Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/tools/benchmark-harness/fixtures/real-world/wikipedia/medium_python.html
A basic 'Hello, World!' program in Python, demonstrating the print function and simple script execution. This is a common starting point for learning the language.
```python
print("Hello, World!")
```
--------------------------------
### Verify Go Installation
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/installation.md
Verify the Go installation by converting HTML to Markdown and printing the result.
```go
package main
import (
"fmt"
htmltomarkdown "github.com/xberg-io/html-to-markdown/packages/go/v3"
)
func main() {
result, err := htmltomarkdown.Convert("
Hello
", nil)
if err != nil {
panic(err)
}
fmt.Println(*result.Content)
// # Hello
}
```
--------------------------------
### Install @xberg-io/html-to-markdown-wasm
Source: https://github.com/xberg-io/html-to-markdown/blob/main/crates/html-to-markdown-wasm/README.md
Install the package using pnpm.
```bash
pnpm add @xberg-io/html-to-markdown-wasm
```
--------------------------------
### Install html-to-markdown for Gemini CLI
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/agent-skills.md
Install the html-to-markdown plugin using the Gemini CLI.
```text
gemini extensions install https://github.com/xberg-io/plugins
```
--------------------------------
### Install R html-to-markdown
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/index.md
Use this command to install the R package.
```r
install.packages("htmltomarkdown")
```
--------------------------------
### Install html-to-markdown for GitHub Copilot CLI
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/agent-skills.md
Use these commands to install the html-to-markdown plugin for GitHub Copilot CLI.
```text
copilot plugin marketplace add https://github.com/xberg-io/plugins
copilot plugin install html-to-markdown@xberg-io
```
--------------------------------
### Install HTML to Markdown (bun)
Source: https://github.com/xberg-io/html-to-markdown/blob/main/crates/html-to-markdown-node/README.md
Install the package using bun. Requires Node.js 18+ or Bun.
```bash
bun add @xberg-io/html-to-markdown
```
--------------------------------
### Install html-to-markdown for Codex CLI
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/agent-skills.md
Add the plugins repository and then search for and install the html-to-markdown plugin.
```text
/plugins add https://github.com/xberg-io/plugins
```
--------------------------------
### Visit Definition List Start
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-python.md
Use this method to visit the start of a definition list (
).
```python
result = instance.visit_definition_list_start(NodeContext())
```
--------------------------------
### Visit Definition List Start
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-dart.md
Use this method to visit the start of a definition list (
).
```dart
final result = instance.visitDefinitionListStart(NodeContext());
```
--------------------------------
### Install HTML to Markdown CLI Tool
Source: https://github.com/xberg-io/html-to-markdown/blob/main/README.md
Install the command-line interface for HTML to Markdown conversion using Cargo or Homebrew.
```sh
cargo install html-to-markdown-cli
```
```sh
brew install xberg-io/tap/html-to-markdown
```
--------------------------------
### Install and Test PHP Apps with Composer
Source: https://github.com/xberg-io/html-to-markdown/blob/main/test_apps/README.md
Install PHP dependencies using Composer and run PHPUnit tests.
```bash
cd tests/test_apps/php
composer install
composer test
```
--------------------------------
### Verify Python Installation
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/installation.md
Verify the html-to-markdown Python installation by converting a simple HTML string to Markdown.
```bash
python -c "from html_to_markdown import convert; print(convert('
Hello
').content)"
# # Hello
```
--------------------------------
### Get Default Conversion Options
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-swift.md
Retrieves the default configuration settings for HTML to Markdown conversion. This is useful for starting with a standard setup.
```swift
let result = ConversionOptions.default()
```
--------------------------------
### Get Default Conversion Options
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-php.md
Retrieves the default configuration for HTML to Markdown conversion. This is useful for starting with a standard setup before applying custom modifications.
```php
$result = ConversionOptions::default();
```
--------------------------------
### Visit Definition List Start in Swift
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-swift.md
Use this method to visit the start of a definition list (
). Requires a NodeContext.
```swift
let result = instance.visitDefinitionListStart(NodeContext())
```
--------------------------------
### Get Default Conversion Options
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-elixir.md
Retrieves the default configuration options for HTML to Markdown conversion. This is useful for starting with a standard setup before applying custom modifications.
```elixir
def default()
# Example:
{:ok, result} = ConversionOptions.default()
```
--------------------------------
### Serve Documentation Locally
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/contributing.md
Install documentation dependencies and serve the documentation site locally for live preview. Fix all warnings before pushing changes.
```bash
uv sync --group doc
uv run --no-sync zensical serve # live preview at localhost:8000
```
```bash
scripts/ci/docs/build.sh --strict # what CI runs — fix all warnings before pushing
```
--------------------------------
### Install flutter_rust_bridge_codegen
Source: https://github.com/xberg-io/html-to-markdown/blob/main/packages/dart/BUILDING.md
Install the Flutter Rust Bridge codegen tool globally. This is a one-time setup step.
```sh
cargo install flutter_rust_bridge_codegen
```
--------------------------------
### VisitTableStart Go Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-go.md
Called before processing a table `
`. Use this to initialize table processing.
```go
result := instance.VisitTableStart(NodeContext{})
```
--------------------------------
### Go: VisitElementStart() Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-go.md
Called before entering any element. Use this to implement generic element handling before tag-specific logic.
```go
result := instance.VisitElementStart(NodeContext{})
```
--------------------------------
### Setting up ROS Node Entry Points
Source: https://github.com/xberg-io/html-to-markdown/blob/main/tools/benchmark-harness/fixtures/real-world/issues/gh-190/kimbrain.html
Configure the setup.py file to specify entry points for your ROS node, allowing it to be executed from the terminal.
```python
'my_node = ros_study_py.my_node:main'
```
--------------------------------
### Java: visitTableStart() Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-java.md
Called before processing a table. Use this to initialize table processing.
```java
var result = instance.visitTableStart(new NodeContext());
```
--------------------------------
### Elixir Usage Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/installation.md
Verify the Elixir installation by converting HTML to Markdown. Uses Rustler NIFs for performance.
```elixir
{:ok, result} = HtmlToMarkdown.convert("
Hello
")
IO.puts(result.content)
# # Hello
```
--------------------------------
### Default Conversion Options
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-dart.md
Get the default configuration for HTML to Markdown conversion. This is useful as a starting point for custom configurations.
```dart
final result = ConversionOptions.default();
```
--------------------------------
### VisitElementStart C# Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-csharp.md
Called before entering any element. Use this for generic element handling before tag-specific logic.
```csharp
var result = instance.VisitElementStart(new NodeContext());
```
--------------------------------
### Get Default Conversion Options
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-go.md
Retrieves the default `ConversionOptions` struct. This is useful for starting with a standard configuration and then customizing specific fields.
```go
result := ConversionOptions.Default()
```
--------------------------------
### Get Default Conversion Options
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-c.md
Retrieves the default conversion options for HTML to Markdown. This is a starting point for customizing conversion behavior.
```c
HtmConversionOptions *result = htm_default();
```
--------------------------------
### PHP visitTableStart() Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-php.md
Called before processing an HTML table. Requires a NodeContext.
```php
$result = $instance->visitTableStart(new NodeContext());
```
--------------------------------
### Example of a Paragraph Element
Source: https://github.com/xberg-io/html-to-markdown/blob/main/test_documents/html/wikipedia/small_html.html
Shows the start tag for a paragraph element. The end tag for this element is often optional and can be inferred by the browser.
```html
```
--------------------------------
### Visit Definition List Start (C)
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-c.md
Use this function to visit the start of a definition list element like `
`. It requires only a node context.
```c
HtmVisitResult *result = htm_visit_definition_list_start(instance, NULL);
```
--------------------------------
### Python Version Sync Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/test_apps/README.md
Illustrates how the `scripts/sync_versions.py` script updates version information in various application manifests, starting from Cargo.toml.
```python
# From Cargo.toml (source of truth)
version = "2.18.0"
# Propagates to:
# - tests/test_apps/python/pyproject.toml → html-to-markdown>=2.18.0
# - tests/test_apps/node/package.json → html-to-markdown@>=2.18.0
# - tests/test_apps/ruby/Gemfile → gem 'html-to-markdown', '>= 2.18.0'
# - tests/test_apps/go/go.mod → (version in module path)
# - tests/test_apps/java/pom.xml → 2.18.0
# - tests/test_apps/csharp/TestApp.csproj → 2.18.0
# - tests/test_apps/php/composer.json → "xberg-io/html-to-markdown": ">=2.18.0"
# - tests/test_apps/elixir/mix.exs → {:html_to_markdown, "~> 2.18.0"}
```
--------------------------------
### Complete React Application Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/tools/benchmark-harness/fixtures/mdream/react-learn.html
A full example demonstrating state management and prop passing in React, including both the parent and child components.
```javascript
import { useState } from 'react';
export default function MyApp() {
const [count, setCount] = useState(0);
function handleClick() {
setCount(count + 1);
}
return (
Counters that update together
);
}
function MyButton({ count, onClick }) {
return (
);
}
```
--------------------------------
### Dart Usage Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/installation.md
Verify the Dart installation by initializing the Rust library and converting HTML to Markdown. Requires Dart 3.11+.
```dart
import 'package:h2m/h2m.dart';
import 'package:h2m/src/html_to_markdown_rs_bridge_generated/frb_generated.dart'
as bridge;
await bridge.RustLib.init();
final result = await H2mBridge.convert('
Hello
');
print(result.content);
```
--------------------------------
### Go: VisitListStart() Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-go.md
Called before processing a list (`
` or ``). Indicates if the list is ordered.
```go
result := instance.VisitListStart(NodeContext{}, true)
```
--------------------------------
### Get Default Conversion Options
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-typescript.md
Retrieves the default configuration options for HTML to Markdown conversion. This is useful as a starting point for custom configurations.
```typescript
const result = ConversionOptions.default();
```
--------------------------------
### PHP visitListStart() Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-php.md
Called before processing an unordered or ordered list. Requires a NodeContext and a boolean indicating if the list is ordered.
```php
$result = $instance->visitListStart(new NodeContext(), true);
```
--------------------------------
### Vue.js Composition API Component Example with
```
--------------------------------
### Go: VisitImage() Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-go.md
Handles image tags (``). Provides context, src, alt text, and title for the image.
```go
result := instance.VisitImage(NodeContext{}, "value", "value", "value")
```
--------------------------------
### Create Default Conversion Options
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-csharp.md
Use this method to get a ConversionOptions object with default settings. This is useful as a starting point for customizing conversion behavior.
```csharp
var result = ConversionOptions.CreateDefault();
```
--------------------------------
### C# VisitTableStart Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-csharp.md
Call this method before processing a table's opening tag (
).
```csharp
var result = instance.VisitTableStart(new NodeContext());
```
--------------------------------
### Get Default Conversion Options
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-java.md
Retrieves the default configuration options for HTML to Markdown conversion. This is useful as a starting point for customizing conversion settings.
```java
var result = ConversionOptions.defaultOptions();
```
--------------------------------
### Python Metadata Extraction Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/readme_templates/partials/_metadata_extraction.md
Demonstrates how to enable and access extracted metadata in Python. Use this to get document title, headers, links, images, and structured data.
```python
from html_to_markdown import convert, ConversionOptions
html = '
Article
'
result = convert(html, ConversionOptions(extract_metadata=True))
print(result.content) # Converted Markdown
print(result.metadata.document.title) # Document title
print(result.metadata.headers) # All h1-h6 elements
print(result.metadata.links) # All hyperlinks
print(result.metadata.images) # All images with alt text
print(result.metadata.structured_data) # JSON-LD, Microdata, RDFa
```
--------------------------------
### Go: VisitCodeBlock() Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-go.md
Handles code blocks (`
`). Provides context, language identifier, and the code content.
```go
result := instance.VisitCodeBlock(NodeContext{}, "value", "value")
```
--------------------------------
### VisitMark Go Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-go.md
Call this method to visit mark/highlight elements ().
```go
result := instance.VisitMark(NodeContext{}, "value")
```
--------------------------------
### Go: VisitCodeInline() Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-go.md
Handles inline code (``). Provides context and the code content.
```go
result := instance.VisitCodeInline(NodeContext{}, "value")
```
--------------------------------
### Vue Single-File Component (Composition API)
Source: https://github.com/xberg-io/html-to-markdown/blob/main/tools/benchmark-harness/fixtures/mdream/vuejs-docs.html
This example shows a Vue component using the Composition API with the `
```
--------------------------------
### Install PHP HTML to Markdown Extension
Source: https://github.com/xberg-io/html-to-markdown/blob/main/README.md
Use `pie install` to install the native PHP extension for html-to-markdown. This is not a Composer package.
```sh
pie install xberg-io/html-to-markdown
```
--------------------------------
### Python visit_element_start() Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-python.md
Called before entering any element. Use for generic element handling before tag-specific logic.
```python
result = instance.visit_element_start(NodeContext())
```
--------------------------------
### Elixir visit_table_start() Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-elixir.md
Called before processing a table `
`. Use this to initialize table processing.
```elixir
def visit_table_start(ctx)
{:ok, result} = instance.visit_table_start(%{{}})
```
--------------------------------
### Go: VisitListItem() Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-go.md
Handles list items (`
`). Provides context, ordered status, marker, and text content.
```go
result := instance.VisitListItem(NodeContext{}, true, "value", "value")
```
--------------------------------
### Install HTML to Markdown Swift Package
Source: https://github.com/xberg-io/html-to-markdown/blob/main/packages/swift/README.md
Build the Swift package from source by cloning the repository and using Cargo and Swift build commands. SwiftPM URL consumption is not yet available.
```bash
git clone https://github.com/xberg-io/html-to-markdown.git
cd html-to-markdown
cargo build -p html-to-markdown-rs-swift --release
swift build --package-path packages/swift
```
--------------------------------
### PHP: Visit Element Start
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-php.md
Called before entering any element. Use this to implement generic element handling before tag-specific logic.
```php
$result = $instance->visitElementStart(new NodeContext());
```
--------------------------------
### Visit Element Start - Swift
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-swift.md
Called before entering any element. Use for generic element handling before tag-specific logic.
```swift
let result = instance.visitElementStart(NodeContext())
```
--------------------------------
### Visit Figure Start in Python
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-python.md
Called at the start of a figure element. Requires a NodeContext.
```python
result = instance.visit_figure_start(NodeContext())
```
--------------------------------
### VisitDefinitionDescription Go Example
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-go.md
Call this method to visit definition descriptions (
).
```go
result := instance.VisitDefinitionDescription(NodeContext{}, "value")
```
--------------------------------
### Manual Testing Setup and Execution for Python
Source: https://github.com/xberg-io/html-to-markdown/blob/main/test_apps/README.md
Commands to set up Python dependencies and run smoke and comprehensive tests locally using pytest.
```bash
cd tests/test_apps/python
uv sync --no-install-project --no-install-workspace
uv run --no-sync pytest smoke_test.py -v
uv run --no-sync pytest comprehensive_test.py -v
```
--------------------------------
### Install html-to-markdown for Factory Droid
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/agent-skills.md
Use these commands to install the html-to-markdown plugin for Factory Droid.
```text
droid plugin marketplace add https://github.com/xberg-io/plugins
droid plugin install html-to-markdown@xberg-io
```
--------------------------------
### Visit Element Start - Java
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-java.md
Called before entering any element. Use this for generic element handling.
```java
var result = instance.visitElementStart(new NodeContext());
```
--------------------------------
### Visit Definition List Start in Java
Source: https://github.com/xberg-io/html-to-markdown/blob/main/docs/reference/api-java.md
Use this method to visit the start of a definition list (
). Requires a NodeContext.
```java
var result = instance.visitDefinitionListStart(new NodeContext());
```