markdownish
Rust library to render Markdown-ish input into a Signal-friendly plain text message and text style ranges suitable for use with signal-cli.
- Spec: see
spec.mdfor rules and future implementation details - Status: baseline working — headings + inline styles (bold/italic/strikethrough/monospace)
- Parser:
markdown-it - Python: optional
pyo3bindings behindpythonfeature
Quick Start (Rust)
- Call
render(&str) -> Renderedto get:Rendered.text: String— final message text (headings converted tohN ...).Rendered.styles: Vec<TextStyle>— style spans with UTF‑16 offsets.- Encode spans for transport if needed with
encode_text_styles(&rendered.styles)→["<start>:<len>:<KIND>", ...](format usable withsignal-cli).
Example
use markdownish::{render, Style, TextStyle, encode_text_styles};
let rendered = render("# **Hello** _world_\n\nHello **bold** and *it*.");
// rendered.text => "h1 Hello world\n\nHello bold and it."
// rendered.styles => spans for bold/italic in the paragraph (none inside headings)
let encoded = encode_text_styles(&rendered.styles);
println!("{}", rendered.text);
println!("{:?}", encoded);
What gets translated (high level)
- Headings: ATX/Setext →
hN <raw text>plus a blank line after. Inline styles inside headings are not emitted. - Bold/Italic:
**text**/__text__,*text*/_text_→ spans over the inner text. - Paragraphs/Breaks: paragraphs separated by a blank line; soft/hard breaks →
\n. - Newlines: input CR/CRLF normalized to
\n.
Features
python: enables optional Python bindings viapyo3(module scaffolding pending). Build with:cargo build --features python- Or install the Python extension via
maturin:pip install maturin(once)maturin develop -F python(installsmarkdownishinto your current venv)
Python usage
After maturin develop -F python, try:
python scripts/render.py "# **Hello** _world_ and **b** *i*"- Outputs JSON with
textandtextStyles(array of"<start>:<len>:<KIND>").
- Outputs JSON with
python scripts/repl.py- Interactive: type lines, then
:goto render current buffer.
- Interactive: type lines, then
Python API (high level):
import markdownish; markdownish.render(text: str) -> dictwith keys:text: str— final message stringtextStyles: list[str]— array of"<start>:<len>:<KIND>"
Docs
- Generate Rust docs:
cargo doc --open
Release files for markdownish 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| markdownish-0.1.2.tar.gz | 21.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| markdownish-0.1.2-cp313-cp313-manylinux_2_34_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.34+ x86-64 | Details |
Total release size: 1.0 MB
Release files / markdownish-0.1.2.tar.gz
| Download URL | markdownish-0.1.2.tar.gz |
|---|---|
| Size | 21.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc4867ae6786475475e5ad14c8ef0435088c3bd73966777123d11c7eed0cfd46
|
|
BLAKE2b-256 checksum How to use checksums |
40a01d8932794ff8009945bcd921199ea8bfd111dc7073316834815ab49ba4ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.3
|
Release files / markdownish-0.1.2-cp313-cp313-manylinux_2_34_x86_64.whl
| Download URL | markdownish-0.1.2-cp313-cp313-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.13 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
31992cca503e0654dbe5cab56736bfeeb8e4d38fdce126410ef1c75053d41fca
|
|
BLAKE2b-256 checksum How to use checksums |
66cd62f8a3dff09194748ef6fca47df765ff24b6d8990f972c3d03eb6560acd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.3
|