Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table to visual #24

Closed
okdistribute opened this issue Apr 21, 2015 · 3 comments
Closed

table to visual #24

okdistribute opened this issue Apr 21, 2015 · 3 comments

Comments

@okdistribute
Copy link
Contributor

I wrote this thing to convert a couple daff tables to a visual for convenience. How do you feel about putting it somewhere in daff core (or maybe extend it even to a version that is smart about 3-table diffs, too).

If not, I'll open an npm module for it

https://github.com/karissa/dat-visualdiff/blob/master/lib/dat2daff.js#L33

function tablesToVisual (tables, opts) {
  var flags = new daff.CompareFlags();

  var table1 = tables[0]
  var table2 = tables[1]

  var alignment = daff.compareTables(table1, table2, flags).align();
  var highlighter = new daff.TableDiff(alignment,flags);
  var table_diff = new daff.SimpleTable();
  highlighter.hilite(table_diff);

  if (opts.html) {
    var diff2html = new daff.DiffRender();
    diff2html.render(table_diff);
    var table_diff_html = diff2html.html();
    return table_diff_html
  }
  else {
    var diff2terminal = new daff.TerminalDiffRender();
    return diff2terminal.render(table_diff)
  }
}
@paulfitz
Copy link
Owner

I'm definitely +1 on adding a helper that does this in core. Even I have a hard time remembering all the hoops to jump through to make a diff...

@okdistribute
Copy link
Contributor Author

Hehe ok! cool

@paulfitz
Copy link
Owner

this became #26 which was merged as 3bc4310 and a4e1d2b, in daff 1.2.13. Thanks @Karissa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants