Pretty Diff Usage

2020-04-15 12:46发布

I want to use this fantastic Javascript Library on my little web project.

http://prettydiff.com/

I've downloaded PrettyDiff.js and ViewDiff.js

I've been researching on how to use it and I can't seem to find any examples on how to get the output for Javascript/Jquery

This is what I have so far.

<script xmlns="http://www.w3.org/1999/xhtml" type="application/javascript" src="prettydiff.js"></script>
<script xmlns="http://www.w3.org/1999/xhtml" type="application/javascript" src="diffview.js"></script>
<link xmlns="http://www.w3.org/1999/xhtml" href="diffview.css" media="all" rel="stylesheet" type="text/css" />
<script type="application/javascript">
    $(document).ready(function () {
        var pd = new prettydiff();
        var dv = new diffview();

    });
</script>

I have the two text areas and the button placed but I just don't seem to find the function to start the show.

Any documentation or code would be much appreciated.

Cheers

2条回答
乱世女痞
2楼-- · 2020-04-15 13:23

Don't exactly know what you want to accomplish, but there are several examples on the site itself. https://prettydiff.com/2/samples.xhtml

Also, documentation. https://prettydiff.com/documentation.xhtml

查看更多
Ridiculous、
3楼-- · 2020-04-15 13:31
    var str = "<html><body><h1>hello</h1></body><html>";

    // Options can be viewed at:
    // http://prettydiff.com/documentation.xhtml#function_properties

    var options   = {
        source: str,
        mode : "beautify", //  beautify, diff, minify, parse
        lang  : "html",
        wrap : 100,
        inchar : "\t",  // indent character
        insize : 1      // number of indent characters per indent
    }

    var pd = prettydiff(options); // returns and array: [beautified, report]

    var pretty = pd[0];
    var report = pd[1];

    console.log(pretty);
    console.log(report);
查看更多
登录 后发表回答