---
title: "init(contentsOf:options:baseURL:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/attributedstring/init(contentsof:options:baseurl:)"
---

# init(contentsOf:options:baseURL:)

Creates an attributed string from the contents of a specified URL that contains Markdown-formatted data, using the provided options.

## Declaration

```swift
init(contentsOf url: URL, options: AttributedString.MarkdownParsingOptions = .init(), baseURL: URL? = nil) throws
```

## Parameters

- `url`: The URL to load Markdown-formatted data from.
- `options`: Options that affect how the initializer interprets formatting in the Markdown string. This parameter defaults to no options.
- `baseURL`: The base URL to use when resolving Markdown URLs. The initializer treats URLs as being relative to this URL. If this value is nil, the initializer doesn’t resolve URLs. The default is nil.

## Discussion

Discussion If your source string includes custom attributes defined by conformers to MarkdownDecodableAttributedStringKey and used with Apple’s markdown extension syntax, be sure to include the allowsExtendedAttributes option. Otherwise, the initializer doesn’t parse these attributes.

## See Also

### Initializing with Markdown from URL Contents

- [init(contentsOf:including:options:baseURL:)](foundation/attributedstring/init(contentsof:including:options:baseurl:)-1x6fz.md)
- [init(contentsOf:including:options:baseURL:)](foundation/attributedstring/init(contentsof:including:options:baseurl:)-1fcpy.md)
