Code Monkey home page Code Monkey logo

nicetitle's Introduction

Gem Version License Last Commit

Nicetitle

Nicetitle is an implementation of John Gruber's TitleCase.pl.

The rule set is:

  • Small words such as "a", "an", and "but" are not capitalized:
    • except for the word "is";
    • except if the previous word ended with a colon.
  • The first and last words are always capitalized, even if they're small words.
  • Words starting with (, _, ', or " are capitalized e.g. __foo becomes __Foo.
  • Words starting with a dash, or words interspersed with dashes, are capitalized after every dash e.g. -Foo-bar becomes -Foo-Bar.
  • Words interspersed with slashes are capitalized "between" every slash e.g. foo/bar becomes Foo/Bar.
  • Words starting with a slash are not capitalized.
  • URLs are not capitalized.
  • Words containing capitals other than the first character are not capitalized e.g. iOS remains untouched.
  • Words containing dots are not capitalized.
  • All caps sentences are down-cased before applying above mentioned rules.

Check out the test cases for a detailed overview.

Installation

Add this line to your application's Gemfile:

gem 'nicetitle'

And then execute:

$ bundle

Or install it yourself as:

$ gem install nicetitle

Usage

Calling

Nice.title('What am I reading/listing/applying these days?')

outputs

What Am I Reading/Listing/Applying These Days?

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/evaneykelen/nicetitle.

License

The gem is available as open source under the terms of the MIT License.

Similar projects

I've written an article about title casing. This article mentions the following similar projects:

nicetitle's People

Contributors

evaneykelen avatar

Stargazers

 avatar

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.