What is OpenStart and OpenEnd use for?

I’m trying to insert a slice into the contents of a node and i’m trying to figure out what the openStart and openEnd are. I read that it refers to the open start depth and open end depth but that doesn’t really add any information in terms of how or why I should set it. What is an example of when I would want it to be 0 or 1 ?

Think of it as the amount of open/close tokens to skip at the start/end of the content. A replace step must ‘fit’ into the position it it inserted in, in that the tokens it inserts should, when replacing the tokens it covers, still produce a valid document. So for example to split a paragraph, you need to insert </p><p> tokens, so you create a slice holding <p></p><p></p> and set openStart and openEnd to 1.

2 Likes

Whoa, that’s a really helpful way to describe this.

Do you think it would be appropriate to add an explanation like this to the guide somewhere if not already present? Thanks!

Do you mind sharing an asymmetric example? I’m a bit mixed up as to whether or not openStart means <p><p> or </p></p>. Start = “at the start” or openstart => “missing the opening”.

They indicate how many levels are ‘open’ (only their content is part of the slice, not their start/end token) at both sides of the slice.