Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
gavel2html
Advanced tools
A utility library to render an HTML diff from the Gavel.js validation results.
npm install gavel2html
const gavel = require('gavel');
const Gavel2Html = require('gavel2html');
// Validate expected/actual HTTP transaction with Gavel.
const gavelResult = gavel(expected, actual);
const renderer = new Gavel2Html({
// Pass the name of the field you wish to render
fieldName: 'body',
// ...and the validation result for that field
fieldResult: gavelResult.fields.body,
});
const html = renderer.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>{"name": "hell</span><span class="missing">o</span><span>"}</span>
Gavel2Html(options)
Creates a renderer instance with the given options.
{
// Gavel validation results field name.
// Affects the converter being used internally.
fieldName: 'statusCode' | 'headers' | 'body'
// Gavel validation results for the given `fieldName`.
// Refer to the Gavel's documentation for more details.
fieldResults: GavelFieldValidationResults
// Use JSON pointers from the Gavel validation results
// passed in the `fieldResults` option.
usePointers?: boolean
}
getHtml(options): string
Returns an HTML string representing the markup of the validation results data diff.
{
// String to wrap the outpout data with.
// The "##data" acts as a placeholder that gets
// substituted with the output results.
// Example: <div>##data</div>.
wrapWith?: string = '##data'
startTag?: string = '<li>'
endTag?: string = '</li>'
jsonKeyStartTag?: string = ''
jsonKeyEndTag?: string = ''
// String to use at the beginning of
// a missing sequence of characters.
missingStartTag?: string
// String to use at the beginning of
// an added sequence of characters.
addedStartTag?: string
// String to use as a start when marking
// a changed sequence of characters.
changedStartTag?: string
// Include comments in the output.
comments?: boolean
commentStartTag?: string
commentEndTag?: string
// String to use as a one level of indentation.
identString?: string = ' '
}
FAQs
Convert output from Gavel to HTML
The npm package gavel2html receives a total of 4 weekly downloads. As such, gavel2html popularity was classified as not popular.
We found that gavel2html demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.