Skip to main content

Module wrap

Module wrap 

Source
Expand description

The wrap check: hygiene wrap [DIR] fails when a prose line of a Markdown file in DIR is longer than 72 characters.

§Design

Each page of the book and the requirements wraps at WIDTH (01M3MNT28NXA9VRST119QR8AQK). just wrap runs hygiene wrap docs/src, and just ci runs it for each diff, also for a diff of only text (01M3WNN836EFG7GJQKZRTSK5FT). So the check is not a test of a crate: a change of the book needs no build of riff.

The rule wrap finds only a line that a wrap can make shorter. It skips:

  • a line in a code block, a row of a table, and a heading;
  • a line with one word after its list marker. A link and a code span are each one word, also with the text that follows them with no space.
let prose = "word ".repeat(15);
let errors = hygiene::wrap::check("a.md", &prose);
assert_eq!(errors.len(), 1);
assert_eq!(errors[0].rule, "wrap");
assert!(errors[0].text.starts_with("a.md:1: the line has 75 characters"));

let link = format!("- [{}](page.md#part).", "a b ".repeat(20));
assert!(hygiene::wrap::check("a.md", &link).is_empty());

Constants§

WIDTH
The wrap width of the book.

Functions§

check
The errors of the Markdown file name with the content text: one for each line of long_lines.
long_lines
The lines of text that are over WIDTH and that a wrap can make shorter: prose outside a code block, a table and a heading. Each line comes with its number, from 1.