diff options
Diffstat (limited to 'mediawiki-matter')
-rwxr-xr-x | mediawiki-matter | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/mediawiki-matter b/mediawiki-matter index 04f5393..402e430 100755 --- a/mediawiki-matter +++ b/mediawiki-matter @@ -1,6 +1,6 @@ #!/usr/bin/perl -# separate frontmatter pieces from mainmatter +# reorganize frontmatter use warnings; use strict; @@ -13,16 +13,12 @@ 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); +# swap sections → Copyright, TOC, Foreword, Preface +s|^((?:.*?\n)?)(= Preface(?:(?!\n=).)*\n)(= Copyright(?:(?!\n=).)*\n)(= Table(?:(?!\n=).)*\n)(= Foreword(?:(?!\n=).)*\n)(=.*)$|$1$3$4$5$2$6|s; +# drop section Copyright s|^((?:.*?\n)?)(= Copyright(?:(?!\n=).)*\n)(=.*)$|$1$3|s; -s|^((?:.*?\n)?)(= Table of Contents(?:(?!\n=).)*\n)(=.*)$|$1$3|s; - path($outfile)->spew_utf8($_); 1; |