Coder Social home page Coder Social logo

Detect new links about php-htmldiff HOT 1 CLOSED

rashid2538 avatar rashid2538 commented on July 30, 2024
Detect new links

from php-htmldiff.

Comments (1)

RadekHavelka avatar RadekHavelka commented on July 30, 2024

here is a code modification that works for me :

method InsertTag

almost end of the code, this

$this->content .= implode( "", $this->ExtractConsecutiveWords( $words, 'tag' ) ) . $specialCaseTagInjection;

needs to be replaces like this

                $workTag = $this->ExtractConsecutiveWords( $words, 'tag' );,

                if ($this->IsOpeningTag($workTag[0]) && !$this->IsClosingTag($workTag[0]))
                {
                    //i expect the tag to be first in the consecutiwe words array result, and I am looking only for opening tag to inject the class
                    if (strpos($workTag[0], 'class='))
                    {
                        //tag already contains class parameter, use it and add new class diffmod to it (two variant of apostrophes)
                        $workTag[0] = str_replace('class="', 'class="diffmod ', $workTag[0]);
                        $workTag[0] = str_replace("class='", "class='diffmod ", $workTag[0]);
                    }
                    else
                    {
                        //no class parameter, add before end of the tag >
                        $workTag[0] = str_replace(">", " class='diffmod'>", $workTag[0]);
                    }
                }
                //implode back together
                $this->content .= implode( "", $workTag ) . $specialCaseTagInjection;

this code produces something like < a href = 'something' class='diffmod' ... for the added tags (works for IMG tag as well)

This code may be extended in many ways, it cannot detect if the tag was added or changed, it always uses the diffmod class, but this is just a start for someone who knows better this code, than I :)

from php-htmldiff.

Related Issues (12)

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.