toTextData
Splits the receiver into segments of normal text and furigana pairs.
The parser looks for the marker [漢字[かんじ]] :
The first bracketed chunk (
漢字) becomes TextData.text.The nested chunk (
かんじ) becomes TextData.reading.All text outside the marker is returned unchanged with reading = null.
The original order is preserved. If the string contains no markers, the whole string is returned as a single TextData with reading = null.
Receiver
A string that may embed furigana markers.
Return
Ordered List<TextData> ready for rendering.
Example
val parts = "これは[漢字[かんじ]]です".toTextData()
// [
// TextData(text = "これは"),
// TextData(text = "漢字", reading = "かんじ"),
// TextData(text = "です")
// ]Content copied to clipboard