#links #markdown #markdown-text #unicode #paragraph #line #breaking

md-ulb-pwrap

Markdown paragraph wrapper using Unicode Line Breaking Algorithm

6 releases

0.1.2 Aug 1, 2024
0.1.1 May 28, 2024
0.1.0 Aug 10, 2023
0.0.3 Feb 19, 2023

#444 in Text processing

Download history 132/week @ 2024-07-29 1/week @ 2024-08-05 11/week @ 2024-09-16 9/week @ 2024-09-23 4/week @ 2024-09-30

348 downloads per month

BSD-3-Clause

22KB
551 lines

md-ulb-pwrap

Crate PyPI

Markdown paragraph wrapper using Unicode Line Breaking Algorithm.

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.

Usage

cargo add md-ulb-pwrap
use md_ulb_pwrap::ulb_wrap_paragraph;

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

Reference

ulb_wrap_paragraph(text: &str, width: usize, first_line_width: usize) -> String

  • text (&str): The text to wrap.
  • width (usize): The maximum width of the lines after the first.
  • first_line_width (usize): The maximum width of the first line.

Returns (String): The wrapped text.

Dependencies

~78KB