#wikidot #normal #nuscp

wikidot-normalize

Simple library to provide Wikidot-compatible string normalization

11 releases (6 breaking)

new 0.7.1 Feb 13, 2021
0.6.3 Feb 13, 2021
0.6.2 Dec 23, 2020
0.6.1 Nov 11, 2020
0.3.0 Oct 20, 2019

#2 in #wikidot

Download history 36/week @ 2020-10-28 66/week @ 2020-11-04 59/week @ 2020-11-11 55/week @ 2020-11-18 15/week @ 2020-11-25 21/week @ 2020-12-02 18/week @ 2020-12-09 4/week @ 2020-12-16 59/week @ 2020-12-23 127/week @ 2020-12-30 92/week @ 2021-01-06 189/week @ 2021-01-13 72/week @ 2021-01-20 54/week @ 2021-01-27 59/week @ 2021-02-03 166/week @ 2021-02-10

272 downloads per month
Used in 4 crates (3 directly)

MIT license

23KB
509 lines

wikidot-normalize

Rust CI badge docs.rs link

Simple library to provide Wikidot-compatible string normalization. It attempts to be a Rust port of the functionality in WDStringUtils::toUnixName.

Wikidot normal form is used in the site's page names. Essentially it ensures the following:

  • All ASCII is lowercase.
  • All characters outside of :, a-z, 0-9, or - are replaced with dashes.
  • Underscores are only permitted as the first character.
  • Any leading or trailing dashes are removed.
  • Any set of multiple dashes are replaced with a single dash.
  • Any set of multiple colons are replaced with a single colon.

Examples:

  • "Big Cheese Horace" -> "big-cheese-horace"
  • "bottom--Text" -> "bottom-text"
  • "Tufto's Proposal" -> "tufto-s-proposal"
  • "-test-" -> "test"

This library is getting close to finalization with a v1.0.0 release.

Available under the terms of the MIT License. See LICENSE.md.

Compilation

This library targets the latest stable Rust. At time of writing, that is 1.49.0

$ cargo build --release

Testing

$ cargo test

Add -- --nocapture to the end if you want to see test output.

Dependencies

~1–1.4MB
~40K SLoC