Package Exports
- commonform-smartify
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (commonform-smartify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
commonform-smartify
replace straight quotes with typographers’ quotes in Common Forms
Notes
Returns the modified form.
Returned values will not be valid forms according to commonform-validate if any replacements were made. Unicode quotation marks are not valid in strictly validated Common Form objects.
You may want to clone a form before smartifying: var smartified = JSON.parse(JSON.stringify(form)).
Examples
var smartify = require('commonform-smartify')
var assert = require('assert')
assert.deepStrictEqual(
smartify({ content: ["The package's first test!"] }),
{ content: ['The package’s first test!'] }
// ^
)Quotation marks after uses, definitions, and references:
assert.deepStrictEqual(
smartify({ content: [{ use: 'Purchaser' }, "'s obligations"] }),
{ content: [{ use: 'Purchaser' }, '’s obligations'] }
// ^
)Multiple quotation marks in one string:
assert.deepStrictEqual(
smartify({ content: ["What's mine ain't yours."] }),
{ content: ['What’s mine ain’t yours.'] }
// ^ ^
)Double quotes:
assert.deepStrictEqual(
smartify({ content: ['The product comes "as is".'] }),
{ content: ['The product comes “as is”.'] }
// ^ ^
)Quotes in definitions and term uses:
assert.deepStrictEqual(
smartify({
content: [
{ definition: "Purchaser's Name" },
' ',
{ use: "Purchaser's Name" }
]
}),
{
content: [
{ definition: 'Purchaser’s Name' },
// ^
' ',
{ use: 'Purchaser’s Name' }
// ^
]
}
)Recurses the full form:
assert.deepStrictEqual(
smartify({
content: [
{
heading: "Purchaser's Obligations",
form: { content: ['First Child'] }
},
{
form: { content: [{ reference: "Purchaser's Obligations" }] }
}
]
}),
{
content: [
{
heading: 'Purchaser’s Obligations',
// ^
form: { content: ['First Child'] }
},
{
form: {
content: [
{ reference: 'Purchaser’s Obligations' }
// ^
]
}
}
]
}
)Leaves blanks alone:
assert.deepStrictEqual(
smartify({ content: [{ blank: '' }] }),
{ content: [{ blank: '' }] }
)Headings:
assert.deepStrictEqual(
smartify({
content: [
{
heading: "Here's a heading",
form: {
content: ["It's the first form."]
}
},
{
heading: "Here's another heading",
form: {
content: ["It's the second form."]
}
}
]
}),
{
content: [
{
heading: 'Here’s a heading',
// ^
form: {
content: ['It’s the first form.']
// ^
}
},
{
heading: 'Here’s another heading',
// ^
form: {
content: ['It’s the second form.']
// ^
}
}
]
}
)