summaryrefslogtreecommitdiff
path: root/mediawiki-matter
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2015-01-04 12:50:17 +0100
committerJonas Smedegaard <dr@jones.dk>2015-01-04 12:50:17 +0100
commit3eb8cb8867f083047c277527e83692cfaa479613 (patch)
treed3dc711d537ebe0257e813724d71658f31240bf8 /mediawiki-matter
parentbc7c640e0db0328964a47c5cacf55b621779f611 (diff)
Split and reorganize frontmatter.
Diffstat (limited to 'mediawiki-matter')
-rwxr-xr-xmediawiki-matter29
1 files changed, 29 insertions, 0 deletions
diff --git a/mediawiki-matter b/mediawiki-matter
new file mode 100755
index 0000000..584e5f4
--- /dev/null
+++ b/mediawiki-matter
@@ -0,0 +1,29 @@
+#!/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;