Renders HTML diff from Gavel.js output
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.
src
test
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
appveyor.yml
package.json

README.md

gavel2html

npm version Build Status Build status Dependency Status devDependency Status Known Vulnerabilities

The gavel2html utility renders HTML diff from Gavel.js output.

Installation

npm install gavel2html

Usage

Gavel2Html = require('gavel2html');

const gavel2html = new Gavel2Html({
  dataReal: '{"name": "hell"}',
  dataExpected: '{"name": "hello"}',
});

const html = gavel2html.getHtml({
  wrapWith: '##data',
  startTag: '<span>',
  endTag: '</span>',
  missingStartTag: '<span class="missing">',
  addedStartTag: '<span class="added">',
  changedStartTag: '<span class="changed">',
  comments: true,
  commentStartTag: '<span class="comments">',
  commentEndTag: '</span>',
  identString: '  '
});

console.log(html);
<span>{&quot;name&quot;: &quot;hell</span><span class="missing">o</span><span>&quot;}</span>

Options

  • dataReal (string, required) - Actual body data
  • dataExpected (string, required) - Expected body data
  • gavelResult (object) - Validation object, output from Gavel.js
  • usePointers: true (boolean, default) - Whether to use JSON pointers from 'results' key in Gavel data to not to rely on Amanda's data

getHtml options

  • wrapWith (string)
  • startTag (string)
  • endTag (string)
  • missingStartTag (string) - String to be used as a start when marking missing sequence of characters.
  • addedStartTag (string) - String to be used as a start when marking added sequence of characters.
  • changedStartTag (string) - String to be used as a start when marking changed sequence of characters.
  • comments (boolean)
  • commentStartTag (string)
  • commentEndTag (string)
  • identString (string) - String to use for one level of indentation.

Note: The gavel2html library is underdocumented. Please see #7 for details.