Coder Social home page Coder Social logo

differ's People

Contributors

pvande avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

differ's Issues

$; is deprecated in Ruby 2.7.0

Ruby 2.7.0 gives a deprecation warning:

vendor/bundle/ruby/2.7.0/gems/differ-0.1.2/lib/differ.rb:11: warning: `$;' is deprecated

Showing only changes?

I don't know how to put it, but to be selfish, here's what i want and need to do:

I grab an html page with net/http, and i save it to the Database.
I then compare this page to another page i grabbed, say yesterday.

I only want the changes between the two pages to appear.

Is this gem right for that? I can see it noticing some changes in the shit i'm looking at, but I don't know how to get it out and use it. i can see something like this gist https://gist.github.com/caf0aff6c57f9ca011a9

I mean i see {+ where it should be, which is all i want to see printed out.

thoughts?

Something is wrong when there is bold text

Something is wrong when there is bold text (text surrounded by the <strong> element). Take for example:

a = "<p>adfadf<br>\n222<br>\nfoo <strong>bar</strong> was <code>here</code> 333<br>\nhere too<br>\n444<br>\n55 <strong>bold text added</strong><br>\n66</p>\n"
b = "<p>adfadf<br>\n222<br>\nfoo <strong>bar</strong> was <code>here</code> 333<br>\nhere too<br>\n444<br>\n55<br>\n66</p>\n"
Differ.diff_by_word(a, b).format_as(:html).html_safe

The following renders as:

<p>adfadf<br>
222<br>
foo <strong>bar</strong> was <code>here</code> 333<br>
here too<br>
444<br>
55<del class="differ">&lt;</del><ins class="differ"> <strong>bold text added</strong>&lt;</ins>br&gt;
66</p>

Notice the &lt; characters. Is this normal? Which renders in the browser inappropriately...

Please remove protected from raw_array

Hi.

Could you remove "protected" from raw_array? I need the diff output in machine readable format (rather than display to user), and raw_array seems the most usable format. My use case is that I'm developing a text editor (https://github.com/SamiSieranoja/vimamsa) and I want to process the buffer contents with external program and then include the diffs of before/after in undo history.

diff --git a/lib/differ/diff.rb b/lib/differ/diff.rb
index 76d3012..5f46cb6 100644
--- a/lib/differ/diff.rb
+++ b/lib/differ/diff.rb
@@ -82,7 +82,7 @@ module Differ
       end
     end
 
-  protected
+#  protected
     def raw_array
       @raw
     end

HTML formatter passes '<' symbol and tags unescaped

:html formatter passes < symbols as is to resulting html, which may result in XSS vulnerability.

[2] pry(main)> Differ.diff_by_line("foo", "<script>alert(1)</script>").format_as(:html)
=> "<del class=\"differ\"><script>alert(1)</script></del><ins class=\"differ\">foo</ins>"

As Differ operates on strings, not HTML fragments, IMHO, it should escape chunks of these strings in resulting html.

Using differ 0.1.2.

Looking for new project maintainer?

@pvande Your Differ project is awesome, but it's sad to see that it's no being actively maintained. We @forgecrafted would love to pick up the torch and carry on your excellent ground work.

Would you be willing to make a maintainer transfer?

By_Word not sensitive enough.

I tested the following two strings:

@original = "The second aspect is that graphic design is a very inclusive subject, and enables me to explore various art fields. For instance, if I am going to create a poster, I could create it solely with a computer, or I can create a sculpture and then take a photo of it, or I can learn photography and create a photograph for it, or I can use traditional ways like drawing or painting, and so forth. The numerous possibilities and great potential of graphic design attract me as well."

@current = "The first aspect is that graphic design is a very inclusive subject. It enables me to explore various art fields, and incorporate a mixture of media in my works. For instance, if I am going to create a poster, I could create it solely by computer, or I can create a sculpture and then take a photo of it, then cut it and edit it digitally. I can learn photography and create a photograph for it. I can even use traditional methods like drawing or painting, and mix it with digital work. The numerous possibilities and great potential of graphic design attract me to this exciting art field."

Your Gem handled the first few phrases well, but then chunked together the remaining part. I've tried many different plugins and gems so far for this, and so far, the best algorithm for comparison is the JS plugin jsdiff. Perhaps you can incorporate some stuff from their algorithm for this gem? I would love it if a ruby gem can take care of this all.

jsdiff: github url
live demo

jsdiff was able to handle very well the complexity of large text revision (by_word).

Differ not formating strings correctly

The difference between two strings is

Original -- Hello
Revision -- <strong>Hello</strong>

using diff_by_word and format :html

Result posted below.

Technically, Differ is doing it correctly. The delta change is the <strong> </strong> tags.

What I would like to figure out is how to change the output
from:
In the
to:
In the

Any ideas of where to attack this would be appreciated. It is an awesome gem, just this one problem is driving me batty

thanks

zonker

DIFF:

<ins class="differ"><strong></ins>In<ins class="differ"></strong> the</ins> 
<ins class="differ">early 1900s, Freud and a <strong>growing</strong> number
of followers formed a psychoanalytic movement. Carl Gustav Jung
(1875&ndash;1961) and Alfred Adler (1870&ndash;1937) were prominent in
</ins>the <del class="differ">early 1900s, Freud and a growing number of
followers formed a psychoanalytic </del>movement<del class="differ">. Carl
Gustav Jung (1875&ndash;1961) and Alfred Adler (1870&ndash;1937) were
prominent in the movement</del>, but both were independent thinkers, and Freud
apparently had little tolerance for individuals who challenged his ideas.

NEW:

<strong>In</strong> the early 1900s, Freud and a <strong>growing</strong>
number of followers formed a psychoanalytic movement. Carl Gustav Jung
(1875&ndash;1961) and Alfred Adler (1870&ndash;1937) were prominent in
the movement, but both were independent thinkers, and Freud apparently had
little tolerance for individuals who challenged his ideas.

ORIGINAL:

In the early 1900s, Freud and a growing number of followers formed a
psychoanalytic movement. Carl Gustav Jung (1875&ndash;1961) and
Alfred Adler (1870&ndash;1937) were prominent in the movement, but
both were independent thinkers, and Freud apparently had little tolerance
for individuals who challenged his ideas.

(Edited for formatting and clarity -- pvande)

Issue when outputting differences in ascii format with unicode chars

Hello sir. Please take a look at this:

image

The outputt:

image

How it looks when you write this content to a file:

image

The problem, found in ascii.rb:

image

The inspect is the problem. Is fine with none unicode strings, but when unicode appear it mess. The workaround we made:

image

How the file where string was written looks:

image

If this is okay for you, I can make a pull request, I'm not sure if fills expectations, probably it could be improved. Cheers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.