Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
matching: 'lines'
})
return htmlReplace(html)
} else {
diffJsonConf = this.getDiffJson(oldContent, newContent + '\n', context, outputFormat)
diffJsonConf.changeLines = 0
diffJsonConf[0].addedLines = 0
diffJsonConf[0].deletedLines = 0
const firstBlock = diffJsonConf[0].blocks[0]
firstBlock.header = ''
firstBlock.newStartLine = '0'
firstBlock.oldStartLine = '0'
firstBlock.lines.splice(firstBlock.lines.length - 1, 1)
const html = Diff2Html.getPrettyHtml(diffJsonConf, {
inputFormat: 'json',
outputFormat: outputFormat,
showFiles: false,
matching: 'lines'
})
return htmlReplace(html)
// return `<div style="line-height: ${this.minHeight}px;" class="diff-tip-box">ๆฐๆฎๆฒกๆๅทฎๅผ</div>`
}
}
}
&& revisionDiffOpened) {
let previousText = previousRevision.body;
// comparing ObjectId
// eslint-disable-next-line eqeqeq
if (currentRevision._id == previousRevision._id) {
previousText = '';
}
const patch = createPatch(
currentRevision.path,
previousText,
currentRevision.body,
);
diffViewHTML = Diff2Html.getPrettyHtml(patch);
}
const diffView = { __html: diffViewHTML };
// eslint-disable-next-line react/no-danger
return <div>;
}
</div>
createdHtml (oldContent, newContent, context, outputFormat) {
function htmlReplace (html) {
return html.replace(
/<span class="d2h-code-line-ctn">(.+?)<\/span>/g,
'<span class="d2h-code-line-ctn"><code>$1</code></span>'
)
}
let diffJsonConf = this.getDiffJson(oldContent, newContent, context, outputFormat)
this.$emit('change-count', diffJsonConf.changeLines)
if (diffJsonConf.changeLines) {
const html = Diff2Html.getPrettyHtml(diffJsonConf, {
inputFormat: 'json',
outputFormat: outputFormat,
showFiles: false,
matching: 'lines'
})
return htmlReplace(html)
} else {
diffJsonConf = this.getDiffJson(oldContent, newContent + '\n', context, outputFormat)
diffJsonConf.changeLines = 0
diffJsonConf[0].addedLines = 0
diffJsonConf[0].deletedLines = 0
const firstBlock = diffJsonConf[0].blocks[0]
firstBlock.header = ''
firstBlock.newStartLine = '0'
firstBlock.oldStartLine = '0'</span>
createdHtml (oldString, newString, context, outputFormat) {
function hljs (html) {
return html.replace(/<span class="d2h-code-line-ctn">(.+?)<\/span>/g, '<span class="d2h-code-line-ctn"><code>$1</code></span>')
}
let args = ['', oldString, newString, '', '', {context: context}]
let dd = createPatch(...args)
let outStr = Diff2Html.getJsonFromDiff(dd, {inputFormat: 'diff', outputFormat: outputFormat, showFiles: false, matching: 'lines'})
let html = Diff2Html.getPrettyHtml(outStr, {inputFormat: 'json', outputFormat: outputFormat, showFiles: false, matching: 'lines'})
return hljs(html)
}
}</span>
export async function createHtmlOutput(
diff: string,
options: Options = {}
): Promise {
const { outputDirectory = 'schemaDiff' } = options;
const adjustedDiff = diff
.replace(/(---\s.*)\sremoved/, '$1')
.replace(/(\+\+\+\s.*)\sadded/, '$1');
const diffHtml = Diff2Html.getPrettyHtml(adjustedDiff, {
inputFormat: 'diff',
matching: 'lines',
outputFormat: 'side-by-side',
rawTemplates: {
'tag-file-renamed': ''
}
});
await fs.ensureDir(outputDirectory);
const diff2HtmlPath = path.dirname(require.resolve('diff2html/package.json'));
await fs.copy(path.join(diff2HtmlPath, 'dist'), outputDirectory);
const htmlOutput = htmlTemplate(diffHtml);
await fs.writeFile(path.join(outputDirectory, 'index.html'), htmlOutput);
}
function createdHtml (oldString, newString, context, outputFormat){
function hljs (html) {
return html.replace(/<span class="d2h-code-line-ctn">(.+?)<\/span>/g, '<span class="d2h-code-line-ctn"><code>$1</code></span>')
}
let args = ['', oldString || '', newString || '', '', '', {context: context}]
let dd = createPatch(...args)
let outStr = Diff2Html.getJsonFromDiff(dd, {inputFormat: 'diff', outputFormat: outputFormat, showFiles: false, matching: 'lines'})
let html = Diff2Html.getPrettyHtml(outStr, {inputFormat: 'json', outputFormat: outputFormat, showFiles: false, matching: 'lines'})
return hljs(html)
}
</span>
function getHtmlFromDiff(diff, currentVersion) {
const style = fs.readFileSync(require.resolve('diff2html/dist/diff2html.min.css'));
const diffHtml = diff2html.getPrettyHtml(diff, { inputFormat: 'diff', showFiles: true, matching: 'lines', outputFormat: 'side-by-side' });
const html = `
<title>Camunda Modeler ${currentVersion} Third Party Notices Changes Summary</title>
<style>${style}</style>
<h1>
Camunda Modeler Third Party Notices Changes
</h1>
${diffHtml}
diffDocs(oldLink, newLink, function(err, diff) {
if (err) { return cb(err); }
var body = Diff2Html.getPrettyHtml(diff, { inputFormat: 'diff' }),
html = buildDiffHtml(body),
filename = entry.guid + '.html';
fs.writeFileSync(filename, html);
uploadFileToS3('edgar-diffs', filename, html, { ACL: 'public-read', ContentType: 'text/html' }, function(err, link) {
if (err) { return cb(err); }
var secondsInAWeek = 604800;
var params = { Bucket: 'edgar-diffs', Key: filename, Expires: secondsInAWeek };
s3.getSignedUrl('getObject', params, function(err, url) {
cb(err, url);
});
});
});
function diffToHTML (diff, options = {}) {
if (!diff) {
return ''
}
return Diff2Html.getPrettyHtml(
diff, {
outputFormat: options.sideBySide ? 'side-by-side' : 'line-by-line'
}
)
}