Contents

init(markdown:including:options:baseURL:)

Creates an attributed string from a Markdown-formatted string using the provided options and attribute scope.

Declaration

init<S>(markdown: String, including scope: S.Type, options: AttributedString.MarkdownParsingOptions = .init(), baseURL: URL? = nil) throws where S : AttributeScope

Parameters

  • markdown:

    The string that contains the Markdown formatting.

  • scope:

    The 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 is nil.

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 from Markdown Strings