3 ms·
I would argue that the inline way of annotating things in XML is actually ok-ish if one absolutely needs human edit-ability, but otherwise bad design. {text:
by j-pb 3y ago
I would argue that the inline way of annotating things in XML is actually ok-ish if one absolutely needs human edit-ability, but otherwise bad design.
{text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
annotations: [{tag: "sometag", ranges: [{from: 12, to: 26}]},
{tag: "sometothertag", ranges: [{from: 21, to: 39}]}
Note that this also removes the limitation that annotations have to be consecutive.
- mdaniel 3y agocrafty, but for your consideration: that places the burden upon every library author to be "accounting accurate" to any edits, and the only way anyone would know that it's not correct is to visually inspect the output text also, as I get older I have a deeper and deeper appreciation that "offset" and "text" are words that are fraught with peril
- j-pb 3y agoFair critique, but shouldn't strings be immutable anyways? Once you bring editing into play, you'll probably either want something like a rope or some CRDT and then you have more effective means of tracking positions, than manual offset computations, as part of the data-structure.
- feoren 3y agoWhat about using inline "floating" checkpoints for the ranges, instead of character indexes? {text: "Lorem ipsum {{1}}dolor sit {{2}}amet{{3}}, consectetur{{4}} adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", annotations: [{tag: "sometag", ranges: [{from: 1, to: 3}]}, {tag: "sometothertag", ranges: [{from: 2, to: 4}]}