I am using diff2html to show the diffs in a git PR in an HTML page. I have added the necessary scripts and is calling the object like this
<script type="text/javascript">
var diffHtml = Diff2Html.getPrettyHtml(
'https://github.com/rtfpessoa/diff2html/pull/106',
{
inputFormat: 'diff',
showFiles: true,
matching: 'lines',
outputFormat: 'side-by-side'
}
);
document.getElementById("diff-container").innerHTML = diffHtml;
</script>
Now this is showing Files changed (0). The URL I have given is the one given in the demo section of their website and have diff. I am doing this correctly ? Or how can I fetch from a the URL ?
Actually
getPrettyHtml
accepts a diff string, not the link itself. There is no way to handle diff calculations with diff2html itself, this library only prettifies it. You can easily retrieve diff with this GitHub tip:To retrieve the data via URL you could take a look at this answer.