cloudflare / cloudflare/cloudflare-docs

Markdown Conversion of HTML `hostname` option requires URL

Open
#31,303 1 comment 0 reactions 7 assignees Claimed by @zeke View on GitHub
content:edit documentation product:workers-ai stale
Dominant language
MDX
Stars
5.2k
Forks
16.7k
Avg merge
2d 6h
Merged PRs (30d)
337

Description

### Existing documentation URL(s)

- https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/#html
- https://developers.cloudflare.com/workers-ai/features/markdown-conversion/how-it-works/#html

### What changes are you suggesting?

The description of the Markdown Conversion Options (e.g. for the `env.AI.toMarkdown` binding) describes the HTML `hostname` option as:
> `hostname`: string to use as a host when resolving relative links inside the HTML.

The property name and this description suggests that a bare `example.com` style hostname (e.g. the result of `URL.hostname`) should be used. However, that leaves relative links in the markdown result (if there is no `` element in the HTML itself).

It appears that this option actually requires a base URL, which will typically be the full URL of the page being converted (`URL.origin` wouldn't suffice for pages in sub-directories). The How It Works page hints at this, but it should be explicit in the description of the Conversion Options, especially since the option name itself is misleading.

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.