Compare commits

...

3 Commits

7
Cargo.lock generated

@ -514,6 +514,7 @@ dependencies = [
"rusqlite", "rusqlite",
"serde", "serde",
"serde_json", "serde_json",
"unidecode",
"uuid 1.3.0", "uuid 1.3.0",
] ]
@ -2397,6 +2398,12 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
[[package]]
name = "unidecode"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "402bb19d8e03f1d1a7450e2bd613980869438e0666331be3e073089124aa1adc"
[[package]] [[package]]
name = "universal-hash" name = "universal-hash"
version = "0.5.0" version = "0.5.0"

@ -31,3 +31,4 @@ rusqlite = {version = "0.28.0", features=["bundled", "chrono"]}
lazy_static = "1.4.0" lazy_static = "1.4.0"
mongodb = "2.3.1" mongodb = "2.3.1"
unidecode = "0.3.0"

@ -1,6 +1,26 @@
use clap::Parser; use clap::Parser;
use r2d2::Pool; use r2d2::Pool;
use r2d2_sqlite::SqliteConnectionManager; use r2d2_sqlite::SqliteConnectionManager;
use regex::Regex;
use unidecode::unidecode;
pub trait NormalizeName {
fn normalize_name(&self) -> String;
}
impl NormalizeName for String {
fn normalize_name(&self) -> String {
let space_re = Regex::new(r"[\s_]+").unwrap();
let remove_re = Regex::new(r"[^a-z0-9_]").unwrap();
let mut str = unidecode(self);
str = space_re.replace_all(&str, "_").to_string();
remove_re.replace_all(&str, "").to_string().to_lowercase()
}
}
#[derive(Parser)] #[derive(Parser)]
pub struct Arguments { pub struct Arguments {
@ -19,12 +39,10 @@ pub struct Arguments {
} }
impl Arguments { impl Arguments {
pub fn parse_args() -> Arguments { pub fn parse_args() -> Arguments {
let args = Arguments::parse(); let args = Arguments::parse();
args args
} }
} }
#[derive(Clone)] #[derive(Clone)]

@ -4,7 +4,7 @@
font-weight: 400; font-weight: 400;
src: local('Material Icons'), src: local('Material Icons'),
local('MaterialIcons-Regular'), local('MaterialIcons-Regular'),
url(/static/MaterialIconsOutlined-Regular.otf) format('woff'); url(MaterialIconsOutlined-Regular.otf) format('woff');
} }
.material-icons { .material-icons {

@ -1,4 +1,5 @@
import { saveSelection, loadSelection } from "./caret.js"; import { saveSelection, loadSelection } from "./caret.js";
import { normalizePagename } from "./tools.js";
function setEditable() { function setEditable() {
let editModeButton = document.getElementById('editModeButton'); let editModeButton = document.getElementById('editModeButton');

@ -0,0 +1,6 @@
function normalizeName(pagename) {
return str.normalize("NFKD").replace(/\p{Diacritic}/gu, "").toLowerCase().replace(/œ/g, "oe").replace(/æ/g, "ae").replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, "").replace(/_+/g, "_");
}
export { normalizeName };
Loading…
Cancel
Save