# document-merger

> Merges documents

Latest version **1.0.4** (published 2017-08-02) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install document-merger
pnpm add document-merger
yarn add document-merger
bun add document-merger
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2017-08-02 |
| First published | 2016-08-29 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | LegalThings |
| Maintainers | moesjarraf, svenstam |

## Links

- npm: https://www.npmjs.com/package/document-merger
- Repository: https://github.com/legalthings/document-merger
- Homepage: https://github.com/legalthings/document-merger#readme
- Issues: https://github.com/legalthings/document-merger/issues
- npm.io page: https://npm.io/package/document-merger

## Dependencies (3)

- [cheerio](https://npm.io/package/cheerio.md) ^0.22.0
- [camelcase](https://npm.io/package/camelcase.md) ^3.0.0
- [html-minifier](https://npm.io/package/html-minifier.md) ^3.0.2

## Recent versions

- 1.0.4 (latest) — 2017-08-02
- 1.0.3 — 2017-07-06
- 1.0.2 — 2017-06-30
- 1.0.1 — 2016-10-07
- 1.0.0 — 2016-08-29

## README

Legal Things - Document merger
==================

With the document merger library, you can combine the contents of multiple documents.
**Currently only HTML is supported.**

## Requirements

- [Node.js (ES6)](https://nodejs.org) >= 5.0.0

## Installation

The library can be installed using npm.

    npm install document-merger

## How it works
The library exposes a single function with which you can merge documents together.
The documents are merged together by a `glue`, which can be custom defined and defaults to pagebreaks.
The results of the merged documents is a html file which contains a `body` tag that has the body of the combined documents in it.
The `head` is inherited from the first file.

```javascript
const DocumentMerger = require('document-merger');
const merger = new DocumentMerger();
let options = {
    documents: [
        {
            content: `
                <html>
                  <head>
                    <base href="http://example.com/cdn">
                  </head>
                  <body>
                    <p>This is the first document</p>
                  </body>
                </html>
            `,
            type: 'html'
        },
        {
            content: `
                <html>
                  <head>This will be ignored, since only the first head is used</head>
                  <body>
                    <p>This is the second document</p>
                    <b>It ends here</b>
                  </body>
                </html>
            `,
            type: 'html'
        }
    ],
    glue: '<div style="page-break-after: always"><span style="display:none">&#xA0;</span></div>',
    head: '<style>body {margin: 0}</style>'
};

console.log(merger.merge(options));
/* 
output:
<html>
  <head>
    <base href="http://example.com/cdn">
    <style>body {margin: 0}</style>
  </head>
  <body>
    <p>This is the first document</p>
    <div style="page-break-after: always"><span style="display:none">&#xA0;</span></div>
    <p>This is the second document</p>
    <b>It ends here</b>
  </body>
</html>
*/
```

---
_Source: https://npm.io/package/document-merger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
