libara 0.2.3
libara: ^0.2.3 copied to clipboard
Attributed Range Algebra: overlapping markup as ranges over a persistent, editable sequence, with constructors, queries, layered documents, and JSON.
0.2.3 #
- Fixes for web compatibility and CI issues.
0.2.2 #
Document.having(key)andLayered.having(layer, key)find the ranges whose attributes say a key, in start order. A document made withDocument.of(items, indexed: ...)orLayered.of(items, grammar, indexed: ...)indexes those keys in every version, so finding one costs what the ranges found do; any other key is found by walking the ranges. A layer's diagnostics and the annotations over the layer below are not among a layer's ranges.
0.2.1 #
- Improve annotation performance by not scanning everything, every time.
0.2.0 #
Move(span, to)moves items, and the ranges wholly inside them, under their markers. A range crossing an edge of the span is decided by thecrossingpolicyDocument.applyandtransacttake:Crossing.clamp,follow, orrefuse, the default. The document logs the move with the decisions it made, so a replay and a JSON history make it the same way.Grammar.crossingis the policy a layered document passes; a layer-1 move moves the items of each layer above that lie wholly inside it. A replica refuses a move.transactlogs each move with its decisions, asapplydoes.- Mapping a position through a move, by
Document.mapor anchors, takes a position strictly inside the moved items along with them; a move to either edge of its items maps every position to itself. An empty range at the place a move puts items, its start right and its end left, reads as empty at its start, as an insertion leaves it; a move fails for a range turned inside out only wherefollowturns it. Grammarhasvalid, the change a text edit makes where it leaves the markup and its diagnostics as they stand, andescaped, how text is written as text alone. Both are new members, so every grammar must answer them. The library'skeptcarries out the check: a grammar'svalidcalls it, naming which of its ranges are text, and every range is markup by default. Markup and diagnostics are compared in order, by what each is and what lies under it, not counted.- The XML example reports a bare
&in text, one starting no reference, as a diagnostic, and its structural edits refuse to make or unmake one. Edit.annotation(layer, command)marks, updates, and unmarks annotations: ranges of the caller's own over a layer's items, which may cross elements, and which no grammar derives or sees. They move with their layer's items, a move that cuts one clamps it unless the move says otherwise,Layered.annotationsreads them, in time following how many there are rather than the layer's size, andLayered.gravitygives their gravities.AnnotationsFormatsaves a layered document's annotations as JSON, to keep beside the markupLayeredFormatsaves, andrestoremarks them again on the document decoded from that markup. An annotation over a layer above 1 is saved as indices into that layer.Changehas a third field,annotations, the annotations each layer created, removed, and updated. Code that destructures aChangewith a record pattern must name it.ARangeis abaseclass andARange.froma generative constructor, so a caller can extend it to say by a range's class what kind of thing it is. Equality is unchanged, and a document stores every range as a plainARange.
0.1.0 #
First release.
- Sequences:
Sequence,Items, andTextover Unicode code points, with the Core Range Algebra operations, andResultfor every operation that can fail. Slices hold unmodifiable copies. - Ranges:
Range,Ranges, the predicates, ordering, and containment structure, withRanges.childrenanswering from a hierarchy indexed once;ARangewith scalar attribute values. - Constructors:
regex,union,concat, andlayer. - Documents:
Document, a persistent sequence whose marked ranges move with every edit, with endpoint gravity,Insert,Delete,Replace,Mark,Unmark, andUpdatecommands,transact, coalesced edits,resolve,at,overlapping,within,crossing,map,markers, andcompact.editsgives the commands that turn one sequence into another, from a shortest edit script. - Formats: the
Formatinterface;JSONFormatto and from JSON, with optional history,restorereturning the loaded markers, andLimitsbounding what a decode may allocate; andtext, the item format for code points. - Layered documents:
Layered, layers 1 to n of ranges over ranges, each a persistentDocument, with a caller'sGrammarderiving them. Text edits derive the layers again over the affected region, reporting what does not parse as diagnostics; structural edits are carried out through the grammar'sDerivation;applyandtransactreturn aChange; andslice,within,crossing,span, andextentread one region.LayeredFormatreads and writes a layered document as its text. An XML grammar inexample/xml/shows one at work. - Selectors:
Selector, CSS-like queries over attributed ranges, with type, attribute, and structural selectors, the four combinators,:not,:is,:has,:overlaps, and:crosses, over any list of keyed ranges, aDocument, or one layer of aLayered. AScopeindexes its ranges once for many selections, andLayered.acrossprojects several layers' ranges to base positions so one selector relates them. - Replicas:
Replica, peer-to-peer replication of aDocumentwith no server. Eachcommitis anOperationstamped by a hybrid logical clock and naming its parents;receivemerges operations from any replica in any causal order, and replicas holding the same operations hold equal documents. Concurrent insertions do not interleave, updates are last writer wins by stamp, an unmark wins over a concurrent update, and stamps too far ahead of the local clock wait.sincegives what a peer lacks,Keynames a range on every replica, andOperationFormatcarries operations as JSON. - Coordinates:
Coordinatesconverts code-point positions to UTF-16 offsets (Unit) and to lines and columns (Place), columns in UTF-16 units, code points, or grapheme clusters, inO(log n)over anyDocument<int>version. Throughpackage:charactersit also finds grapheme cluster boundaries, counts clusters, and snaps ranges to them, andsnappedmakes a constructor's ranges whole clusters.