blob: 7e9fd9cd54768e75be32369dfda38419f575d8b4 (
plain)
- #!/usr/bin/perl
- # normalize Markdown
- use Getopt::Long;
- use File::Slurp;
- use Lingua::Sentence;
- use strict;
- use warnings;
- use charnames ':full';
- # 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{HORIZONTAL ELLIPSIS}\))/\n$1/mg;
- s/(\(\N{HORIZONTAL ELLIPSIS}\))\h+/$1\n/mg;
- write_file( $stem . '.mdwn', $_ );
- print "DONE: $0 stem $stem\n";
|