Skip to main content

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.md for rules and future implementation details
  • Status: baseline working — headings + inline styles (bold/italic/strikethrough/monospace)
  • Parser: markdown-it
  • Python: optional pyo3 bindings behind python feature

Quick Start (Rust)

  • Call render(&str) -> Rendered to get:
    • Rendered.text: String — final message text (headings converted to hN ...).
    • 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 with signal-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 via pyo3 (module scaffolding pending). Build with:
    • cargo build --features python
    • Or install the Python extension via maturin:
      • pip install maturin (once)
      • maturin develop -F python (installs markdownish into your current venv)

Python usage

After maturin develop -F python, try:

  • python scripts/render.py "# **Hello** _world_ and **b** *i*"
    • Outputs JSON with text and textStyles (array of "<start>:<len>:<KIND>").
  • python scripts/repl.py
    • Interactive: type lines, then :go to render current buffer.

Python API (high level):

  • import markdownish; markdownish.render(text: str) -> dict with keys:
    • text: str — final message string
    • textStyles: 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)

Source distribution for markdownish 0.1.2
File Size Uploaded
markdownish-0.1.2.tar.gz 21.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for markdownish 0.1.2
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page