md-ulb-pwrap

Crates.iomd-ulb-pwrap
lib.rsmd-ulb-pwrap
version0.1.2
sourcesrc
created_at2023-02-16 18:23:39.094557
updated_at2024-08-01 12:36:42.995656
descriptionMarkdown paragraph wrapper using Unicode Line Breaking Algorithm.
homepage
repository
max_upload_size
id786961
size21,839
Álvaro Mondéjar Rubio (mondeja)

documentation

README

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.

Commit count: 0

cargo fmt