convert CommonMark to and from Common Form
This package is the bridge between the way most people write legal terms for Common Form, and the internal data format that Common Form tools use to analyze, format, and share.
For a very short introduction to the syntax, see type.commonform.org.
This package includes a JavaScript module and command-line interface.
const commonmark = require('commonform-commonmark')
const assert = require('assert')
assert.deepStrictEqual(
commonmark.parse(
[
'# Purchase Price',
'The purchase price is $10.'
].join('\n')
).form,
{
content: [
{
heading: 'Purchase Price',
form: { content: ['The purchase price is $10.'] }
}
]
}
)
assert.deepStrictEqual(
commonmark.parse(
[
'# Purchase Price',
'The purchase price is `dollars`.'
].join('\n')
).directions,
[
{
label: 'dollars',
blank: ['content', 0, 'form', 'content', 1]
}
]
)
assert.deepStrictEqual(
commonmark.stringify({
content: [
'The ',
{ definition: 'Purchase Price' },
' is $10.'
]
}),
'The **Purchase Price** is $10.\n'
)
assert.deepStrictEqual(
commonmark.stringify(
{
content: [
'The ',
{ definition: 'Purchase Price' },
' is ',
{ blank: '' },
'.'
]
},
[
{
value: '$10',
blank: ['content', 3]
}
]
),
'The **Purchase Price** is $10.\n'
)
npx commonform-commonmark --help