Capítulo 176 de 411

Chapter 176: Split Lines Inside Nested Elements (Helper)

Core Idea

SplitText's built-in type: "lines" doesn't correctly handle text that contains nested child elements (like an inline <span> inside a paragraph); this helper works around that by recursively splitting each nested target and merging the resulting line arrays.

Key Concepts

  • Wraps SplitText.create(), then marks word/character elements as protected so the recursive merge doesn't double-process them.
  • If given multiple targets, recurses per-target and concatenates each one's .lines array onto a single split result.
  • Only relevant when vars.type includes "lines" combined with "words" and/or "chars" and the markup has nested elements.

Key Takeaways

  1. Use the plain SplitText.create() first — only reach for this helper when the target actually contains nested inline elements that break normal line-splitting.

Connects To

  • SplitText: the plugin this helper patches around a specific nested-markup limitation.