From 3eb8cb8867f083047c277527e83692cfaa479613 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 4 Jan 2015 12:50:17 +0100 Subject: Split and reorganize frontmatter. --- mediawiki-matter | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 mediawiki-matter (limited to 'mediawiki-matter') 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; -- cgit v1.2.3