Closed photos closed 5 years ago
It depends from your desired result, but could be something like that
func stringWithOrderedList() -> NSAttributedString {
var counter = 0
let transformers: [TagTransformer] = [
TagTransformer.brTransformer,
TagTransformer(tagName: "ol", tagType: .start) { _ in
counter = 0
return ""
},
TagTransformer(tagName: "li", tagType: .start) { _ in
counter += 1
return "\(counter > 1 ? "\n" : "")\(counter). "
}
]
return "<ol><li>Coffee</li><li>Tea</li><li>Milk</li></ol>".style(tags: [], transformers: transformers).attributedString
}
How should I handle
<ol>
ordered lists? Should I use theTagTransformer
?Example:
<ol><li>Northerngiraffe</li><li>Reticulated giraffe</li><li>Masai giraffe</li><li>Southern giraffe</li></ol>
Expected Result: `1. Northern giraffe