Metadata-Version: 2.4
Name: uniscript-py
Version: 1.0.0
Summary: Uniscript (<:alpha> → α, <:fracture A> → 𝔄 and back) in pure Python, reading the shared entity index in place
License-Expression: MIT
Project-URL: Homepage, https://pannous.com/uniscript/
Project-URL: Repository, https://github.com/pannous/uniscript
Keywords: unicode,uniscript,entities,text,ascii
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Text Processing
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# uniscript (pure Python)

The uniscript converter in pure Python without dependencies, a port of the Rust reference (`src/lib.rs`). It reads
`data/entities.idx` (bundled as `uniscript/entities.idx`) in place through `mmap`. Same API as the FFI package in
`python/ffi` (`uniscript-rs`), so either one is a drop-in replacement for the other.

```sh
pip install uniscript-py     # imported as `import uniscript`
```

```python
import uniscript
uniscript.to_unicode("<:alpha> <:fracture A>")               # 'α 𝔄'; lenient: warnings go to stderr
uniscript.to_uniscript("α 𝔄")                                # '<:alpha> <:fracture A>'
uniscript.convert("<:greek c>")                              # ('c', [Warning(message='no greek form of c', at=0)])
uniscript.convert("<:nosuch>", uniscript.WarningMode.WARN)   # raises UnknownEntity; ERROR raises Unsupported on warnings
converter = uniscript.Uniscript()
styled, warnings = converter.meta_runs(uniscript.to_unicode("<:color red A>"))
converter.html(styled)                                       # '<span style="color: red">A</span>'
```

Offsets (`Warning.at`, `Header.length`, `MetaRun.start/end/at`) are UTF-8 byte offsets, as in Rust and Swift.
`python3 -m uniscript` is the command line of the Rust crate (`-r`, `--strict`, `--lenient`, `--html`).

Tests: `PYTHONPATH=. python3 -m pytest tests` (in `python/native`). `tests/test_reference.py` compares with the Rust
binary at `/opt/cargo/release/uniscript` (`CARGO_TARGET_DIR=/opt/cargo cargo build --release`), skipped without it.
