From 22bd3b7e415c5a33e8101bc38acaaab22de5b316 Mon Sep 17 00:00:00 2001
From: Alex Auvolat
Date: Mon, 18 Sep 2023 18:56:51 +0200
Subject: change characters appearance
---
src/main.rs | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
(limited to 'src')
diff --git a/src/main.rs b/src/main.rs
index d0f896d..837b7ff 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -76,6 +76,10 @@ fn main() {
.map_err(anyhow::Error::from)
.and_then(|x| Ok(serde_json::from_slice::>(&x)?))
.expect("read/parse");
+
+ fs::create_dir_all("public").expect("mkdir public");
+ fs::copy("static/style.css", "public/style.css").expect("copy style.css");
+
batches.iter()
.enumerate()
.for_each(|x| format_batch(&jmdict_idx, batches.len(), x));
@@ -343,7 +347,7 @@ fn format_batch<'a>(dict_idx: &DictIndex<'a>, count: usize, (i, batch): (usize,
}
fn format_batch_aux<'a>(dict_idx: &DictIndex<'a>, count: usize, i: usize, batch: &Batch) -> Result<()> {
- let mut f = io::BufWriter::new(fs::File::create(format!("html/{:03}.html", i))?);
+ let mut f = io::BufWriter::new(fs::File::create(format!("public/{:03}.html", i))?);
write!(f, r#"
@@ -363,7 +367,8 @@ fn format_batch_aux<'a>(dict_idx: &DictIndex<'a>, count: usize, i: usize, batch:
}
writeln!(f, r#"
"#)?;
writeln!(f, "Level: {}
", batch.level)?;
- writeln!(f, "Characters: {}
", batch.chars.to_string())?;
+
+ writeln!(f, r#"【{}】
"#, batch.chars.to_string())?;
for ex in batch.examples.iter() {
writeln!(f, "
")?;
@@ -461,7 +466,7 @@ fn dict_str<'a>(qkeb: &str, qreb: Option<&str>, ent: &roxmltree::Node<'a, 'a>) -
}
fn format_index(batches: &[Batch], kanji_levels: &[(String, String)]) -> Result<()> {
- let mut f = io::BufWriter::new(fs::File::create("html/index.html")?);
+ let mut f = io::BufWriter::new(fs::File::create("public/index.html")?);
write!(f, r#"
--
cgit v1.2.3