|
|
|
|
|
by mdciotti
1283 days ago
|
|
I've frequently wondered why a hierarchical approach is the norm for text formatting. It seems that many problems could be solved trivially using a text buffer and a list of formatting sequences defined by a starting index and a length. The only place I've seen this in practice is in Telegram's TL Schema [1]. Is this method found anywhere else? Edit to note: there is one obvious advantage to in-band markup such as HTML -- streaming formatted content. Though I wonder if this could be done with a non-hierarchical method, for example using in-band start tags which also encode the length. Edit 2: looks like Condé Nast maintains a similar technology called atjson [2]. [1]: https://core.telegram.org/api/entities [2]: https://github.com/CondeNast/atjson |
|
ProseMirror (a JavaScript library for building rich text editors) also employs a document model like this. The docs for that project [2] do a good job of explaining how their implementation of this idea works, and what problems it solves.
[1]: https://medium.engineering/why-contenteditable-is-terrible-1...
[2]: https://prosemirror.net/docs/guide/#doc