1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * lib.rs
 *
 * wikidot-normalize - Library to provide Wikidot-compatible normalization.
 * Copyright (c) 2019 Ammon Smith
 *
 * wikidot-normalize is available free of charge under the terms of the MIT
 * License. You are free to redistribute and/or modify it under those
 * terms. It is distributed in the hopes that it will be useful, but
 * WITHOUT ANY WARRANTY. See the LICENSE file for more details.
 *
 */

#![deny(missing_debug_implementations, missing_docs)]

//! A library to provide Wikidot-compatible string normalization.
//!
//! Wikidot ensures all names of pages subscribe to a particular pattern.
//! Essentially, only the characters `_`, `:`, `a-z`, `0-9`, and `-` can be outputted.
//! Any uppercase ASCII characters are made lowercase, and any characters outside
//! the above set are collapsed into dashes. Finally, any leading, trailing, or
//! multiple dashes are trimmed.

#[macro_use]
extern crate lazy_static;

#[macro_use]
extern crate log;
extern crate percent_encoding;
extern crate regex;

#[cfg(test)]
#[macro_use]
extern crate str_macro;

mod normal;

#[cfg(test)]
mod test;

pub use self::normal::{is_normal, normalize, normalize_decode};

/// A "prelude" for consumers of the `wikidot-normalize` crate.
///
/// This prelude includes all exports from the crate, and is provided
/// for convenience without requiring programs to do a glob import of
/// the whole crate.
pub mod prelude {
    pub use super::normal::{is_normal, normalize, normalize_decode};
}