Package name.fraser.neil.plaintext

Examples of name.fraser.neil.plaintext.diff_match_patch


  }
 
  private void assertHtmlEquals(String expected, String serialized) {
    // Compute the diff of expected vs. serialized, and disregard constructs that we don't
    // care about, such as whitespace deltas and differently-computed escape sequences.
    diff_match_patch dmp = new diff_match_patch();
    LinkedList<Diff> diffs = dmp.diff_main(expected, serialized);
    while (diffs.size() > 0) {
      Diff cur = diffs.removeFirst();
      switch (cur.operation) {
      case DELETE:
        if (StringUtils.isBlank(cur.text) || "amp;".equalsIgnoreCase(cur.text)) {
View Full Code Here


  public ShareObj(String file) {
    if (!idPattern.matcher(file).matches()) {
      throw new IllegalArgumentException("Illegal id " + file);
    }
    this.file = file;
    this.dmp = new diff_match_patch();
    this.dmp.Diff_Timeout = 0.5f;
    // List of unacknowledged edits sent to the server.
    this.editStack = new LinkedList<Object[]>();
  }
View Full Code Here

  public ShareObj(String file) {
    if (!idPattern.matcher(file).matches()) {
      throw new IllegalArgumentException("Illegal id " + file);
    }
    this.file = file;
    this.dmp = new diff_match_patch();
    this.dmp.Diff_Timeout = 0.5f;
    // List of unacknowledged edits sent to the server.
    this.editStack = new LinkedList<Object[]>();
  }
View Full Code Here

        history.setProperty(Page.DATE, now);
        history.setProperty(Page.UPDATE, p.isUpdate());
        history.setProperty(Page.USER, identity);

        // create the diff
        diff_match_patch dmp = new diff_match_patch();
        // create the diff
        LinkedList<Diff> diffs = dmp.diff_main(oldPage.getContent(),
            p.getContent());
        // make the diff human readable
        dmp.diff_cleanupSemantic(diffs);
        // convert the diff to html
        String diff = dmp.diff_prettyHtml(diffs);

        history.setProperty(Page.DIFF, new Text(diff));

        datastore.put(history);
      }
View Full Code Here

  }
 
  private void assertHtmlEquals(String expected, String serialized) {
    // Compute the diff of expected vs. serialized, and disregard constructs that we don't
    // care about, such as whitespace deltas and differently-computed escape sequences.
    diff_match_patch dmp = new diff_match_patch();
    LinkedList<Diff> diffs = dmp.diff_main(expected, serialized);
    while (!diffs.isEmpty()) {
      Diff cur = diffs.removeFirst();
      switch (cur.operation) {
      case DELETE:
        if (StringUtils.isBlank(cur.text) || "amp;".equalsIgnoreCase(cur.text)) {
View Full Code Here

        HtmlView htmlView = new HtmlView();
        StringBuffer newHtml = new StringBuffer();
        StringBuffer oldHtml = new StringBuffer();

        diff_match_patch dmp = new diff_match_patch();
        LinkedList<diff_match_patch.Diff> diffs = dmp.diff_main(oldContent, newContent);

        for (diff_match_patch.Diff diff : diffs) {
            String text = diff.text.replace("&", "&amp;").replace("<", "&lt;")
                    .replace(">", "&gt;").replace(XmlUtil.crlf, "<br>");
            if (diff.operation == diff_match_patch.Operation.INSERT) {
View Full Code Here

  }

  public static String runComparison(String s1, String s2) {
    s1 = s1.replace("<br/>", "\n");
    s2 = s2.replace("<br/>", "\n");
    diff_match_patch dmp = new diff_match_patch();
    dmp.Diff_EditCost = 30;
    LinkedList<Diff> ll = dmp.diff_main(s1, s2);
    dmp.diff_cleanupEfficiency(ll);
    return dmp.diff_prettyHtml(ll);
  }
View Full Code Here

  }

  private void assertHtmlEquals(String expected, String serialized) {
    // Compute the diff of expected vs. serialized, and disregard constructs that we don't
    // care about, such as whitespace deltas and differently-computed escape sequences.
    diff_match_patch dmp = new diff_match_patch();
    LinkedList<Diff> diffs = dmp.diff_main(expected, serialized);
    while (!diffs.isEmpty()) {
      Diff cur = diffs.removeFirst();
      switch (cur.operation) {
      case DELETE:
        if (StringUtils.isBlank(cur.text) || "amp;".equalsIgnoreCase(cur.text)) {
View Full Code Here

    Map<String, Object> properties = webSocketData.getNodeData();
    String patch                   = (String) properties.get("patch");

    if (node != null) {

      diff_match_patch dmp      = new diff_match_patch();
      String oldText            = node.getProperty(Content.content);
      LinkedList<Patch> patches = (LinkedList<Patch>) dmp.patch_fromText(patch);
      final Object[] results    = dmp.patch_apply(patches, oldText);

      try {
        node.setProperty(Content.content, results[0].toString());
       
      } catch (Throwable t) {
View Full Code Here

TOP

Related Classes of name.fraser.neil.plaintext.diff_match_patch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.