scripts

My personal collection of scripts
git clone git://src.gearsix.net/scripts
Log | Files | Refs | Atom | README | LICENSE

commit b944444a614d419ffd4321742465ec185f8af2a1
parent e2e8f8e8ea9ed219ae1a9c8a3d0dd836da6962e8
Author: GeaRSiX <gearsix.net>
Date:   Fri, 12 Jun 2020 15:49:25 +0100

added preview-md

Diffstat:
MREADME.md | 1+
Asrc/preview-md.sh | 17+++++++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -63,6 +63,7 @@ Scripts related to string parsing/manipulation ### misc - **while-true** - clear the terminal, run $1 sleep ($2 || 1), repeat forever (Ctrl+C to cancel) +- **preview-md** - convert a markdown file ($1) to html, open if $2 == "-o" or "--open". Uses cmark by default, set conversion tool and default output destination in src. ### depreciated diff --git a/src/preview-md.sh b/src/preview-md.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# preview-md (preview markdown) +# DESCRIPTION: convert a markdown file $1 to html, optionall open in a browser (if $2 == --open). Set converter in src (cmark by default). +# e.g.$ preview-md README.md --open + +mdconv=cmark +out=~/tmp/README.html + +${mdconv} $1 >> $out +if [ $? -eq 0 ]; then + echo "succesfully converted to $out" + if [ ! -z $2 ] && [ $2 = "--open" ] || [ $2 = "-o" ]; then + xdg-open $out &>/dev/null + fi +else + echo "$mdconv returned $?" +fi