Skip to content
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

Support terminal and HTML markup #1

Open
nichtich opened this issue Jul 5, 2012 · 3 comments
Open

Support terminal and HTML markup #1

nichtich opened this issue Jul 5, 2012 · 3 comments

Comments

@nichtich
Copy link

nichtich commented Jul 5, 2012

Right now one must always define DEFAULT_MARKS by hand which is cumbersome. For instance in every script one must write:

use Term::ANSIColor;

%String::Diff::DEFAULT_MARKS = ( 
    remove_open  => color('red'),
    remove_close => color('reset'),
    append_open  => color('green'),
    append_close => color('reset'),
);

This module should provide some default markup settings as easy options, for instance:

    use String::Diff qw(diff html); # sets DEFAULT_MARKS to html
    use String::Diff qw(diff ansi); # sets DEFAULT_MARKS to ansi

    diff($s1,$s2, syntax => 'html');
    diff($s1,$s2, syntax => 'ansi');
@yappo
Copy link
Owner

yappo commented Jul 6, 2012

I want to reduce the dependence.
If there is a possibility, only to add to the document.

use Term::ANSIColor;
%String::Diff::DEFAULT_MARKS = (
remove_open => color('red'),
remove_close => color('reset'),
append_open => color('green'),
append_close => color('reset'),
);

@nichtich
Copy link
Author

nichtich commented Jul 7, 2012

Term::ANSIColor is a core module, so you don't add any additional dependency. Moreover you can just use fixed strings (also for HTML). Anyway, I use modules for not having to write the same lengthy code to every script. String::Diff should make common use cases (ANSI color markup, HTML markup) quick and simple with a single option or parameter.

@yappo
Copy link
Owner

yappo commented Aug 23, 2015

You may need OOPish interface.

my $differ = String::Diff->new(
    remove_open => color('red'),
    remove_close => color('reset'),
    append_open => color('green'),
    append_close => color('reset'),
);
my $result = $differ->diff($old, $new);

But I'm too late response...

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

No branches or pull requests

2 participants