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 crate::utils::{
|
||||
self,
|
||||
self, capitalize,
|
||||
models::{Position, TabChar},
|
||||
};
|
||||
|
||||
|
@ -85,12 +85,14 @@ pub async fn timetable(
|
|||
}
|
||||
None => None,
|
||||
},
|
||||
room: course
|
||||
.select(&sel_strong)
|
||||
.next()
|
||||
.unwrap()
|
||||
.inner_html()
|
||||
.replace("<br>", ""),
|
||||
room: capitalize(
|
||||
&mut course
|
||||
.select(&sel_strong)
|
||||
.next()
|
||||
.unwrap()
|
||||
.inner_html()
|
||||
.replace("<br>", ""),
|
||||
),
|
||||
start: location_tracker,
|
||||
size: match course.value().attr("colspan") {
|
||||
Some(i) => i.parse().unwrap(),
|
||||
|
|
11
src/utils.rs
11
src/utils.rs
|
@ -75,7 +75,7 @@ pub fn line_table(
|
|||
Some(text) => {
|
||||
println!("{:^cell_length$}{}", text, rsbc_bbc);
|
||||
last_day = true;
|
||||
},
|
||||
}
|
||||
None => (),
|
||||
}
|
||||
} else {
|
||||
|
@ -114,3 +114,12 @@ pub fn split_half(text: &str) -> (&str, &str) {
|
|||
pub fn etc_str(text: &str) -> String {
|
||||
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