blob: 584e5f4f8f835c928e8c27352db9a702eff47707 (
plain)
- #!/usr/bin/perl
- # separate frontmatter pieces from mainmatter
- use warnings;
- use strict;
- use Path::Tiny;
- use HTML::HTML5::Entities;
- my $infile = shift;
- my $outfile = shift || $infile;
- $_ = path($infile)->slurp_utf8;
- s|^((?:.*?\n)?)(= Preface(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
- path('preface.mw')->spew_utf8($2);
- s|^((?:.*?\n)?)(= Foreword(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
- path('foreword.mw')->spew_utf8($2);
- s|^((?:.*?\n)?)(= Copyright(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
- path('copyright.mw')->spew_utf8($2);
- s|^((?:.*?\n)?)(= Table of Contents(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
- path($outfile)->spew_utf8($_);
- 1;
|