Skip to main content

url_slug

Function url_slug 

pub(crate) fn url_slug(tail: &str) -> &str
Expand description

The URL path characters following a site or repository prefix, up to whatever ends the link.

A Markdown inline link’s target ends at ); the other delimiters are here so that the rejected spellings — an autolink’s >, a code span’s backtick, bare prose’s whitespace — are quoted correctly in the failure message rather than swallowing the rest of the paragraph.

A . cannot be a delimiter, and a trailing one cannot be part of the path. Inside a path it belongs there — concepts/storage.md in the repository form, trait.Storage.html in the rustdoc tree — while a . after the path is the full stop of the sentence that quoted it. So the scan stops only at characters that can do nothing but delimit, and sentence punctuation is trimmed from the end afterwards. Without the trim a bare citation ending a sentence resolved to a page named storage/., which check-guide-links then reported as missing: a red on a citation that is correct, and the worst kind, because the obvious repair is to break the link (§1.3.152).

Shared with check_guide_links deliberately. The two had drifted to different delimiter sets — one stopped at , and the other did not — so the same line meant different things to the rewrite and to the checker that verifies the rewrite, which is the one pair of functions in the tree that must agree.