I’m working on writing a JSON Schema to describe the shape of documents that we’ll be storing and sharing between systems. We have a code block node, based on schema-basic’s:
To allow the block to be empty. In this case it could also have been text{0,1}, but with textblocks that allow marks and non-text inline nodes, you’d need the * to allow breaking the content into pieces.
All document-manipulation functions, as well as Fragment.fromArray, make sure to merge adjacent identically-styled text nodes, so no, you should never end up with a non-canonical encoding of a stretch of text, unless you go out of your way to construct it yourself, by constructing a non-canonical JSON object and deserializing it for example.