Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling text with newlines #71

Open
TheNeikos opened this issue May 2, 2022 · 1 comment
Open

Handling text with newlines #71

TheNeikos opened this issue May 2, 2022 · 1 comment

Comments

@TheNeikos
Copy link

I would like to use pretty to print text that comes from users. The problem is that it will contain new lines. What would be the preferred way of using it here? Should I simply break up the string myself on newlines and add each seperately with Doc::text?

@Marwes
Copy link
Owner

Marwes commented May 3, 2022

You can use https://docs.rs/pretty/0.11.3/pretty/trait.DocAllocator.html#method.reflow if you are fine with treating newlines the same as any whitespace. Otherwise you will need to break it up yourself as Doc::text will treat newlines the same as any other character so it tends to mess up the width calculation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants