Skip to content
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.npmignore
.travis.yml
LICENSE.md
README.md
index.js
package.json

README.md

commonform-flatten

Produces a useful intermediary representation for rendering in linear document formats, like Office Open XML and terminal listings.

var flatten = require('commonform-flatten')
var assert = require('assert')

assert.deepEqual(
  flatten(
    {
      content: [
        'some text ',
        { blank: '' },
        {
          heading: 'A',
          form: {
            conspicuous: 'yes',
            content: [
              'before',
              { form: { content: [ 'B' ] } },
              { form: { content: [ 'C' ] } },
              'between',
              { form: { content: [ 'D' ] } },
              { form: { content: [ 'E' ] } },
              'after'
            ]
          }
        },
        'after',
        { use: 'A Defined Term' }
      ]
    },
    [ { blank: [ 'content', 1 ], value: 'NewCo' } ]
  ),
  [
    {
      depth: 1,
      content: [
        'some text ',
        { blank: 'NewCo' }
      ]
    },
    {
      depth: 2,
      heading: 'A',
      content: [ 'before' ],
      numbering: [
        {
          series: { number: 1, of: 1 },
          element: { number: 1, of: 1 }
        }
      ],
      conspicuous: 'yes'
    },
    {
      depth: 3,
      content: [ 'B' ],
      numbering: [
        {
          series: { number: 1, of: 1 },
          element: { number: 1, of: 1 }
        },
        {
          series: { number: 1, of: 2 },
          element: { number: 1, of: 2 }
        }
      ]
    },
    {
      depth: 3,
      content: [ 'C' ],
      numbering: [
        {
          series: { number: 1, of: 1 },
          element: { number: 1, of: 1 }
        },
        {
          series: { number: 1, of: 2 },
          element: { number: 2, of: 2 }
        }
      ]
    },
    {
      depth: 2,
      content: [ 'between' ],
      conspicuous: 'yes'
    },
    {
      depth: 3,
      content: [ 'D' ],
      numbering: [
        {
          series: { number: 1, of: 1 },
          element: { number: 1, of: 1 }
        },
        {
          series: { number: 2, of: 2 },
          element: { number: 1, of: 2 }
        }
      ]
    },
    {
      depth: 3,
      content: [ 'E' ],
      numbering: [
        {
          series: { number: 1, of: 1 },
          element: { number: 1, of: 1 }
        },
        {
          series: { number: 2, of: 2 },
          element: { number: 2, of: 2 }
        }
      ]
    },
    {
      depth: 2,
      content: [ 'after' ],
      conspicuous: 'yes'
    },
    {
      depth: 1,
      content: [
        'after',
        { use: 'A Defined Term' }
      ]
    }
  ]
)
You can’t perform that action at this time.