Coder Social home page Coder Social logo

rashid2538 / php-htmldiff Goto Github PK

View Code? Open in Web Editor NEW
69.0 69.0 48.0 81 KB

A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.

License: GNU General Public License v2.0

PHP 100.00%
html php php-htmldiff

php-htmldiff's Introduction

Hi, I'm Rashid Mohamad 👋

I'm a full-stack developer with a passion for creating robust and scalable applications. I have experience working with a variety of programming languages including:

  • TypeScript/JavaScript 🌐
  • PHP 🐘
  • C# ☕️
  • Python 🐍

My expertise in front-end technologies like React, Angular, and Vue.js, combined with my knowledge of back-end frameworks like MVC .NET, Node.js, ReactJS, VueJS, and Laravel, enables me to build end-to-end solutions that meet the needs for my projects.

Latest Technologies

I'm always staying up-to-date with the latest technological advancements and experimenting with new tools and frameworks. Here are a few of my latest technology interests:

  • Artificial Intelligence - I believe that AI has the potential to revolutionize many industries and I'm excited to be a part of this movement.
  • Serverless - Serverless architecture is becoming increasingly popular and I'm interested in exploring how it can be used to build scalable and cost-effective applications.
  • Blockchain - I'm fascinated by the potential of blockchain technology and the opportunities it presents for creating decentralized applications.

Github Stats

Rashid's GitHub stats

Get in Touch

If you're looking for a dedicated and skilled developer who can help bring your ideas to life, feel free to reach out to me. I'm always up for a challenge!

php-htmldiff's People

Contributors

adamgoose avatar faceleg avatar gondo avatar jerray avatar rashid2538 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

Watchers

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

php-htmldiff's Issues

Undefined offset error

The following code:

$diff = new HtmlDiff(
    'This is a demonstration restaurant.',
    'This is a demonstration restaurant'
);
$diff->build();

Triggers the following error:

Undefined offset: 0 in HtmlDiff.php on line 269

Problem when part of text in anchor is taken out of anchor tag

I took a quick look at your demo and tried a few different string changes and noticed the following issues:

  1. When taking out text that was inside an anchor tag, the text that was taken out shows up in the compared html inside an anchor tag of its own rather than showing up with no anchor tag. For instance, when going from $html1 = Check <a href="http://google.com">this out</a>. to $html2 = Check <a href="http://google.com">this</a> out.
  2. When putting text that was outside of an anchor into an anchor (the opposite to the above example), the text that is now inside the anchor still shows up outside the anchor in the comparison html.
  3. Any change to the href or other attributes of an anchor is not indicated in any way in the comparison html. The most appropriate behavior would be to show the entire anchor element twice; first, the original anchor element inside a "del" tag, and second, the modified one inside an "ins" tag.

inefficient diff?

I run this on these two strings:

  1. "Lot of words"
  2. "not very many letters"

and I get the result:

Lotnot ofvery wordsmany letters

Instead of

Lot of wordsnot very many letters

Isn't this not very good?

Warning: count(): Parameter must be an array or an object that implements Countable .....

When running demo/index.php I see the following errors (multiple times):

Warning: count(): Parameter must be an array or an object that implements Countable in C:.....\vendor\php-htmldiff-master\HtmlDiff.php on line 360

Warning: count(): Parameter must be an array or an object that implements Countable in C:.....\vendor\php-htmldiff-master\HtmlDiff.php on line 266

wamp
PHP Version 7.3.12

Letters disappear, ins tag not closed

$a = new HtmlDiff('<p>1.1', 'test');
echo $a->build();

outputs:

<ins class='mod'><del class="diffmod">.1</del><ins class="diffmod">test</ins>

<p>1 is not shown as being removed, and the opening <ins class='mod'> tag is not closed.

Accents

It is not working with accents.

When I enter the values below

from = Crédito
to = Créditos

I get the result

Créditoditos

Instead of
CréditoCréditos

Detect new links

Hello,
first of all, thank you for this library !
I tested some of the script, and it seems not to be able to detect the link addition, like

$old_text = ''Some text without link"
$new_text = "Some text with link"

it marks the change on WITHOUT to WITH, but not the new anchor tag to LINK word.

Would it be possible to detect new tags added ? maybe just add some special class to them not any INS and DELs, but simply add "class='diff' " or whatever to mark that this exact element is new ? That would be great help.

Thank you

Issues upgrading to PHP8

Migrating to PHP8 will cause a problem with the use of the class name "Match".
Recommend you change the three occurrences to "HtmlDiffMatch".

Line 342 changed to:
$matches[] = new HtmlDiffMatch( count( $this->oldWords ), count( $this->newWords ), 0 );

Line 360:

if( count( $match ) != 0 ) {
	$operations[] = new Operation( 'equal', $match->StartInOld, $match->EndInOld(), $match->StartInNew, $match->EndInNew() );
}

changed to

$operations[] = new Operation( 'equal', $match->StartInOld, $match->EndInOld(), $match->StartInNew, $match->EndInNew() );

Line 428 changed to:
return $bestMatchSize != 0 ? new HtmlDiffMatch( $bestMatchInOld, $bestMatchInNew, $bestMatchSize ) : null;

Line 432 changed to:
class HtmlDiffMatch {

Special character problem

Hi,

I like you class, but I had a problem with german characters like ä, ü, ö.

Solution for me is, to replace the Explode funtion with the following code:

private function Explode( $value ) {
return preg_split('//u', $value);
}

That splits a string using UTF8 encoding.

A bug in InsertTag function.

In function InsertTag, here at line: if( preg_match( $words[ 0 ], $x ) ).

I think it should be preg_match( $words[ 0 ], $x ) => preg_match( $x, $words[ 0 ] ).

Project status

As title, this project has been inactive for about whiles.

And it also has the forked version of caxy/php-htmldiff.

Should I need to migrate to this forked one?

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.