From 896a782ee7502909b8a476d7c8766d90b18e1660 Mon Sep 17 00:00:00 2001 From: lshprung Date: Sat, 18 Dec 2021 09:28:18 -0800 Subject: Changed method to get CSS --- markdown-to-github-html.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/markdown-to-github-html.sh b/markdown-to-github-html.sh index f320a6e..a8b9e37 100755 --- a/markdown-to-github-html.sh +++ b/markdown-to-github-html.sh @@ -2,6 +2,7 @@ NAME="$0" CSS_LINK="https://raw.githubusercontent.com/sindresorhus/github-markdown-css/gh-pages/github-markdown.css" +CSS_PATH="./github-markdown.css" INPUT="/dev/stdin" CUSTOM_INPUT=0 OUTPUT="/dev/stdout" @@ -13,10 +14,11 @@ print_help() { echo "Usage: $NAME [OPTION]... [INPUT]" echo "Compile INPUT markdown file to github-styled html" echo "" - echo " --compiler [COMPILER] set the markdown compiler to use. Default is marked --gfm" + echo " --compiler COMPILER set the markdown compiler to use. Default is marked --gfm" + echo " -c, --css CSS_PATH set the github-markdown.css file path (by default github-markdown.css in the CWD)" echo " -h, --help print this help message" - echo " -i, --input [INPUT] specify INPUT file" - echo " -o, --output [OUTPUT] output to specified OUTPUT file" + echo " -i, --input INPUT specify INPUT file" + echo " -o, --output OUTPUT output to specified OUTPUT file" echo " -y, --yes automatic yes to prompts" } @@ -27,6 +29,10 @@ while [ $# -gt 0 ]; do COMPILER="$2" shift 2 ;; + -c | --css) + CSS_PATH="$2" + shift 2 + ;; -h | --help) print_help exit 1 @@ -67,20 +73,20 @@ if [ $CUSTOM_OUTPUT -eq 1 ] && [ -e "$OUTPUT" ]; then fi fi -# Prompt to download CSS file if not in CWD or same directory as NAME -if [ ! -e "github-markdown.css" ] || [ ! -e "$(dirname "$NAME")/github-markdown.css" ]; then +# Prompt to download CSS file if not in CWD/specified CSS_PATH +if [ ! -e "$CSS_PATH" ]; then if [ $YES -eq 0 ]; then - echo -n "Download github-markdown.css to current working directory? [Y/n] " + echo -n "Download github-markdown.css to $CSS_PATH? [Y/n] " read -r PROMPT fi if [ ! "$PROMPT" = "n" ]; then - wget "$CSS_LINK" + wget "$CSS_LINK" -O "$CSS_PATH" fi fi # Add meta, link, and style lines to OUTPUT echo "" >> "$OUTPUT" -echo "" >> "$OUTPUT" +echo "" >> "$OUTPUT" echo "" >> "$OUTPUT" echo "
" >> "$OUTPUT" # Add body (from markdown) using compiler (default is marked --gfm) -# TODO work on getting syntax highlighting support $COMPILER "$INPUT" >> "$OUTPUT" # Close output -- cgit