Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

WISHLIST:Override <del> and <ins> html tags #14

Open
maysara opened this issue Dec 20, 2013 · 2 comments
Open

WISHLIST:Override <del> and <ins> html tags #14

maysara opened this issue Dec 20, 2013 · 2 comments

Comments

@maysara
Copy link

maysara commented Dec 20, 2013

It would be great if the <del> </del> and <ins> </ins> tags can be over ridden; it would also be nice then if the function name would change to something like renderDiffToMarkup.

This is very useful if one wants to create entries that include styling within the tag and not in css , or even use it for non html , such as generating svg or other XML or non XML markup documents.

@toxalot
Copy link

toxalot commented Apr 2, 2014

This is already an option. Quoting from README.

It is also possible to provide a custom renderer through a user supplied callback
function/method:

FineDiff::renderFromOpcodes($from, $opcodes, $callback);

For example, you could use something like this:

$opcodes = FineDiff::getDiffOpcodes($from_text, $to_text);
$callback = function ($opcode, $from, $from_offset, $from_len) {
    $fragment = substr($from, $from_offset, $from_len);
    if ($opcode == 'd') {
        // do something with removed fragment
    }
    elseif ($opcode == 'i') {
        // do something with inserted fragment
    }
    else {
        // do something with copied fragment
    }
};
FineDiff::renderFromOpcodes($from_text, $opcodes, $callback);

@asleepwalker
Copy link

https://gist.github.com/asleepwalker/fb46883e88a3a44af786
Maybe it will be helpful for someone.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants