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

Reverse diff opcode #17

Description

@max13fr

Hello, a very good feature would be to get reverse diff opcodes.
I would like to log all changes in my forum (on subject or responses). But I don't keep the old version, only the newer. So I would like to compute old versions from the last version, not the opposite.

I try to switch arguments when calling FineDiff::getDiffOpcodes($from, $to) :

$firstVersion = "Test 123 - Heloa";
$newVersion = "Test 124 - Hello";
$opdiff = FineDiff::getDiffOpcodes($newVersion, $firstVersion)

But when I display, the difference (FineDiff::renderDiffToHTMLFromOpcodes), the modification are reversed (ins & del). So I tried something like :

$result = FineDiff::renderDiffToHTMLFromOpcodes($text, $opdiff);
// Replace ins by del & del by ins
$result = strtr($result, array('<del>' => '<ins>', '</del>' => '</ins>', '<ins>' => '<del>', '</ins>' => '</del>'));
// Swap ins & del
$result = preg_replace('#(<ins>.+?</ins>)(\s*)(<del>.+?</del>)#s', '$3$2$1', $result);

But, it's very ugly...
Could you do function FineDiff::getReverseDiffOpcodes for this case?

Thanks in advance,
Best Regards, Max

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions