diff options
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -54,14 +54,16 @@ async fn fetch(req: Request, env: Env, _ctx: Context) -> Result<Response> { pre { @for x in a.split('\n').map(|l| { let l = l.trim(); - if let Some(c) = re.captures(l) { + re.captures(l) + .map_or_else(|| html! { (PreEscaped(l)) "\n" }, + |c| { let (m, d, y) = (c.get(1), c.get(2), c.get(3)); let f = |x: Option<regex::Match>| x.unwrap().as_str().parse().unwrap(); let (y, m, d): (usize, usize, usize) = (f(y) + 2000, f(m), f(d)); let s = solar(y, m, d); let (dowc, dowl) = dow(y, m, d); let (y, m, d, t) = (s.year, s.month, s.day, s.term); - let href = l.replace("/", "_"); + let href = l.replace('/', "_"); html! { (PreEscaped("</pre>")) a name=(href) { } @@ -73,9 +75,7 @@ async fn fetch(req: Request, env: Env, _ctx: Context) -> Result<Response> { } (PreEscaped("<pre>")) } - } else { - html! { (PreEscaped(l)) "\n" } - } + }) }) { (x) } @@ -112,7 +112,7 @@ async fn fetch(req: Request, env: Env, _ctx: Context) -> Result<Response> { } fn header() -> Markup { - let css = r#"/* i dont know css im so fucking sorry ill fix it l8r */ + let css = r"/* i dont know css im so fucking sorry ill fix it l8r */ pre { white-space: pre-wrap; white-space: -moz-pre-wrap; @@ -198,7 +198,7 @@ body { max-width: 960px; margin-left: auto; margin-right: auto; -}"#; +}"; html! { (DOCTYPE) style { (PreEscaped(css)) } |
