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

Squashing consecutive newlines #201

Closed
newhoggy opened this issue Jul 19, 2021 · 3 comments
Closed

Squashing consecutive newlines #201

newhoggy opened this issue Jul 19, 2021 · 3 comments

Comments

@newhoggy
Copy link

newhoggy commented Jul 19, 2021

Is it possible to add a special kind of newline whereby if there were more than one consecutive such newline they will be squashed into one?

@newhoggy
Copy link
Author

Similarly for spaces.

@quchen
Copy link
Owner

quchen commented Jul 22, 2021

This has been requested multiple times via various channels, and I’m not a fan of it.

Rationale

Code

On a code level, it would be quite complicated, and thus only pitfall-heavy, probably changing the Doc type.

Usage

  • To how many lines do we collapse – maybe we want to keep a single empty line max, thus should it be collapseToMaxEmptyLines 1?
  • Can we somehow cancel a previously set collapse-linebreak if e.g. a previous producer has one but we’d like to have a hard line break?
  • What’s the semantics of line <> collapseLine, collapseLine <> line?
  • What does collapseLine <> ann "test" collapseLine do? Print a (maybe surprising) empty line, or silently discard an annotation?

My recommendation

Produce your documents with concatWith, and insert the desired amount of lines between manually. Don’t use the layouter to clean up your Doc, but rather create it in a way it doesn’t have to.

@newhoggy
Copy link
Author

Thanks for you advice and suggestions!

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