wordcount
This commit is contained in:
1 parent
1c3f3797da
commit
0a65ed38fc
9 files changed
+2178
-10
No files matched your search
+2
-5
@@ -1,5 +1,2 @@
|
||||
book
|
||||
|
||||
# Added by cargo
|
||||
|
||||
/target
|
||||
**/target
|
||||
**/book
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "bleak"
|
||||
version = "0.1.0"
|
||||
@@ -1,8 +1,11 @@
|
||||
[book]
|
||||
title = "bleak"
|
||||
authors = ["Nathan Rashleigh"]
|
||||
authors = ["ntwl"]
|
||||
language = "en"
|
||||
|
||||
[output.wordcount]
|
||||
|
||||
[output.html]
|
||||
default-theme = "gruvbox"
|
||||
preferred-dark-theme = "gruvbox"
|
||||
|
||||
Generated
+2108
File diff suppressed because it is too large.
Load diff
@@ -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"
|
||||
@@ -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()
|
||||
}
|
||||
@@ -7,6 +7,7 @@ default:
|
||||
|
||||
# Build the book into ./book
|
||||
build:
|
||||
cargo install --path crates/mdbook-wordcount
|
||||
mdbook build
|
||||
|
||||
# Serve the book with live reload and open it in a browser
|
||||
|
||||
+7
-3
@@ -46,17 +46,21 @@ It took two attempts - better than the average of 2.45 - to correctly enter the
|
||||
Y,Sy-W$Cx;s%p]~9FL!r`:(
|
||||
```
|
||||
|
||||
A failed attempt meant a five second wait until trying again.
|
||||
The failed attempt had meant a ten second wait spent staring blankly at the screen before being able to again.
|
||||
A message flashed on
|
||||
|
||||
> [!WARNING]
|
||||
> Mandatory Software Update Required
|
||||
>
|
||||
> ...
|
||||
>
|
||||
> Restarting now.
|
||||
|
||||
After another three cycles he logged in once again, this time on the third try, and prepared to join the report.
|
||||
|
||||
>[!INFO]
|
||||
> [!NOTE]
|
||||
>The Morning Report has already commenced.
|
||||
>
|
||||
>A notification of your request to enter has been sent to the already present attendees.
|
||||
|
||||
He sighed and waited for somebody to accept the request.
|
||||
@@ -77,7 +81,7 @@ All manner of domestic noise carried on in the background until the attendees gr
|
||||
|
||||
The attendees numbered between 6 and 10 on any given day. Those present were constantly being rotated in and out. Cameras of questionable quality or cleanliness, as well as outright missing faces, made it difficult to form any kind of attachment with the names. He often resorted to associating a general feeling and sense of the person with the colour of the small panel bearing their name on the list of people connected. Last week a _sugary female voice eminating in time with the glowing of a dark green panel_ had connected for four days before it was absent the next day, replaced by three elderly and bespectacled strangers.
|
||||
|
||||
Despite this, almost everybody on the call seemed to know one another if not personally then at least as a professional acquaintance of some time; the report usually consisted of gossip and rumours being exchanged until **the manager** would come online and interrupt the conversation to make some announcement.
|
||||
Despite this, almost everybody on the call seemed to know one another if not personally then at least as a professional acquaintance of some time; the report was usually an exchange of gossip and rumours until **the manager** would come online and interrupt the conversation to make some announcement.
|
||||
|
||||
> good morning all, i'm pleased to announce the business has presented us with a tremendous new opportunity to start off our week:
|
||||
> in addition to some generalised high level downward economic pressures across the sector, a recent media cycle promoting negative sentiment for units of varying sizes has lead to an updated downgraded prediction of quarterly sales targets as well as an accelerated slowdown of advertising resource earning potential resulting from of an increased reduction in tolerance for inconsistency of size between individual units within a packet.
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
# Chapter 1
|
||||
Reference in new issue
Block a user