#wikidot #normal #nuscp

wikidot-normalize

Simple library to provide Wikidot-compatible string normalization

17 releases (9 breaking)

0.10.0 May 11, 2022
0.9.2 Sep 9, 2021
0.8.1 Apr 26, 2021
0.8.0 Mar 31, 2021
0.3.0 Oct 20, 2019

#342 in Text processing

Download history 161/week @ 2022-11-25 54/week @ 2022-12-02 82/week @ 2022-12-09 39/week @ 2022-12-16 31/week @ 2022-12-23 22/week @ 2022-12-30 28/week @ 2023-01-06 23/week @ 2023-01-13 47/week @ 2023-01-20 24/week @ 2023-01-27 34/week @ 2023-02-03 89/week @ 2023-02-10 88/week @ 2023-02-17 33/week @ 2023-02-24 99/week @ 2023-03-03 164/week @ 2023-03-10

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

MIT license

19KB
306 lines

wikidot-normalize

Rust CI badge docs.rs link

Simple library to provide Wikidot-compatible string normalization. It is 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.57.0

$ cargo build --release

Testing

$ cargo test

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

Dependencies

~1.5–2.1MB
~78K SLoC