> ## Documentation Index
> Fetch the complete documentation index at: https://intunedhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# extractMarkdown

Converts HTML content from a Playwright Page or Locator to semantic markdown format.

```typescript theme={null}
export declare function extractMarkdown(input: {
  source: Page | Locator;
}): Promise<string>;
```

## Examples

```typescript Extract Markdown from Locator theme={null}
import { extractMarkdown } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";

interface Params {}

export default async function handler(
  params: Params,
  page: Page,
  context: BrowserContext
) {
  await page.goto("https://books.toscrape.com/");
  const headerLocator = page.locator("h1").first(); // First title on the page
  const markdown = await extractMarkdown({ source: headerLocator }); // Extract markdown from the first title
  console.log(markdown);
  return markdown;
}
```

```typescript Extract Markdown from Page theme={null}
import { extractMarkdown } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";

interface Params {}

export default async function handler(
  params: Params,
  page: Page,
  context: BrowserContext
) {
  await page.goto("https://sandbox.intuned.dev/pdfs");
  const markdown = await extractMarkdown({ source: page });
  console.log(markdown);
  return markdown;
}
```

## Arguments

**input** `Object` *required*

The input object containing the source of the HTML content

**properties**

**input.source** `Page | Locator` *required*

The source of the HTML content. When a Page is provided, extracts from the entire page. When a Locator is provided, extracts from that specific element.

## Returns: `Promise<string>`

Promise that resolves to the markdown representation of the HTML content


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.