Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update mmd_merge

  • Loading branch information...
commit e8bef8913ba9f1f2ebd51faa1bafabeac17f19dc 1 parent 8606a13
Fletcher T. Penney authored
Showing with 26 additions and 7 deletions.
  1. +26 −7 Utilities/mmd_merge.pl
View
33 Utilities/mmd_merge.pl
@@ -16,10 +16,32 @@
my $data = "";
my $line = "";
-foreach(@ARGV) {
- open(INPUT, "<$_");
+my $count = @ARGV;
+
+if ($count == 0) {
+ # We're in "stdin mode"
+
+ # process stdin
+ undef $/;
+ my $data .= <>;
+
+ mergeLines($data);
+} else {
+ foreach(@ARGV) {
+ open(INPUT, "<$_");
+ local $/;
+ my $data = <INPUT>;
+ close(INPUT);
+ mergeLines($data);
+ }
+}
+
- while ($line = <INPUT>) {
+sub mergeLines {
+ my $file = shift;
+
+ while ($file =~ /^(.*?)$/mg) {
+ $line = $1;
if (($line !~ /^\s*$/) && ($line !~ /^\#/)) {
$line =~ s/ {4}/\t/g;
$line =~ s/\s*$//;
@@ -39,12 +61,9 @@
}
}
- close INPUT;
+ print $data;
}
-print $data;
-
-
=head1 NAME
mmd_merge.pl - Combine text documents to create a MultiMarkdown structured
Please sign in to comment.
Something went wrong with that request. Please try again.