<commit_before># richtextpy

An [operational transformation](https://en.wikipedia.org/wiki/Operational_transformation) library for rich text documents. It enables optimistic conflict-free collaborative editing scenarios (like [Google Docs](http://docs.google.com)) by providing a rich text document format as well as **compose()** and **transform()** methods for managing changes according to the [OT](https://en.wikipedia.org/wiki/Operational_transformation) algorithm.

This is a Python version of the [Javascript Rich Text](https://github.com/ottypes/rich-text) ottype.

To fully support collaborative editing, you'll also need a rich text editor that produces Delta objects on user changes as well as a server that implements the full [OT](https://en.wikipedia.org/wiki/Operational_transformation) collaboration protocol. See the references for details on the protocol and some libraries that provide these additional capabilities.

## Example

```python
from richtextpy import Delta

delta = Delta([
  {'insert': 'The quick '},
  {'insert': 'brown', 'attributes': {'color': 'brown'}},
  {'insert': ' fox'}
])

# keep the first 10 characters, delete the next 5, and insert a red 'red'
change = Delta().retain(10).delete(5).insert('red', {'color': 'red'})

"""
this produces:

[
	{'retain': 10},
	{'delete': 5},
	{'insert': 'red', 'attributes': {'color': 'red'}},
]
"""

composed = delta.compose(change)

"""
composed is now:

[
  {'insert': 'The quick '},
  {'insert': 'red', 'attributes': {'color': 'red'}},
  {'insert': ' fox'}
]
"""
```

## Installation
```
(install from Pypi)

pip install richtextpy

OR

(install from GitHub source download)

python setup.py install
```
<commit_msg>readme updates<commit_after># richtextpy

An [operational transformation](https://en.wikipedia.org/wiki/Operational_transformation) library for rich text documents. It enables optimistic conflict-free collaborative editing scenarios (like [Google Docs](http://docs.google.com)) by providing a rich text document format as well as **compose()** and **transform()** methods for managing changes according to the [OT](https://en.wikipedia.org/wiki/Operational_transformation) algorithm.

This is a Python version of the [Javascript Rich Text](https://github.com/ottypes/rich-text) ottype.

To fully support collaborative editing, you'll also need a rich text editor that produces Delta objects on user changes as well as a server that implements the full [OT](https://en.wikipedia.org/wiki/Operational_transformation) collaboration protocol. See the references for details on the protocol and some libraries that provide these additional capabilities.

## Example

```python
from richtextpy import Delta

delta = Delta([
  {'insert': 'The quick '},
  {'insert': 'brown', 'attributes': {'color': 'brown'}},
  {'insert': ' fox'}
])

# keep the first 10 characters, delete the next 5, and insert a red 'red'
change = Delta().retain(10).delete(5).insert('red', {'color': 'red'})

"""
change is:

[
	{'retain': 10},
	{'delete': 5},
	{'insert': 'red', 'attributes': {'color': 'red'}},
]
"""

composed = delta.compose(change)

"""
composed is:

[
  {'insert': 'The quick '},
  {'insert': 'red', 'attributes': {'color': 'red'}},
  {'insert': ' fox'}
]
"""
```

## Installation
```
(install from Pypi)

pip install richtextpy

OR

(install from GitHub source download)

python setup.py install
```

{'fraction_non_alphanumeric': 0.1497484462858834, 'fraction_numerical': 0.005327019828351583, 'mean_word_length': 5.224677716390423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '436765', 'n_tokens_mistral': 1008, 'n_tokens_neox': 961, 'n_words': 356}