init(contentsOf:including:options:baseURL:)
Creates an attributed string from the contents of a specified Markdown URL, using the provided options and attribute scope that a key path identifies.
Declaration
init<S>(contentsOf url: URL, including scope: KeyPath<AttributeScopes, S.Type>, options: AttributedString.MarkdownParsingOptions = .init(), baseURL: URL? = nil) throws where S : AttributeScopeParameters
- url:
The URL to load Markdown-formatted data from.
- scope:
The Attributescopes key path that identifies an attribute scope to associate with the attributed string.
- 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 isnil.
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.