md-ulb-pwrap

Crate PyPI

Markdown paragraph wrapper using [Unicode Line Breaking Algorithm]. Includes a Rust library with Python bindings.

Wrap a Markdown paragraph using a maximum desired width. Only works for paragraphs that don't contain other [container blocks]. Respects the prohibition against wrapping text inside inline code blocks and links.

Rust library

bash cargo add md-ulb-pwrap

````rust use mdulbpwrap::ulbwrapparagraph;

asserteq!( ulbwrap_paragraph( &"aaa `` ` a b c ccc", 3, 3, ), "aaa\n`` ` a b c\nccc", ); ````

Python bindings

bash pip install md-ulb-pwrap

````python from mdulbpwrap import ulbwrapparagraph

markdown = "aaa `` ` a b c ccc" expectedresult = "aaa\n`` ` a b c\nccc" assert ulbwrapparagraph(markdown, 3, 3) == expectedresult ````

Reference

ulbwrapparagraph(text: str, width: int, firstlinewidth: int) -> str

Returns (str): The wrapped text.