Wardian docs

Text tools

Try it

The app runs here in your browser. Nothing you type leaves it. Open it on its own.

Download text-tools.wardian Import it in Wardian: Settings → Import.

A Wardian page app. You type, paste or open a text file, and WebAssembly counts it, ranks its words, hashes it with SHA-256 and changes its case, on every key press. Nothing leaves the browser.

Why a page: the module works on text and returns JSON, and WebAssembly functions pass only numbers. So the page moves the text through the module's memory and draws the answers. It has one job, the text in front of you, so it is one page and not a suite.

FileWhat it is
index.htmlThe page: the text box and four panels (counts, top words, change case, SHA-256).
app.jsCopies the text into the module, calls each function, reads the answers back, draws them. Opens files.
src/lib.rsstats, top_words, sha256, change_case, plus alloc, dealloc and out_ptr. SHA-256 is written out in full, with no crates. Unit tests at the end.
app.wasmBuilt from src/lib.rs by ./build.sh.
ui/The Wardian component library: theme, button, field, card, badge, table, tabs, toast, switch and Arrange.
PanelShows
TextThe text box, Open file…, Sample text, Clear. You can also drop a file on the box.
CountsWords, characters (with and without spaces), sentences, paragraphs, lines, unique words, average word length, reading and speaking time, size in UTF-8, the longest word.
Top wordsThe 10 to 100 most frequent words, with or without common English words.
Change caseUPPER, lower, Title Case, Sentence case and url-slug, with Copy and Download.
SHA-256The hash of the text, or of the open file's bytes.

How data moves, once per change:

  1. app.js encodes the text as UTF-8 and asks the module for space with alloc(len).
  2. It copies the bytes in once, then calls stats, top_words, change_case and sha256 on the same address.
  3. Each call puts its answer in one buffer the module owns and returns the length. app.js reads that many bytes at out_ptr(). It reads memory.buffer again after every call, because a call can grow memory.
  4. app.js frees the space with dealloc.

Short text updates on every key. Text over 200,000 characters waits until typing pauses for a quarter second. A 2 MB paste takes about 120 ms.

The hash of a file: a text box turns \r\n line ends into \n. So while the text is exactly what the file held, the page hashes the file's own bytes, and the result matches shasum -a 256 <file>. Once you edit the text, the badge says "of the text" and the page hashes the text as UTF-8.

Arrange: each panel has data-panel, inside a data-arrange-column. Each viewer may reorder the panels, move them between the columns, or hide them. A hidden panel still updates.

Limits:

Change it: edit src/lib.rs and app.js, run cargo test, run ./build.sh, then wardian check ..

This page is apps/text-tools/README.md in the repository. Something wrong or missing? Change that file.