https://github.com/wezm/titlecase
A tool and Rust crate for transforming text into Title Case.
https://github.com/wezm/titlecase
rust titlecase wasm
Last synced: about 1 year ago
JSON representation
A tool and Rust crate for transforming text into Title Case.
- Host: GitHub
- URL: https://github.com/wezm/titlecase
- Owner: wezm
- License: other
- Created: 2017-06-17T00:54:43.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-05-23T09:29:28.000Z (about 2 years ago)
- Last Synced: 2024-05-23T10:33:37.379Z (about 2 years ago)
- Topics: rust, titlecase, wasm
- Language: Rust
- Homepage: https://7bit.org/titlecase/
- Size: 110 KB
- Stars: 86
- Watchers: 4
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: LICENSE
Awesome Lists containing this project
README
# Title Case (titlecase)
`titlecase` is a small tool and library (crate) that capitalizes English text
[according to a style][style] defined by John Gruber for post titles on his
website [Daring Fireball]. `titlecase` should run on all platforms supported
by Rust including Linux, macOS, FreeBSD, NetBSD, OpenBSD, and Windows.
[](https://cirrus-ci.com/github/wezm/titlecase)
[](https://crates.io/crates/titlecase)
[][crate-docs]
[][MIT]
## Try Online
## Command Line Usage
`titlecase` reads lines of text from **stdin** and prints title cased versions
to **stdout**.
### Examples
```
% echo 'Being productive on linux' | titlecase
Being Productive on Linux
% echo 'Finding an alternative to Mac OS X — part 2' | titlecase
Finding an Alternative to Mac OS X — Part 2
% echo 'an example with small words and sub-phrases: "the example"' | titlecase
An Example With Small Words and Sub-Phrases: "The Example"
```
## Install
### Pre-compiled binaries
Pre-compiled binaries are available for some platforms, check the
[latest release](https://github.com/wezm/titlecase/releases/latest).
### From Source
If you have a stable [Rust compiler toolchain][rustup] installed you can
install the most recently released `titlecase` with cargo:
cargo install titlecase
## Usage as a Rust Crate
**Minimum Supported Rust Version:** 1.70.0
See the [crate documentation][crate-docs].
## Building for WebAssembly
### Pre-requisites
- Rust 1.73.0+
- Rust `wasm32-unknown-unknown` target
(`rustup target add wasm32-unknown-unknown` or `rust-wasm` package on Chimera Linux)
- [wasm-bindgen]
(`wasm-bindgen` package on Arch, or `cargo install wasm-bindgen-cli --version 0.2.92`)
- `make` (GNU or BSD should work)
### Building
There is a `Makefile` that automates building for WebAssembly.
make
The output is put into a `wasm` directory. See
for an
example that uses the wasm build.
## Style
Instead of simply capitalizing each word `titlecase` does the following
([amongst other things][style]):
* Lower case small words like an, of, or in.
* Don't capitalize words like iPhone.
* Don't interfere with file paths, URLs, domains, and email addresses.
* Always capitalize the first and last words, even if they are small words
or surrounded by quotes.
* Don't interfere with terms like "Q&A", or "AT&T".
* Capitalize small words after a colon.
## Credits
This tool makes use of prior work by [John Gruber][style], [Aristotle
Pagaltzis], and [David Gouch].
[Aristotle Pagaltzis]: http://plasmasturm.org/code/titlecase/
[crate-docs]: https://docs.rs/titlecase
[Daring Fireball]: https://daringfireball.net/
[David Gouch]: http://individed.com/code/to-title-case/
[MIT]: https://github.com/wezm/titlecase/blob/master/LICENSE
[rustup]: https://www.rust-lang.org/tools/install
[style]: https://daringfireball.net/2008/05/title_case
[wasm-bindgen]: https://github.com/rustwasm/wasm-bindgen