Comprehensive, HTML-entities-aware tool to typographically-correct the dashes and hyphens
This package is pure ESM.
npm i string-dashes
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, "—"]],
);
Please visit codsen.com for a full description of the API.
To report bugs or request features or assistance, raise an issue on GitHub.
MIT License.
Copyright © 2010-2024 Roy Revelt and other contributors.