1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 02:42:40 +01:00
phorge-phorge/externals/cowsay/Wrap.pm.diff
epriestley c705c8011e Use PHP implementation of Cowsay for cowsay rule
Summary:
Ref T7785. Convert the Cowsay Remarkup rule to use a PHP implementation so we don't have to execute an external `cowsay` binary.

I removed some of the default ".cow" files that come with Cowsay because they:

  - include Perl code which we can not interpret; or
  - are primarily in-jokes or standalone visual puns or artwork rather than usable actors on the grand stage of cowsay; or
  - offended my delicate sensibilities.

Users can add new cows to `resources/cows/custom/` if they want to make new cows available.

I have included a majestic original artwork depicting the "Companion Cube" character from //Portal//.

Test Plan: {F802535}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9408, T7785

Differential Revision: https://secure.phabricator.com/D14100
2015-09-13 12:27:30 -07:00

47 lines
879 B
Diff

*** Wrap.pm.in Thu May 22 00:21:42 1997
--- Wrap.pm Fri Nov 12 10:00:15 1999
***************
*** 3,9 ****
require Exporter;
@ISA = (Exporter);
! @EXPORT = qw(wrap);
@EXPORT_OK = qw($columns);
$VERSION = 97.011701;
--- 3,9 ----
require Exporter;
@ISA = (Exporter);
! @EXPORT = qw(wrap fill);
@EXPORT_OK = qw($columns);
$VERSION = 97.011701;
***************
*** 66,71 ****
--- 66,90 ----
print "-----------$r---------\n" if $debug;;
return $r;
+ }
+
+ ## Copied up from below.
+ sub fill
+ {
+ my ($ip, $xp, @raw) = @_;
+ my @para;
+ my $pp;
+
+ for $pp (split(/\n\s+/, join("\n",@raw))) {
+ $pp =~ s/\s+/ /g;
+ my $x = wrap($ip, $xp, $pp);
+ push(@para, $x);
+ }
+
+ # if paragraph_indent is the same as line_indent,
+ # separate paragraphs with blank lines
+
+ return join ($ip eq $xp ? "\n\n" : "\n", @para);
}
1;