From fff245eaa5db1289a652da41ff7826bd368d7180 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 26 Sep 2023 13:12:26 +0200 Subject: add readme to site; style for batches; order kanji like in sentences --- src/main.rs | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 69e5d6f..06c0a07 100644 --- a/src/main.rs +++ b/src/main.rs @@ -160,6 +160,7 @@ fn main() { let kanji_levels = read_kanji_levels().expect("read_kanji_levels"); format_index(&batches, &kanji_levels).expect("format_index"); + format_about().expect("format_about"); } } } @@ -966,7 +967,7 @@ fn format_batch_aux<'a>( Batch #{:03} - "#, +
"#, i )?; @@ -981,11 +982,20 @@ fn format_batch_aux<'a>( writeln!(f, r#"

"#)?; writeln!(f, "

Level: {}

", batch.level)?; - writeln!( - f, - r#"

【{}】

"#, - batch.chars.to_string() - )?; + write!(f, r#"

"#)?; + let mut ex_prev = Charset::default(); + for ex in batch.examples.iter() { + let ex_chars = ex.chars.inter(&batch.chars); + for c in ex_chars.diff(&ex_prev).chars().iter() { + write!( + f, + r#"{}"#, + c, c + )?; + } + ex_prev = ex_prev.union(&ex_chars); + } + writeln!(f, r#"

"#)?; for ex in batch.examples.iter() { writeln!(f, "
")?; @@ -1079,7 +1089,7 @@ fn format_batch_aux<'a>( writeln!(f, "
")?; writeln!(f, "

\(≧▽≦)/

")?; - write!(f, "")?; + write!(f, "
")?; f.flush()?; Ok(()) } @@ -1135,6 +1145,8 @@ fn format_index(batches: &[Batch], kanji_levels: &[(String, String)]) -> Result< "# )?; + writeln!(f, r#"

About / How-to


"#)?; + writeln!(f, "")?; writeln!(f, "")?; for (i, batch) in batches.iter().enumerate() { @@ -1188,3 +1200,27 @@ fn format_index(batches: &[Batch], kanji_levels: &[(String, String)]) -> Result< f.flush()?; Ok(()) } + +fn format_about() -> Result<()> { + let mut f = io::BufWriter::new(fs::File::create("public/about.html")?); + write!( + f, + r#" + + + + Datagengo README + + + "# + )?; + + writeln!(f, r#"
"#)?; + writeln!(f, r#"

Back to lessons


"#)?; + + writeln!(f, "{}", markdown::to_html(&fs::read_to_string("README.md")?))?; + + writeln!(f, r#"
"#)?; + + Ok(()) +} -- cgit v1.2.3
NumLevelCharsExamplesB-1B-2Ignore