What sets NSTextParagraph.paragraphSeparatorRange and paragraphContentRange

With my continued experiments with TextKit2, I'm trying to figure out what sets the properties paragraphSeparatorRange and paragraphContentRange on a NSTextParagraph. These seem to be computed properties (or at least they cannot be directly set via public API).

var paragraph = NSTextParagraph(attributedString: NSAttributedString(string: "It was the best of times.\n"))
print("attributes: \(paragraph.attributedString.attributes(at: 0, effectiveRange: nil))")
print("paragraphSeparatorRange: \(String(describing: paragraph.paragraphSeparatorRange))")
print("paragraphContentRange: \(String(describing: paragraph.paragraphContentRange))")

In the above example, both paragraphSeparatorRange and paragraphContentRange are nil.

However, when using NSTextLayoutManager/NSTextContentStorage they are set.

let layoutManager = NSTextLayoutManager()
let container = NSTextContainer(size: NSSize(width: 400, height: 400))
layoutManager.textContainer = container
let contentStorage = NSTextContentStorage()
contentStorage.textStorage = NSTextStorage(string: "It was the best of times.\n")
contentStorage.addTextLayoutManager(layoutManager)
layoutManager.enumerateTextLayoutFragments(from: contentStorage.documentRange.location, options: .ensuresLayout) { textLayoutFragment in
    print("layoutFragment: \(textLayoutFragment)")
    print("textElement: \(String(describing: textLayoutFragment.textElement))")
    print("textElement.range: \(String(describing: textLayoutFragment.textElement?.elementRange))")
    let paragraph = textLayoutFragment.textElement as! NSTextParagraph
    print("paragraphContentRange: \(String(describing: paragraph.paragraphContentRange))")
    print("paragraphSeparatorRange: \(String(describing: paragraph.paragraphSeparatorRange))")
 
    
    return true
}

Would appreciate any ideas on how these values are computed/set. Thanks

paragraphSeparatorRange is a newline/paragraph_separator itself

paragraphContentRange is just paragraph content, without the newline

values are available once the layout happen.

What sets NSTextParagraph.paragraphSeparatorRange and paragraphContentRange
 
 
Q