-
Notifications
You must be signed in to change notification settings - Fork 63
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
Preserve line breaks and white space in algorithm steps #513
base: main
Are you sure you want to change the base?
Preserve line breaks and white space in algorithm steps #513
Conversation
Hmm. I agree we need better formatting for large records, but I'm not totally convinced by the approach of preserving whitespace - I think I'd like to handle them explicitly. Right now I definitely assume whitespace will get collapsed when working with ecmarkdown text. |
I think that assumption is fine, but rather than forcing authors to set up the spacing, could ecmarkup not just explicitly format any record with more than, say, 3 fields, to be multiline? |
Yeah, that's what I meant by "handle them explicitly" (though it would be a little more complicated than that - you only want to expand a record at the end of a line, and you probably want to let the user control whether expansion happens by omitting or including a linebreak after the initial |
Do you have any concrete examples? All I can find in ECMA-262 are two cases of embedded tables1, which can also be addressed with CSS like I did consider something like Record auto-formatting, but ultimately came to the conclusion that the rendering of steps should generally match their source representation—the author of the latter is best-positioned to determine the appropriateness of forced line breaks etc. in the former. Footnotes
|
I don't know that I deliberately rely on whitespace collapsing; rather it's just that it's (kind of) HTML, and I assume whitespace always collapses when writing HTML. Even if we did make it whitespace-sensitive, for formatting records in particular I'd still want |
I don't disagree with you, but <emu-alg> acts a lot like <pre> in this respect (e.g., ecmarkdown is already sensitive to whitespace for list item indentation).
Sure, but that's just linting—there'd be a relevant difference between single-line vs. multi-line Records and a programatically-enforcable opinion about which style is appropriate. |
Fair point about lists. I'm still not sure about fully general whitespace-sensitivity, though. I guess my actual opinion is, I think explicitly supporting multi-line records is sufficient for the use case we actually have, and is a much more narrowly scoped change, so I'm more inclined in that direction. If there's some reason to want the more general thing I'd be happier going that way. Still, maybe we can merge this as-is (once I review and upstream the prerequisite ecmarkdown PR) and maybe switch it out for the more narrow thing when I get around to actually implementing that. |
Works for me. As far as I know, large records and the aforementioned embedded tables are the only examples of line-oriented formatting inside <emu-alg> items, and the latter are already an escape hatch. |
P.S. This could actually be merged ahead of tc39/ecmarkdown#94 ; the only negative consequence would be a little bit of extra rendered whitespace. But I agree that there's no need to rush. |
Temporal makes extensive use of line breaks in defining large Records, but they end up collapsed in rendered documentation (for example, ParseTemporalInstantString source vs. result). As noted in tc39/proposal-temporal#2290 (review) , that hinders readability.
This PR updates the CSS to preserve line breaks and whitespace while preserving wrapping of long lines.