string-dashes
TypeScript icon, indicating that this package has built-in type declarations

1.2.13 • Public • Published

string-dashes

Comprehensive, HTML-entities-aware tool to typographically-correct the dashes and hyphens

page on codsen.com page on npm page on github Downloads per month changelog MIT Licence

Install

This package is pure ESM.

npm i string-dashes

Quick Take

import { strict as assert } from "assert";

import { convertOne, convertAll } from "string-dashes";

assert.deepEqual(
  convertAll("Dashes come in two sizes - the en dash and the em dash.", {
    convertDashes: true,
    convertEntities: true,
  }),
  {
    result: "Dashes come in two sizes — the en dash and the em dash.",
    ranges: [[25, 26, "—"]],
  },
);

assert.deepEqual(
  convertOne("Dashes come in two sizes - the en dash and the em dash.", {
    from: 25,
    convertDashes: true,
    convertEntities: true,
  }),
  [[25, 26, "—"]],
);

Documentation

Please visit codsen.com for a full description of the API.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License.

Copyright © 2010-2024 Roy Revelt and other contributors.

ok codsen star

Package Sidebar

Install

npm i string-dashes

Weekly Downloads

58

Version

1.2.13

License

MIT

Unpacked Size

25 kB

Total Files

7

Last publish

Collaborators

  • royston