漂亮的DIFF用法

问题描述 投票:2回答:2

我想用我的小web项目这个梦幻般的JavaScript库。

http://prettydiff.com/

我已经下载PrettyDiff.js和ViewDiff.js

我一直在研究如何使用它,我似乎无法找到如何让输出为Javascript / jQuery的任何实例

这是我到目前为止所。

<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>

我有两个文本区域,按钮放置,但我似乎就是找不到启动节目的功能。

任何文件或代码,将不胜感激。

干杯

javascript jquery view line
2个回答
4
投票
    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);

0
投票

不知道到底要完成什么,但也有网站本身的几个例子。 https://prettydiff.com/2/samples.xhtml

此外,文档。 https://prettydiff.com/documentation.xhtml

© www.soinside.com 2019 - 2024. All rights reserved.