Skip to main content

split_pages

Function split_pages 

Source
pub fn split_pages(text: &str) -> Vec<String>
Expand description

Splits intro text into pages at lines that consist of exactly ---.

This is the Python raw.split("\n---\n") followed by trimming each page and dropping empty ones. Text without a separator is a single page, and blank text yields one empty page rather than none, so a caller can always show at least one panel.

use shellgame::ui::split_pages;

assert_eq!(split_pages("První\n\n---\n\nDruhá\n"), ["První", "Druhá"]);
assert_eq!(split_pages("Jedna"), ["Jedna"]);
assert_eq!(split_pages("  \n"), [""]);