JavaScript based diff utility [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm looking for a diff equivalent written in JavaScript that only returns/prints relevant lines. I don't want both full text displayed next to each other with the differences highlighted, but just want the actual differences (plus some buffer lines to know where the difference is), similar to the output from the linux diff utility.
Does anybody know a javascript function that does this? All differences should be recognized (even changed whitespace). Thanks.

I completely rebuilt the jsdifflib utility for speed. Since my version does not require DOM access it at least 4.5 times faster, and it is also extended to highlight character differences in each line.
http://prettydiff.com/diffview.js
You can test this out with the online tool directly at http://prettydiff.com/

jsdifflib inline mode comparison, try tweaking the context size to display just the desired window of change you want. There's a demo here

There's also google-diff-match-patch from Google
Also available on NPM
npm install diff-match-patch

Mergely is totally worth checking out. CodeMirror-based, client-side only.
Then there's the CodeMirror demo which requires server-side diff computation.
jsdifflib and prettydiff as mentioned in other answers.

Checkout my minimal implementation: https://github.com/Slava/diff.js

Check out CodeMirror. Nuff said.

I dont know much about the diff utility in linux or linux in general, but this might be what you are looking for jsdifflib. You can find a live example there and see if it works for you.

Check out the the wikEd diff JavaScript library. There is also an online tool.
wikEd diff features inline text comparisons with block move highlighting and character/word-based resolution. It is optimized for Wikipedia source text, but works great for any type of text or code. The library code is fully customizable, has Unicode support, is extensively commented, and is in the public domain.

old question i know, but if your doing node work or want something that is compatible with requirejs/commonjs module
I've really liked https://www.npmjs.com/package/diff
console.log(diff.createPatch('some file name.txt', expected, actual));

jsdifflib looks promising - try the demo linked from that page.

Related

What would you suggest as a start point to understand a 25k rows code? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm really confused here. I am trying to understand this code (it's javascript) but I don't really know from where I should start. It's more than 25.000 rows including the comments. Therefore, reading the code line by line is definitely not the way to go. Using a debugger would be good, but I don't know any that works like Visual Studio debugger. So what else could I do to understand this code? What would be your starting point?
Change something.
Find something you're interested in (something must be more interesting than "all of it"), and change it. Make it do something different.
Don't fixate on the 25K lines of code, rather fixate on the 2, 10, 100 lines that you care about first. Then, you will implicitly bump in to other parts of the system.
Once you're done, change something else. See what, if any, commonality exists between your two changes.
And just keep going. It's easier that way. Elephants taste better when eaten in small bites.
Take a look at this instead: https://github.com/ajaxorg/ace/tree/master/lib/ace
That format should be much more approachable than all 25k LoC concatenated together. Having the filenames to help provide context is very helpful.
You can step through JavaScript code just like stepping through VB or C# code in Visual Studio. Take a look at the developer tools in your browser of choice - F12 will open them up in Chrome, Firefox, and IE. They will all have a section related to scripts, where you can set breakpoints, step through the code once paused, set watches, and most of the other things you're used to when debugging in Visual Studio.
You can debug javascript in firefox's firebug with breakpoints. This code looks like a library used to convert code from one language to another. It is rather in depth and very well coded.
I would start by finding a effect you want to figure out and off you go...
I would start by looking at the source https://github.com/ajaxorg/ace/tree/master/lib/ace instead of the file with it all scrunched together... The file you linked is the final build, not the edited sources, If my quick glance is correct.

javascript code formatter and highlighter [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am looking for a jQuery plugin that can take a string of code as input and will apply formatting and Highlights to make the code easily understandable. Just like jsfiddle.net.
As of now I have found many sites like jsbeautifier.org.. But I need a standalone jquery plugin which can process my code
Please help me on this.
9 useful Javascript syntax highilghting scripts. There, I googled it for you. 3 of them are jQuery-based.
i am using codemirror. http://codemirror.net/
its easy and cool.
I use Highlight.Js
If you want to change the syntax in a specific style or just check the style than take a look at code painter
A JavaScript beautifier that can both infer coding style and transform
code to reflect that style. You can also set style preferences
explicitly in a variety of ways.
you can use jstidy for this. and if you are using visual studio, you can directly copy code and paste in to the designer view. it will generates the required styles.
I have checked the pages linked by other answers and found them very lacking.
After a bit of research and scouring the web, I found one that I think clearly is superior to the rest.
Snippit is jQuery based, including "copy" feature (with clipboard plugin), line-numbers, custom styles, etc.
Let me know what you think.

ipython equivalent for javascript/coffeescript for node.js? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
More specifically, is there a REPL that has (more) colorful output, pretty printing, tab completion and the other goodies that ipython has for node.js javascript/coffeescript?
I've recently started a project to provide an enhanced, extensible, embeddable interactive interpreter for multiple languages running on Node (including built-in support for CoffeeScript) here:
http://danielgtaylor.github.com/nesh/
It's pretty basic at the moment but it already provides a nice base with multi-language support and an asynchronous plugin architecture, a small set of built-in utility functions, etc. Let me know if there are any specific features you are looking for :-)
To my knowledge, node and coffee are the only full-featured command-line REPLs for Node.js and CoffeeScript (respectively) right now. In their latest iterations, both offer some degree of colorful output, pretty printing, and completion.
This is the best REPL available - https://github.com/princejwesley/Mancy
Ankit, I was looking for exactly the same answer and ended up implementing it, perhaps it could be helpful for you as well: https://github.com/mksenzov/i.js
Have you tried the console in Chrome Dev Tools?
or this one: http://jsconsole.com/
Ok so for input commands history you can use this:
http://blog.doteight.com/blog/2011/01/16/rlwrap-and-node/
but this way the tab completion doesn't work...
anyone know how to call node interpreter with
tab autocomletion turned on?

Source code annotation tool [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm looking for a tool with which I can annotate source code.
I have some 3rd party source code (JavaScript) I need to understand and I don't want to change it (add inline comments) so that
line numbers can stay intact (for communication with others),
I can avoid accidentally changing something and
my annotations stand out compared to the authors comments.
Normally I would print the whole thing out an scribble on it, but the code is too long for that and I need to share it per email. I would be great if one could do some like that including being able to create "links" between so places in the code, possibly even visually with a lines or arrows.
If you would usually print it (if it were shorter), why not print it to a PDF and then use a PDF viewer that supports comments, like Foxit Reader? :)
I would use email to comment and pastebin to host and highlight #h# lines with links in the email text.
OR
some code-review tool (like codestricker or reviewboard for example)
You can certainly do what you want to with LaTeX and its listings package. But if you are not already a LaTeX user you might think that a hard way to go.
start a github project and post the code there, github includes annotation abilities OOB.
You have difficult requirements. I don't know of such tool. Nevertheless as a more general purpose tool, I can recommend Yui Doc (download here).
I'd build a glamour browser for it. (If spending half a day building it wouldn't be too much).
[edit]
Glamour is a toolkit for building browsers on a model. The model would here consist of the various parts of the file(s) and the comments and attributes you'd like to add. This would allow you to easily navigate through the source and comments, to select only parts with (or without) certain attributes. There is a video and slides. Official page, Source
How about using google wave with syntaxy (http://wave-samples-gallery.appspot.com/about_app?app_id=14008) bot?

Any good javascript BBCode parser? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Currently i'm parsing bbcode server side but i'd like to show a preview just like this site does.
If I process the bbcode serverside using ajax it's a bit laggy, so i thought doing it client side, to just show the preview.
Do you guys know any bbcode parser written in javascript?
It is a bit late, and the question has certainly been answered. However if you are still open to suggestions, and have not yet spent your time converting the indicated parser from C# to JavaScript, I have written a parser (originally in PHP) which I converted myself[2] to JavaScript. It is available at bitbucket under the 3-clause BSD license. The parser seems to be reasonably fast, but I haven't performed any analysis on its speed.
It may not be as flexible in some ways as other possible projects out there, but it does allow defining your own codes ("bb-code" or not, with quite a few properties), and is also all contained within the one file. This is not a simple find-and-replace parser, and is not based on regex.
If this is of any interest to you, it might save you from having to convert that other library. Technically, I'm a relative "unknown", but that's the great things about JS/OSS: you can check out the source to see what I've done.
[2] As a result, there are a few remaining "compatibility functions", but I rewrote things which had native equivalents available.
I haven't personally used any Javascript BBcode parsers, but the top two Google results (bbcodejs and this blog post) seem pretty weak. The former only seems to support simple find-and-replace, and the latter seems to have pre-set BBcode built in, so you'd probably have to hack it a bit if you chose that solution.
Your best options are probably to roll your own solution (possibly basing your work off one of the two links here), or just use AJAX and move on. That's probably the best way to ensure that previews are accurate, and previewing doesn't have to be real-time on every keypress, anyway; a delay before even sending the request is acceptable.
I encountered the same problem, so I wrote my own. That supports BBCode -> AST Array -> any kind of markup, now supports HTML and React. And has plugins and presets support
https://github.com/JiLiZART/bbob

Categories

Resources