summaryrefslogtreecommitdiff
path: root/node_modules/typographic-quotes/README.md
blob: 8d3084fede38c58480cb558680fbe29dd2b2257d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# typographic-quotes

[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Coveralls Status][coveralls-image]][coveralls-url]
[![Dependency Status][depstat-image]][depstat-url]

> [Always use curly quotes][rtfm]

Micro module to help eliminate one of the [bad typewriter habits][habits].


## Install

```sh
npm install --save typographic-quotes
```


## Usage

Use typographic quotes for your text with respect to your locale, basically for
proper primary and secondary quotes. Pass object with specified locale field as
second parameter. **`locale` field is mandatory.** This module relies on
[`typographic-quotes-l10n-db`][quotesDB] in choosing proper quotes
for every language.


> In American English, double quotes are used normally (the “primary” style).
> If quote marks are used inside another pair of quote marks, then single quotes
> are used as the “secondary” style. For example: “Didn't she say ‘I like red
> best’ when asked her favorite wine?” he wondered to himself.  
— [from the Wikipedia](http://en.wikipedia.org/wiki/Quotation_mark)

```js
var quotes = require('typographic-quotes');

// in american english (en-us) primary quotes are “”, and secondary are ‘’.
// in danish (da) primary quotes are »«, and secondary are ›‹.

// `locale` field is mandatory
quotes(`foo 'foo' bar`, { locale: 'en-us' }); // foo “foo” bar
quotes(`foo 'foo' bar`, { locale: 'da' });    // foo »foo« bar
quotes(`foo "foo 'inside' bar" bar`, { locale: 'en-us' }); // foo “foo ‘inside’ bar” bar
quotes(`foo 'foo "inside" bar' bar`, { locale: 'da' });    // foo »foo ›inside‹ bar« bar
```

[quotesDB]: https://www.npmjs.com/package/typographic-quotes-l10n-db


## Apostrophes

If you want to see proper apostrophes too, take a look at [apostrophes][typographic-apostrophes] and [apostrophes-for-possessive-plurals][typographic-apostrophes-for-possessive-plurals] typographic modules. Use first one before this module, second after: `apostrophes → quotes → apostrophes-for-possessive-plurals` (order is important). Check complex usage in [typography playground][playground].

[typographic-apostrophes]: https://www.npmjs.com/package/typographic-apostrophes
[typographic-apostrophes-for-possessive-plurals]: https://www.npmjs.com/package/typographic-apostrophes-for-possessive-plurals
[playground]: https://github.com/matmuchrapna/typographic-playground

## License

MIT © [Vladimir Starkov](https://iamstarkov.com/)

[rtfm]: http://practicaltypography.com/straight-and-curly-quotes.html
[habits]: http://practicaltypography.com/typewriter-habits.html

[npm-url]: https://npmjs.org/package/typographic-quotes
[npm-image]: http://img.shields.io/npm/v/typographic-quotes.svg

[travis-url]: https://travis-ci.org/iamstarkov/typographic-quotes
[travis-image]: http://img.shields.io/travis/iamstarkov/typographic-quotes.svg

[coveralls-url]: https://coveralls.io/r/iamstarkov/typographic-quotes
[coveralls-image]: http://img.shields.io/coveralls/iamstarkov/typographic-quotes.svg

[depstat-url]: https://david-dm.org/iamstarkov/typographic-quotes
[depstat-image]: https://david-dm.org/iamstarkov/typographic-quotes.svg