forked from Anri/cal8tor
capitalize room name
This commit is contained in:
parent
20fd40bbba
commit
cdec3c6309
2 changed files with 19 additions and 8 deletions
|
@ -4,7 +4,7 @@ use scraper::{Html, Selector};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
self,
|
self, capitalize,
|
||||||
models::{Position, TabChar},
|
models::{Position, TabChar},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -85,12 +85,14 @@ pub async fn timetable(
|
||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
},
|
},
|
||||||
room: course
|
room: capitalize(
|
||||||
|
&mut course
|
||||||
.select(&sel_strong)
|
.select(&sel_strong)
|
||||||
.next()
|
.next()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.inner_html()
|
.inner_html()
|
||||||
.replace("<br>", ""),
|
.replace("<br>", ""),
|
||||||
|
),
|
||||||
start: location_tracker,
|
start: location_tracker,
|
||||||
size: match course.value().attr("colspan") {
|
size: match course.value().attr("colspan") {
|
||||||
Some(i) => i.parse().unwrap(),
|
Some(i) => i.parse().unwrap(),
|
||||||
|
|
11
src/utils.rs
11
src/utils.rs
|
@ -75,7 +75,7 @@ pub fn line_table(
|
||||||
Some(text) => {
|
Some(text) => {
|
||||||
println!("{:^cell_length$}{}", text, rsbc_bbc);
|
println!("{:^cell_length$}{}", text, rsbc_bbc);
|
||||||
last_day = true;
|
last_day = true;
|
||||||
},
|
}
|
||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -114,3 +114,12 @@ pub fn split_half(text: &str) -> (&str, &str) {
|
||||||
pub fn etc_str(text: &str) -> String {
|
pub fn etc_str(text: &str) -> String {
|
||||||
format!("{}...", split_half(text).0.trim())
|
format!("{}...", split_half(text).0.trim())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Capitalize string
|
||||||
|
pub fn capitalize(text: &mut str) -> String {
|
||||||
|
if let Some(r) = text.get_mut(0..1) {
|
||||||
|
r.make_ascii_uppercase();
|
||||||
|
}
|
||||||
|
|
||||||
|
text.to_string()
|
||||||
|
}
|
||||||
|
|
Reference in a new issue