summaryrefslogtreecommitdiff
path: root/mediawiki-matter
blob: 04f5393af149b4223e3a08548dbbb8542bd63dc1 (plain)
  1. #!/usr/bin/perl
  2. # separate frontmatter pieces from mainmatter
  3. use warnings;
  4. use strict;
  5. use Path::Tiny;
  6. use HTML::HTML5::Entities;
  7. my $infile = shift;
  8. my $outfile = shift || $infile;
  9. $_ = path($infile)->slurp_utf8;
  10. s|^((?:.*?\n)?)(= Preface(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
  11. path('preface.mw')->spew_utf8($2);
  12. s|^((?:.*?\n)?)(= Foreword(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
  13. path('foreword.mw')->spew_utf8($2);
  14. s|^((?:.*?\n)?)(= Copyright(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
  15. s|^((?:.*?\n)?)(= Table of Contents(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
  16. path($outfile)->spew_utf8($_);
  17. 1;