New conversion options for Markdown Conversion
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.