Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rubypants

Package Overview
Dependencies
Maintainers
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rubypants

  • 0.7.1
  • Rubygems
  • Socket score

Version published
Maintainers
5
Created
Source

= RubyPants: SmartyPants for Ruby

{Gem}[https://rubygems.org/gems/rubypants] {Travis}[https://travis-ci.org/jmcnevin/rubypants] {CodeCov}[https://codecov.io/gh/jmcnevin/rubypants]

== Synopsis

RubyPants is a Ruby port of the smart-quotes library SmartyPants.

The original "SmartyPants" is a free web publishing plug-in for Movable Type, Blosxom, and BBEdit that easily translates plain ASCII punctuation characters into "smart" typographic punctuation HTML entities.

== Description

RubyPants can perform the following transformations:

  • Straight quotes (" and ') into "curly" quote HTML entities
  • Backticks-style quotes (``like this'') into "curly" quote HTML entities
  • Dashes (-- and ---) into en- and em-dash entities
  • Three consecutive dots (... or . . .) into an ellipsis entity

This means you can write, edit, and save your posts using plain old ASCII straight quotes, plain dashes, and plain dots, but your published posts (and final HTML output) will appear with smart quotes, em-dashes, and proper ellipses.

RubyPants does not modify characters within

,
, , ,  or
 tag blocks. Typically, these tags are used to
display text where smart quotes and other "smart punctuation" would
not be appropriate, such as source code or example markup.

== Installation

gem install rubypants

Or, in your application's Gemfile:

gem 'rubypants'

== Example of Usage

RubyPants.new("String with 'dumb' quotes.").to_html

For additional options, consult the documention in lib/rubypants/core.rb.

== Backslash Escapes

If you need to use literal straight quotes (or plain hyphens and periods), RubyPants accepts the following backslash escape sequences to force non-smart punctuation. It does so by transforming the escape sequence into a decimal-encoded HTML entity:

\ " ' . - `

This is useful, for example, when you want to use straight quotes as foot and inch marks: 6'2" tall; a 17" iMac. (Use 6'2" resp. 17".)

== Algorithmic Shortcomings

One situation in which quotes will get curled the wrong way is when apostrophes are used at the start of leading contractions. For example:

'Twas the night before Christmas.

In the case above, RubyPants will turn the apostrophe into an opening single-quote, when in fact it should be a closing one. I don't think this problem can be solved in the general case--every word processor I've tried gets this wrong as well. In such cases, it's best to use the proper HTML entity for closing single-quotes ("") by hand.

== Bugs

To file bug reports or feature requests, please create an issue in this gem's GitHub repository.

If the bug involves quotes being curled the wrong way, please send example text to illustrate.

== Authors

John Gruber did all of the hard work of writing this software in Perl for Movable Type and almost all of this useful documentation. Chad Miller ported it to Python to use with Pyblosxom.

Christian Neukirchen provided the Ruby port, as a general-purpose library that follows the *Cloth API.

Jeremy McNevin posted this code to GitHub ages ago, but has recently been trying to improve it where possible.

Aron Griffis made jekyll-pants[https://github.com/scampersand/jekyll-pants] which depends on RubyPants, and consequently jumped in to help out with issues and pull requests.

== Links

John Gruber :: http://daringfireball.net SmartyPants :: http://daringfireball.net/projects/smartypants Chad Miller :: http://web.chad.org Christian Neukirchen :: http://kronavita.de/chris Aron Griffis :: https://arongriffis.com

FAQs

Package last updated on 30 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc