ZhgChgLi/ZMarkupParser

Use ListItemMarkup with NSTextList

zhgchgli0718 opened this issue · 0 comments

I found an attribute called NSTextList in NSMutableParagraphStyle, but after testing, I didn't see any benefit in using it because even when using NSTextList, we still need to manually append list items and padding to NSAttributedString.

sample code:

let attributedText = NSMutableAttributedString()
let paragraphStyle = NSMutableParagraphStyle()
let list = NSTextList(markerFormat: .circle, options: 0)
paragraphStyle.textLists = [list]
attributedText.append(NSAttributedString(string: "test"))
attributedText.append(NSAttributedString(string: "\(list.marker(forItemNumber: 1))testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest", attributes: [.paragraphStyle: paragraphStyle]))
attributedText.append(NSAttributedString(string: "test"))