1 #!/bin/bash
   2 
   3 cd ~/Projects/lexa.by/bloge
   4 
   5 post=~/.cache/post.md
   6 news=2018/news.txt
   7 
   8 [[ $1 ]] &&
   9 sed 's/\\n/\n/g;'$1'q;d' $news |
  10 pandoc -f html -o $post ||
  11 date +'%F %T|' > $post
  12 
  13 cp $post $post.orig
  14 ${EDITOR:-vim} $post
  15 diff $post* && exit
  16 
  17 date=$(sed 1q $post)
  18 body=$(sed 1d $post | pandoc -St html5)
  19 body=${body//“/«}
  20 body=${body//”/»}
  21 body=${body//$'\n'/\\\\n}
  22 
  23 sed -i "${1:-$}a\\$date$body" $news
  24 [[ $1 ]] && sed -i $1d $news
  25 
  26 ./build.php
[raw]