Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

arch::diffparser(3pm) [debian man page]

Arch::DiffParser(3pm)					User Contributed Perl Documentation				     Arch::DiffParser(3pm)

NAME
Arch::DiffParser - parse file's diff and perform some manipulations SYNOPSIS
use Arch::DiffParser; my $dp = Arch::DiffParser->new; # usable for "annotate" functionality my $changes = $dp->parse_file("f.diff")->changes; $dp->parse($diff_content); $dp->parse("--- f1.c 2005-02-26 +++ f2.c 2005-02-28 ..."); # prints "f1.c, f2.c" printf "%s, %s ", $dp->filename1, $dp->filename2; # enclose lines in <span class="patch_{mod,orig,line,add,del}"> my $html = $dp->markup_content; DESCRIPTION
This class provides a limited functionality to parse a single file diff in unified format. Multiple diffs may be parsed sequentially. The parsed data is stored for the last diff, and is replaced on the following parse. METHODS
The following class methods are available: new, parse, parse_file, content, lines, filename1, filename2, mtime1, mtime2, hunks, changes. new Construct the "Arch::DiffParser" instanse. parse diff_content Parse the diff_content and store its parsed data. parse_file diff_filename Like parse, but read the diff_content from diff_filename. diff_data Return hashref containing certain parsed data. Die if called before any parse methods. The keys are: "lines", "filename1", "filename2", "mtime1", "mtime2", "hunks", "changes". The value of "hunks" and "changes" is arrayref of arrayrefs with 5 elements: [ line-number-1, num-lines-1, line-number-2, num-lines-2, "lines"-index ]. A "hunk" describes a set of lines containing some combination of unmodified, deleted and added lines, a "change" describes an inter- hunk atom that only contains zero or more deleted lines and zero or more added lines. lines filename1 filename2 mtime1 mtime2 hunks changes These methods are just shortcuts for diff_data->{method}. content [%args] Return content of the last diff. %args keys are "fileroot1" and "fileroot2"; if given, these will replace the subdirs "orig" and "mod" that arch usually uses in the filepaths. markup_content [%args] Like content, but every non-context line is enclosed into markup <span class="patch_name">line</span>, where name is one of "orig" (filename1), "mod" (filename2), "line" (hunk linenums), "add" (added), del (deleted). Not implemented yet. BUGS
No support for newlines in source file names yet. AUTHORS
Mikhael Goikhman (migo@homemail.com--Perl-GPL/arch-perl--devel). SEE ALSO
For more information, see Text::Diff::Unified, Algorithm::Diff. perl v5.10.1 2005-03-09 Arch::DiffParser(3pm)

Check Out this Related Man Page

Arch::FileHighlighter(3pm)				User Contributed Perl Documentation				Arch::FileHighlighter(3pm)

NAME
Arch::FileHighlighter - syntax-highlight file's content using markup SYNOPSIS
use Arch::FileHighlighter; my $fh = Arch::FileHighlighter->new( [ 'internal(pm+c)', 'none(txt), 'enscript', 'internal', ] ); my $html_ref = $fh->highlight($0); print $$html_ref; print ${$fh->highlight('file.c', '/* some code */')}; DESCRIPTION
This class processes file contents and produces syntax highlighting markup. This may be used together with css that defines exact text colors and faces. The default is to use the builtin "internal" processing, that is pretty poor; only very basic file types and syntax constructions are supported. It is suggested to configure and use the external "enscript" utility. GNU enscript understands quite a rich number of file types and produces a useful syntax highlighting. "enscript" filter is used by default if /usr/bin/enscript is found. It is possible to configure different filters ("none", "internal", "enscript") depending on file name extension. In any case the resulting markup is always unified, i.e. all special characters are HTML-encoded using SGML entities, and the markup that looks like <spanclass="syntax_foo">bar</span> is used. METHODS
The following methods are available: new, instance, highlight. new [filters] Create a new instance of Arch::FileHighlighter. filters is arrayref of strings of the form filter(ext1+ext2+...)", where filter is one of "enscript", "internal" or "none". Special extension ":xml" is a shortcut for "html+htm+sgml+xml+wml+rss+glade". The filters optionally constrained by file extensions are probed sequentially and the first passed one is used. Note that if enscript is configured in the sequence, but is not installed, then its probing may print a warning to stderr. The "enscript" filter is handled a bit specially, it may take parameters "mono" (less colors) and "asis" instead of the file extensions. If enscript returns html without any tags, then the filter is handled as failed, unless "asis" is given. By default, filters is [ 'internal' ], or [ 'enscript', 'internal' ] depending on presense of '/usr/bin/enscript'. instance [filters] Alternative constructor. Return the last created instance of Arch::FileHighlighter or create a new one. The purpose of this alternative constructor is to allow the singleton behaviour as well as certain Aspect Oriented Programming practices. highlight filename [content] Process filename using configured filters (as described in the constructor) and produce the file content with embeded <span class="class">...</span> markup. class is one of: syntax_keyword syntax_builtin syntax_comment syntax_special syntax_funcdef syntax_vartype syntax_string syntax_constant If content is provided (either string or reference to string), it is used, otherwise the content of filename is loaded. BUGS
Awaiting for your reports. AUTHORS
Mikhael Goikhman (migo@homemail.com--Perl-GPL/arch-perl--devel). SEE ALSO
For more information, see enscript, Arch::Util, Syntax::Highlight::Perl. perl v5.10.1 2005-10-23 Arch::FileHighlighter(3pm)
Man Page