Workers AI - New conversion options for Markdown Conversion
The Markdown Conversion service now supports customizable conversion options through a conversionOptions object, allowing you to configure image descriptions language, CSS selectors for HTML extraction, relative link resolution, and PDF metadata exclusion. This gives you fine-grained control over how different file types are processed when converting to Markdown.
You can now customize how the Markdown Conversion service processes different file types by passing a conversionOptions object.
Available options:
- Images: Set the language for AI-generated image descriptions
- HTML: Use CSS selectors to extract specific content, or provide a hostname to resolve relative links
- PDF: Exclude metadata from the output
Use the env.AI binding:
await env.AI.toMarkdown(
{ name: "page.html", blob: new Blob([html]) },
{
conversionOptions: {
html: { cssSelector: "article.content" },
image: { descriptionLanguage: "es" },
},
},
);await env.AI.toMarkdown(
{ name: "page.html", blob: new Blob([html]) },
{
conversionOptions: {
html: { cssSelector: "article.content" },
image: { descriptionLanguage: "es" },
},
},
);
Or call the REST API:
curl https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/tomarkdown \
-H 'Authorization: Bearer {API_TOKEN}' \
-F 'files=@index.html' \
-F 'conversionOptions={"html": {"cssSelector": "article.content"}}'
For more details, refer to Conversion Options.
Source: original entry ↗
More from Cloudflare
Follow Cloudflare to get its new changes in your feed and email digest.
Cloudflare One Client for Windows hotfix - trusted certificate chains
A new GA release for Windows Cloudflare One Client is available, addressing an issue with building trusted certificate chains.
Cloudflare One Client for macOS - Trusted Certificate Chain Fix
A new GA release of the macOS Cloudflare One Client is available. This hotfix addresses an issue with building trusted certificate chains.
Cloudflare One Client for Linux
A new GA release of Cloudflare One Client for Linux is now available. This hotfix addresses an issue with building trusted certificate chains.