summaryrefslogtreecommitdiff
path: root/mediawiki-matter
blob: 584e5f4f8f835c928e8c27352db9a702eff47707 (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. path('copyright.mw')->spew_utf8($2);
  16. s|^((?:.*?\n)?)(= Table of Contents(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
  17. path($outfile)->spew_utf8($_);
  18. 1;