diff options
-rwxr-xr-x | .local/bin/sentences | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/.local/bin/sentences b/.local/bin/sentences index 75314f5..cc21d3b 100755 --- a/.local/bin/sentences +++ b/.local/bin/sentences | |||
@@ -4,15 +4,17 @@ use strict; | |||
4 | 4 | ||
5 | my $pont = qr{[.!?]+}; ## punctuation | 5 | my $pont = qr{[.!?]+}; ## punctuation |
6 | my $abrev = qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abbreviations | 6 | my $abrev = qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abbreviations |
7 | my $header = qr{(=+ .*? =+)}; | ||
7 | 8 | ||
8 | $/ = ""; | 9 | $/ = ""; |
9 | 10 | ||
10 | while(<>) { | 11 | while(<>) { |
11 | chomp; ## for each paragraph, | 12 | chomp; ## for each paragraph, |
12 | 13 | ||
13 | s/\h*\n\h*/ /g; ## remove \n | 14 | s/\h*\n\h*/ /g; ## remove \n |
14 | s/($pont)\h+(\S)/$1\n$2/g; ## punctuation+space | 15 | s/($pont)\h+(\S)/$1\n$2/g; ## punctuation+space |
15 | s/($abrev)\n/$1 /g; ## undo \n after abbreviations | 16 | s/($abrev)\n/$1 /g; ## undo \n after abbreviations |
17 | s/$header\h+(\S)/$1\n$2/g; ## vimwiki headers | ||
16 | 18 | ||
17 | print "$_\n"; | 19 | print "$_\n"; |
18 | } | 20 | } |