Comments (1)
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)
- License missing HOT 2
- Undefined offset error HOT 3
- inefficient diff? HOT 3
- Accents
- Project status HOT 4
- Special character problem HOT 5
- Problem when part of text in anchor is taken out of anchor tag
- Warning: count(): Parameter must be an array or an object that implements Countable ..... HOT 1
- Issues upgrading to PHP8
- Letters disappear, ins tag not closed
- A bug in InsertTag function. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-htmldiff.