---
title: "init(attributedSelectedText:contextBefore:contextAfter:markedText:selectedRangeInMarkedText:)"
framework: browserenginekit
role: symbol
role_heading: Initializer
path: "browserenginekit/betextdocumentcontext/init(attributedselectedtext:contextbefore:contextafter:markedtext:selectedrangeinmarkedtext:)"
---

# init(attributedSelectedText:contextBefore:contextAfter:markedText:selectedRangeInMarkedText:)

Initializes a document with attributed strings that represent the selection and its surrounding context.

## Declaration

```swift
init(attributedSelectedText selectedText: NSAttributedString?, contextBefore: NSAttributedString?, contextAfter: NSAttributedString?, markedText: NSAttributedString?, selectedRangeInMarkedText: NSRange)
```

## Discussion

Discussion The attributedSelectedText, contextBefore, and contextAfter parameters represent the same ranges as their counterparts in init(selectedText:contextBefore:contextAfter:markedText:selectedRangeInMarkedText:), and carry the same requirements, with the addition of text formatting and style attributes.

## See Also

### Creating a text document context

- [init(selectedText:contextBefore:contextAfter:markedText:selectedRangeInMarkedText:)](browserenginekit/betextdocumentcontext/init(selectedtext:contextbefore:contextafter:markedtext:selectedrangeinmarkedtext:).md)
