danielsaidi / RichTextKit

RichTextKit is a Swift SDK that helps you use rich text in Swift and SwiftUI.
MIT License
944 stars 126 forks source link

Add support to automatically split up text in paragraphs #55

Closed danielsaidi closed 8 months ago

danielsaidi commented 1 year ago

It would be nice if the text editor could automatically detect when a new sentence should be added to a new paragraph, for instance after a certain number of sentences.

For instance, if I ask Chat GPT to Can you divide this text into paragraphs? for this text:

Once upon a time in a small village nestled in the mountains, there lived a young girl named Lily. She possessed a curious spirit and an insatiable love for adventure. One day, while exploring the woods near her home, she stumbled upon a hidden cave. Intrigued, she entered cautiously, discovering a dusty, ancient book with a worn leather cover. As Lily opened the book, a magical portal appeared, transporting her to a mystical realm called Evermore. In Evermore, she encountered fantastical creatures, enchanted forests, and breathtaking landscapes. Guided by an old, wise owl named Orion, Lily embarked on a quest to restore the balance between light and darkness. Along her journey, she encountered a mischievous sprite named Ember, who became her loyal companion. Together, they faced numerous challenges, including treacherous riddles, fearsome monsters, and tests of courage. Lily's determination and Ember's cleverness proved to be a formidable combination. With each obstacle overcome, Lily grew wiser and stronger, unlocking hidden powers within herself. As they delved deeper into Evermore's secrets, they discovered an ancient prophecy foretelling a cataclysmic event that would engulf the realm in eternal darkness. Lily realized that she was the chosen one, destined to fulfill the prophecy and save Evermore. The fate of an entire world now rested on her young shoulders. With unwavering bravery, Lily confronted the malevolent sorcerer responsible for the impending darkness. In a climactic battle, she tapped into her newfound powers, weaving spells of light and hope. The sorcerer, vanquished by her courage, was defeated, and the realm of Evermore was saved. As a token of gratitude, the creatures of Evermore bid Lily a fond farewell, and she returned to her village. Though she had changed, her heart remained filled with wonder and the knowledge that magic existed not only in distant realms but within herself. Lily became an inspiration to her fellow villagers, reminding them to embrace adventure and the boundless possibilities of the unknown. And so, the story of Lily, the young girl who journeyed through the realm of Evermore, lived on as a testament to the extraordinary power of belief, courage, and the timeless allure of a world where anything is possible.

we get:

Once upon a time in a small village nestled in the mountains, there lived a young girl named Lily. She possessed a curious spirit and an insatiable love for adventure. One day, while exploring the woods near her home, she stumbled upon a hidden cave. Intrigued, she entered cautiously, discovering a dusty, ancient book with a worn leather cover.

As Lily opened the book, a magical portal appeared, transporting her to a mystical realm called Evermore. In Evermore, she encountered fantastical creatures, enchanted forests, and breathtaking landscapes. Guided by an old, wise owl named Orion, Lily embarked on a quest to restore the balance between light and darkness.

Along her journey, she encountered a mischievous sprite named Ember, who became her loyal companion. Together, they faced numerous challenges, including treacherous riddles, fearsome monsters, and tests of courage. Lily's determination and Ember's cleverness proved to be a formidable combination. With each obstacle overcome, Lily grew wiser and stronger, unlocking hidden powers within herself.

As they delved deeper into Evermore's secrets, they discovered an ancient prophecy foretelling a cataclysmic event that would engulf the realm in eternal darkness. Lily realized that she was the chosen one, destined to fulfill the prophecy and save Evermore. The fate of an entire world now rested on her young shoulders.

With unwavering bravery, Lily confronted the malevolent sorcerer responsible for the impending darkness. In a climactic battle, she tapped into her newfound powers, weaving spells of light and hope. The sorcerer, vanquished by her courage, was defeated, and the realm of Evermore was saved.

As a token of gratitude, the creatures of Evermore bid Lily a fond farewell, and she returned to her village. Though she had changed, her heart remained filled with wonder and the knowledge that magic existed not only in distant realms but within herself. Lily became an inspiration to her fellow villagers, reminding them to embrace adventure and the boundless possibilities of the unknown.

And so, the story of Lily, the young girl who journeyed through the realm of Evermore, lived on as a testament to the extraordinary power of belief, courage, and the timeless allure of a world where anything is possible.
danielsaidi commented 8 months ago

I'm closing this since I think it's outside the scope of the library.