blob: 04f5393af149b4223e3a08548dbbb8542bd63dc1 (
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;
- s|^((?:.*?\n)?)(= Table of Contents(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
- path($outfile)->spew_utf8($_);
- 1;
|