rutrum / convert-case

Converts to and from various cases.
MIT License
122 stars 10 forks source link

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

Open JosephTLyons opened 1 year ago

JosephTLyons commented 1 year ago

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.

rutrum commented 10 months ago

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.

JosephTLyons commented 9 months ago

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