summaryrefslogtreecommitdiff
path: root/mkmd2mdwn-default
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2013-05-10 20:46:04 +0200
committerJonas Smedegaard <dr@jones.dk>2013-05-10 20:46:04 +0200
commit27d338dec0428bc22e2838eb8641c6e0d1681e22 (patch)
tree18eeb76e189ce03838dd9b23194f1c707b1eabbb /mkmd2mdwn-default
Include mk* scripts
Diffstat (limited to 'mkmd2mdwn-default')
-rwxr-xr-xmkmd2mdwn-default35
1 files changed, 35 insertions, 0 deletions
diff --git a/mkmd2mdwn-default b/mkmd2mdwn-default
new file mode 100755
index 0000000..588b61e
--- /dev/null
+++ b/mkmd2mdwn-default
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+# normalize Markdown
+
+use Getopt::Long;
+use File::Slurp;
+use Lingua::Sentence;
+
+use strict;
+use warnings;
+
+# setup sentence splitter
+my $splitter = Lingua::Sentence->new("en");
+
+my $force;
+GetOptions ("force|f");
+
+my $stem = shift;
+$_ = read_file( $stem . '.md' );
+
+# join non-headline multi-lines
+s/([^\n=])\n/$1 /g;
+#s/(?<=[\S^=])\h*\n(?=[\S^=])/ /g;
+
+# split into sentences
+$_ = $splitter->split($_);
+
+# split after comma, and before and after ellipsis
+#s/,\s(?=[^\v=]*\v)/,\n/mg;
+s/\h+(\(…\))/\n$1/mg;
+s/(\(…\))\h+/$1\n/mg;
+
+write_file( $stem . '.mdwn', $_ );
+
+print "DONE: $0 stem $stem\n";