From 8bad66e1db626ffd9c9382dbdab0212204efa1f6 Mon Sep 17 00:00:00 2001 From: Amolith Date: Wed, 4 Jun 2025 09:59:52 -0600 Subject: [PATCH] feat(fish): add markdown to HTML converter Provides `md2html` fish function. This function converts Markdown content from stdin to an HTML file. It uses `prettier` for formatting, `pandoc` for conversion, and then opens the generated HTML with `xdg-open`. Temporary files are stored in `~/Downloads/tmp/responses`. --- .../private_fish/functions/md2html.fish | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 dot_config/private_fish/functions/md2html.fish diff --git a/dot_config/private_fish/functions/md2html.fish b/dot_config/private_fish/functions/md2html.fish new file mode 100644 index 0000000000000000000000000000000000000000..18b68edc5b5b349974d62caffccc0ac227a9b7b9 --- /dev/null +++ b/dot_config/private_fish/functions/md2html.fish @@ -0,0 +1,27 @@ +function md2html + set NAME (eow) + set DIR ~/Downloads/tmp/responses + set FILENAME "$DIR/$NAME.md" + + mkdir -p $DIR + cat > $FILENAME + + cd $DIR + + if not prettier -w --parser markdown --prose-wrap always --no-editorconfig --no-config "$NAME.md" + echo "Error: prettier failed" >&2 + return 1 + end + + if not pandoc -so "$NAME.html" "$NAME.md" + echo "Error: pandoc failed" >&2 + return 1 + end + + if not xdg-open "$NAME.html" + echo "Error: xdg-open failed" >&2 + return 1 + end + + echo "Successfully created and opened $NAME.html" +end