convert-case icon indicating copy to clipboard operation
convert-case copied to clipboard

Is there a way to specify `\n` as a boundary?

Open JosephTLyons opened this issue 2 years ago • 2 comments

I'm trying to use Case::Title on some text that contains a newline (ex: The big\nblue house), but the newline isn't counted as a boundary, so I get The Big\nblue House. Is there a way to specify newlines as boundarys so I can get The Big\nBlue House? Thanks.

I tried doing something like:

let mut boundaries = Boundary::list_from("\n");
boundaries.push(Boundary::Space);

let converter = Converter::new()
    .to_case(Case::Title)
    .set_boundaries(&boundaries);

But I didn't have any luck with this.

JosephTLyons avatar Aug 07 '23 08:08 JosephTLyons

This is not a feature at this time. You can only split a string based on a boundary condition, which is currently fixed to whatever is currently in Boundary, which doesn't include a generic "character" option. This should definitely be an option. I'd like to keep this issue open until it is fully investigated. For now, you would need to manually split the string before hand.

rutrum avatar Dec 29 '23 12:12 rutrum

Manually splitting is what I ended up doing. Appreciate the response.

JosephTLyons avatar Jan 01 '24 17:01 JosephTLyons