big file storage

This commit is contained in:
Nathan Rashleigh committed 2026-09-18 23:22:55 +10:00
1 parent 91fe0211d4
commit 9b11a4ded6
1265 files changed
+149378 -60

No files matched your search

File diff suppressed because it is too large. Load diff
+13
View File
@@ -0,0 +1,13 @@
[package]
name = "mdbook-wordcount"
version = "1.0.2"
edition = "2021"
description = "A word-count renderer for mdBook, rebuilt against mdbook 0.5"
license = "MIT"
[[bin]]
name = "mdbook-wordcount"
path = "src/main.rs"
[dependencies]
mdbook-renderer = "0.5"
+36
View File
@@ -0,0 +1,36 @@
// mdbook-wordcount, rebuilt against mdbook 0.5.
//
// Iterates every chapter, counts whitespace-separated words, and prints
// per-chapter counts plus a grand total to stdout.
//
// The only reason this exists separately is that the crates.io release is
// compiled against mdbook 0.4, whose RenderContext JSON schema differs from
// 0.5 ("missing field `sections`"). See rust-lang.github.io/mdBook backends.
use mdbook_renderer::book::{BookItem, Chapter};
use mdbook_renderer::RenderContext;
use std::io;
fn main() {
let mut stdin = io::stdin();
let ctx = RenderContext::from_json(&mut stdin).expect("couldn't parse RenderContext");
println!("\n----------");
println!("Word Count");
let mut total = 0;
for item in ctx.book.iter() {
if let BookItem::Chapter(ref ch) = *item {
let words = count_words(ch);
total += words;
println!("{}: {}", ch.name, words);
}
}
println!("Total: {}", total);
println!("----------");
}
fn count_words(ch: &Chapter) -> usize {
ch.content.split_whitespace().count()
}