split_by_width:
type: task
script:
- define book "<&8>I am trying to write a method that will automatically wrap text from one page onto the next without any problems. Book pages used to be capped at 256 characters each, but since some characters are smaller than others they changed it to use character width instead. I'm trying to use this to wrap my text from page 1 to page 2 to page 3 etc. perfectly without cutting off words or anything like that."
- define pages <[book].split_lines_by_width[1596].split[<n>]>
- define lastColors <[pages].parse[last_color]>
- foreach <[lastColors]> as:color:
- define nextPage <[loop_index].add[1]>
- if <[pages].size> < <[nextPage]>:
- foreach stop
- define pages[<[nextPage]>]:<[color]><[pages].get[<[nextPage]>]>
Wrote a small script that should do what you want to do. It also includes the last color from the recent page.