-
-
Notifications
You must be signed in to change notification settings - Fork 51
New Renderer #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Renderer #22
Conversation
Signed-off-by: Jack Cherng <[email protected]>
Signed-off-by: Jack Cherng <[email protected]>
I just do some coding style tweaks in the |
Coding style tweaks
awesome! currently i'm working on a new JSON renderer for less storage volume in DB. Maybe you can allow users to use their own renderers from their namespaces and add all of the current renderers as an example in v7? I think the repo will be more robust & customizable that way. What do you think? It will require lots of work though but i'm sure that this lib will be the one when it comes to diff implementation in PHP. |
Eventually, I think it's much easier to not take care about line numbers just like what GitHub does... I kinda feel that diff on "article" is totally different from diff on "codes" right now. Feel like doing a monkey patch. The following is how the The thought about dealing with a "replace" block is to treat them as "a line with |
Users should already can do it. I didn't actually try it but basically you just do not use the // custom usage
$differ = new Differ(explode("\n", $old), explode("\n", $new), $differOptions);
$renderer = new MyRenderer($rendererOptions);
$result = $renderer->render($differ); Your renderer must implements the RendererInterface. |
I notice that GitHub's diff uses |
I noticed diff2html library also uses the table layout. Maybe you just can implement some scrollbar like that lib does. |
d079960
to
0394a74
Compare
I finished new JSON format but it can't be used in this repo because of https://www.diffchecker.com/hWRMcRDB It's not duplicating context lines and can be useful for custom projects. I did this for my Flarum forum extension because Flarum itself is not ignoring whitespaces & cases either. I coudn't find any other way to do this new I also implemented diff2html library's layout without any problems, it fits well and looks beautiful by the way. |
Thanks. I have written some inspirations down in the project page. So if v7 ever happens, there are some thoughts.
We can do some checking in
Yeah. I think people don't use those options in 99% cases. Those options are more like because they were there or seen in other diff softwares.
I cannot figure out a good way to make it work with line numbers. #22 (comment) is the best result I can get.
I try to make this lib unrelated (or less related) to frontend thing (I am lame in writing maintainable CSS) but for HTML renderer output, it has spoke itself (it's for frontend). If the user uses Vue.js, React.js or other templating lib, he/she may use the JSON output to write the layout in the frontend, which I think is more flexible. |
I will use this in production without line numbers but i think it shouldn't print the new line here, because the old line already indicates the deleted part: |
I am not able to reproduce on my But it may not directly usable for you since your |
I have changed the algorithm so I have also fixed the behavior when |
4c74aa9
to
8b89bbc
Compare
fe01bb0
to
2277a98
Compare
Thanks. That's see how it will actually works. 🎆
|
looks beautiful 🤩 i'll implement it in Flarum extension later today. Thanks! |
@the-turk Yes, confirmed. 8adc4f0 should fix it. |
#22 (comment) Signed-off-by: Jack Cherng <[email protected]>
#22 (comment) Signed-off-by: Jack Cherng <[email protected]>
#22 (comment) Signed-off-by: Jack Cherng <[email protected]>
#22 (comment) Signed-off-by: Jack Cherng <[email protected]>
#22 (comment) Signed-off-by: Jack Cherng <[email protected]>
#22 (comment) Signed-off-by: Jack Cherng <[email protected]>
#22 (comment) Signed-off-by: Jack Cherng <[email protected]>
for #20
This is the updated version for
Combined
renderer (name could be changed).Basically it will find
</del>
closures in old lines and change them with new parts and their delimiters in new lines.Old:
Hello world.
New:
Hello test.
Outputs:
Hello <del>world</del><ins>test</ins>.
Needs discussion & further testing.