Giter VIP home page Giter VIP logo

titlecase's Introduction

Title Case (titlecase)

titlecase is a small tool and library (crate) that capitalizes English text according to a 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.

Build Status crates.io Documentation License

Try Online

https://7bit.org/titlecase/

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 a some platforms:

Example to download and extract a binary:

curl https://releases.wezm.net/titlecase/3.2.0/titlecase-3.2.0-x86_64-unknown-linux-musl.tar.gz | tar zxf -

From Source

If you have a stable Rust compiler toolchain 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.

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 https://github.com/wezm/7bit.org/tree/main/public/titlecase for an example that uses the wasm build.

Style

Instead of simply capitalizing each word titlecase does the following (amongst other things):

  • 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, Aristotle Pagaltzis, and David Gouch.

titlecase's People

Contributors

dependabot[bot] avatar negezor avatar rinarakaki avatar wezm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

titlecase's Issues

Capitalise hyphenated words

The following test cases are not currently supported:

testcase!(
    in_flight,
    "The in-flight entertainment was excellent",
    "The In-Flight Entertainment Was Excellent"
);

testcase!(
    stand_in,
    "The Stand-in teacher gave us homework",
    "The Stand-In Teacher Gave Us Homework"
);

Markdown mode

Provide a way to opt-into a Markdown aware mode where leading puctuation (#, *, -, etc.) would be ignored as would formatting like backticks and bold/italic.

ASCII Only mode

From discussion in #11 it might be useful to have a mode where only ASCII characters are upper-cased:

@wezm I mean I want to leave small greek letters as are when they are used as special mathematical operators or constants:

* π → π

* λ-calculus → λ-Calculus

Ahh interesting. I see that it's upper-casing the greek letters too.

I can see why you'd want to avoid that. I think it would be fairly easy to support a mode where only ASCII characters were upper-cased.

Originally posted by @wezm in #11 (comment)

tag and github release for v2.0.0?

Just wanted to flag this in case it wasn't intentional. It would be nice to have a tag (and optionally, a GitHub release) for 2.0.0 version that is already on crates.io.

Just bringing it up since it seems like you were doing tags/github releases in the past.

Ignore markdown hash/heading marks?

Shouldn't:

echo '### A small tool and library (crate) that capitalizes English text' | titlecase

produce:

### A Small Tool and Library (Crate) That Capitalizes English Text

instead of:

### a Small Tool and Library (Crate) That Capitalizes English Text

?

Strips punctuation

echo 'they're bill's friends from the UK' | titlecase
Theyre Bills Friends From the UK

Expected result: "They're Bill's Friends From the UK"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.