feat(fish): add markdown to HTML converter

Amolith created

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`.

Change summary

dot_config/private_fish/functions/md2html.fish | 27 ++++++++++++++++++++
1 file changed, 27 insertions(+)

Detailed changes

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