-
Notifications
You must be signed in to change notification settings - Fork 5
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
Styled
documents interact poorly with line breaking.
#30
Comments
Actually I think I do have a reasonable idea, involving some more unfoldD (Linked l x) = LinkOpen l : unfoldD x <> [LinkClose]
unfoldD (Styled f x) = StyleOpen f : unfoldD x <> [StyleClose] seems to work but probably no PR til next week |
I am approaching a PR that is sort of like what I proposed a few days ago but instead of adding cases to In working on this I realized that the busted line-breaking was a condition that already existed in
This boils down to, like with Is there any particular design intention for, say, how a |
No intention. I just didn't anticipate that anyone would do this. Incidentally, it occurred to me that it could be worth experimenting with an alternative way of approaching Doc that makes it a Seq of Doc' elements. This might avoid the need to have both Doc and FlatDoc, and it would avoid the need for a 'unfolding' or 'flattening' operation. I haven't really looked into this, so there might be an obvious reason why it would be a bad idea, but it's worth a thought. |
I like that idea and I will experiment with that. |
I've spent an hour or so on the If you wanted to prepare for changing what's inside of a |
The inner document of a
Styled
can be aConcat
, but as written,unfoldD
won't unfold that document. The ultimate effect, via the definition ofoffsetOf
, is thatStyled
text will exceed the line length when output becauserenderList (BreakingSpace : xs)
can't correctly measure the offset of aStyled
following aBreakingSpace
.It's not readily apparent what the right adaptation is here. Sprinkling cases around like
unfoldD (Styled f x) = Styled f <$> unfoldD x
andoffsetOf (Styled _ x) = offsetOf x
works towards addresses the line-breaking issue, but that then breaks how nested styles are flattened when outputting attributed text. That suggests we have to do some sort of further intermediate step but I'd have to think pretty hard about a good way of doing that.The text was updated successfully, but these errors were encountered: