summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYigit Sever2021-10-19 16:21:13 +0300
committerYigit Sever2021-10-19 16:21:13 +0300
commit49217626ab947b7bc8cf2f5b9d8bc821cc565358 (patch)
tree4476c6615437502458fb58ff2ee8147b1133c8e7
parenta0a3fe2d4119ed55d25ce24a6af08ed176ddd7f3 (diff)
downloaddotfiles-49217626ab947b7bc8cf2f5b9d8bc821cc565358.tar.gz
dotfiles-49217626ab947b7bc8cf2f5b9d8bc821cc565358.tar.bz2
dotfiles-49217626ab947b7bc8cf2f5b9d8bc821cc565358.zip
sentences: support vimwiki headers
-rwxr-xr-x.local/bin/sentences10
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
5my $pont = qr{[.!?]+}; ## punctuation 5my $pont = qr{[.!?]+}; ## punctuation
6my $abrev = qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abbreviations 6my $abrev = qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abbreviations
7my $header = qr{(=+ .*? =+)};
7 8
8$/ = ""; 9$/ = "";
9 10
10while(<>) { 11while(<>) {
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}