https://github.com/scpwiki/wikidot-normalize
Simple library to provide Wikidot-compatible string normalization.
https://github.com/scpwiki/wikidot-normalize
library normalize nuscp rust scp-foundation wikidot
Last synced: 9 months ago
JSON representation
Simple library to provide Wikidot-compatible string normalization.
- Host: GitHub
- URL: https://github.com/scpwiki/wikidot-normalize
- Owner: scpwiki
- License: mit
- Created: 2019-09-30T01:36:39.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-09-29T21:38:40.000Z (over 2 years ago)
- Last Synced: 2025-03-25T21:13:36.244Z (10 months ago)
- Topics: library, normalize, nuscp, rust, scp-foundation, wikidot
- Language: Rust
- Homepage:
- Size: 74.2 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## wikidot-normalize
Simple library to provide Wikidot-compatible string normalization. It is a Rust port of the functionality in [`WDStringUtils::toUnixName`](https://github.com/scpwiki/wikijump/blob/legacy-php/web/php/Utils/WDStringUtils.php).
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](LICENSE).
### Compilation
This library targets the latest stable Rust. At time of writing, that is 1.68.2
```sh
$ cargo build --release
```
### Testing
```sh
$ cargo test
```
Add `-- --nocapture` to the end if you want to see test output.