# markdown

## Table of Contents

- [Options](#options)
- [Examples](#examples)

---

The page as clean Markdown, ready for LLM context windows. It resolves to a string:

```js
constmarkdown=awaitmicrolink.markdown('https://example.com')
```

Headings, links, lists, tables, and code blocks are preserved; navigation chrome, scripts, and styles are dropped. Documents work too: point it at a PDF with a text layer or an office file (`docx`, `xlsx`, `pptx`, `odt`, `rtf`, `epub`) and the content is converted the same way.

## Options

- [selector](https://microlink.io/docs/sdk/methods/extract/selector) `<string>` — scopes the conversion to the first element matching the CSS selector.
- [selectorAll](https://microlink.io/docs/sdk/methods/extract/selectorAll) `<string> | <string[]>` — scopes the conversion to every matching element, resolving to an array with one Markdown string per match.
- [type](https://microlink.io/docs/sdk/methods/extract/type) `<string>` — overrides how the extracted value is normalized, per the [rules grammar](https://microlink.io/docs/sdk/methods/extract).

Any [shared option](https://microlink.io/docs/sdk/getting-started/options) applies too. [prerender](https://microlink.io/docs/api/parameters/prerender) and [waitForSelector](https://microlink.io/docs/api/parameters/waitForSelector) matter most here: client-side rendered content only exists after JavaScript runs.

## Examples

Keep just the article body, leaving out headers, footers, and sidebars:

```js
constmarkdown=awaitmicrolink.markdown('https://example.com/blog/post',{

selector:'article'

})
```

One string per comment on a discussion page:

```js
constcomments=awaitmicrolink.markdown(

'https://news.ycombinator.com/item?id=1',

{

selectorAll:'.comment'

}

)

console.log(comments.length)
```

Wait for a client-side rendered page to finish before converting:

```js
constmarkdown=awaitmicrolink.markdown('https://app.example.com/docs',{

prerender:true,

waitForSelector:'main h1'

})
```

Under the hood the call is an [extraction rule](https://microlink.io/docs/sdk/methods/extract) with `attr: 'markdown'`; use [extract](https://microlink.io/docs/sdk/methods/extract) when you want Markdown for one field and other values alongside it.

See [URL to Markdown](https://microlink.io/docs/guides/content-conversion/url-to-markdown) in the content conversion guide for scoping strategies, document support, and LLM pipelines.