Earlier quoted context omitted.
Since hyperlinks can link to any document, not just children, shouldn't the data structure be a (not necessarily tree-shaped) directed graph?
I can't even decide whether the text (e.g. in a div or p element) should be stored as a unit with links stored as meta-data, or should the stretches of text before/after/between links be "chunks" and the links store their own content (like DOM)? It's an old question, see the "piece-chain" structure Prof With chose for text-with-"looks" (aka "style") http://www.inf.ethz.ch/personal/wirth/ProjectOberon/PO.Syste... sect…
The former is how NSAttributedString works in the Apple ecosystem. It’s a plain string with attributes attached to certain character ranges.
https://developer.apple.com/documentation/foundation/nsattri...