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

Add "chunkwrap" metatag #441

Merged
merged 7 commits into from
Mar 26, 2024
Merged

Add "chunkwrap" metatag #441

merged 7 commits into from
Mar 26, 2024

Conversation

towerofnix
Copy link
Member

@towerofnix towerofnix commented Mar 26, 2024

Development:

Notes:

  • Chunkwrap is magic!
  • Chunkwrap is very pure and safe magic. Chunkwrap would never hurt you.
  • Chunkwrap may not play nice with alternate localization, and this is left as a concern to address later.
  • Chunkwrap takes inline-block wrapping responsibilities away from the parent and moves it into each of a sequence of children which chunkwrap creates, by splitting after each instance of a specified marker (for example , as in an accent). The parent gets no special wrapping behavior, at each child is treated as its own wrappable unit.
  • Chunkwrap is currently used to make word wrapping in the additional names box nice.

Technical details:

  • Apart from html.tag('chunkwrap', {split: ','}), this PR also introduces a new utility html.smush(). Smushing is a simple recursive operation which provides a nice, even, not-bumpy layer of top-level texts and tags. It takes hierarchies of content-only tags nested directly under other content-only tags, such as produced by language.formatString or any call to html.tags([...]), and evens them out into a single continuous layer. Any adjacent bits of text, including opposite boundaries of html.tags([]) containing text as well as tags, are combined into single strings, so they can be conveniently operated on.
    • Smushing always results in a hierarchy that stringifies to the same output as if the input hadn't been smushed.
    • Smush will traverse tags which are contentOnly, but never tags which are not. Smush doesn't care at all about what's going on inside a normal element; it only wants to smooth a run of apparently top-level tags and apparently top-level texts into one layer of actually top-level tags and texts.
    • Smush will resolve templates, but only at the top level. This is so that it can actually see everything that's going on at the top-level. If a template returns html.tags([]) which directly nests more templates, those will also be resolved, but only until everything at the top layer is a sequence of tags and texts.
    • Smushing never results in two strings next to each other, but it can result in two tags next to each other, if there wasn't any text between them.
    • Smushing respects the smushee's [html.joinChildren] attribute at each layer. This means it applies the appropriate joiner wherever stringifying would; each parent applies its joiner to between own children, not between the children that each recursively smushed child will actually be represented as.
  • Smushing exists to address the "transparent" layers which we've made use of in these prior pull requests:
  • The chunkwrap metatag smushes its own contents (i.e itself) so that it has direct access to the text components which divide its non-text chlidren. Chunkwrap never splits inside elements (nor inside attribute values!!), so it needs a clean hierarchy of just the top-level texts. Those are safe to split inside.

@towerofnix towerofnix merged commit 5da9b99 into preview Mar 26, 2024
@towerofnix towerofnix deleted the chunkwrap branch March 26, 2024 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant