#!/bin/bash
#shellcheck disable=SC1090
. "$(sfpath)" || exit 3
shellfu import pretty
usage() {
mkusage "$@" "[options] FILE" \
-- \
"Open Markdown file FILE in vimb (no junk)." \
-o \
"-C DIR Use DIR as config directory root. Default is" \
" \$HOME/.config/mdvimb." \
"-S STYLE Add CSS style STYLE to the final HTML (this"\
" implies -w). If STYLE contains slash, it will" \
" be interpreted as path, otherwise a file called"\
" STYLE.css is looked up in 'css' directory of" \
" configuration directory. Default is to not add"\
" style." \
"-c CONV_BIN Use converter CONV_BIN, which must be" \
" a program that when called without arguments," \
" accepts Markdown on standard input and prints" \
" HTML to standard output. Default is 'Markdown'."\
"-d Enable debugging output." \
"-n Don't open, just print HTML." \
"-w Wrap the generated HTML with basic HTML5 tags" \
" such as
and" \ "
. Default is to leave the HTML as is." \ "-v Enable verbose output." \ "--help Print this help text and exit." \ -- \ "Default values of options -C, -S and -c can be changed"\ "by setting environment variables MDVIMB__CONFIG_HOME," \ "MDVIMB__STYLE and MDVIMB__CONVERTER, respectively." } MDVIMB__CONVERTER=${MDVIMB__CONVERTER:-Markdown} MDVIMB__CONFIG_HOME=${MDVIMB__CONFIG_HOME:-$HOME/.config/mdvimb} MDVIMB__STYLE=${MDVIMB__STYLE:-} browseopen() { # # Open stdin in vimb # $NoOpen && { cat; return 0; } think "opening vimb" vimb - "$@" } mkwrap() { # # Create wrapper part $1 if needed # local part=$1 case $part in link) mkcssref >/dev/null || return 0 think "adding CSS style: $Style" echo ' ' ;; title) case $MdFile in "") echo '
' ;; *) echo "
" ;; esac ;; head) echo '' echo '' echo '
' mkwrap title mkwrap link echo ' ' echo '