diff options
author | Yigit Sever | 2021-10-19 16:21:13 +0300 |
---|---|---|
committer | Yigit Sever | 2021-10-19 16:21:13 +0300 |
commit | 49217626ab947b7bc8cf2f5b9d8bc821cc565358 (patch) | |
tree | 4476c6615437502458fb58ff2ee8147b1133c8e7 /.local/bin/sentences | |
parent | a0a3fe2d4119ed55d25ce24a6af08ed176ddd7f3 (diff) | |
download | dotfiles-49217626ab947b7bc8cf2f5b9d8bc821cc565358.tar.gz dotfiles-49217626ab947b7bc8cf2f5b9d8bc821cc565358.tar.bz2 dotfiles-49217626ab947b7bc8cf2f5b9d8bc821cc565358.zip |
sentences: support vimwiki headers
Diffstat (limited to '.local/bin/sentences')
-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 | } |