@@ -1,27 +0,0 @@
-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
@@ -0,0 +1,90 @@
+function mdas
+ set DIR "$HOME/LLM Responses"
+ mkdir -p $DIR
+ pushd $DIR
+
+ set exit_status 0
+
+ # Parse command line arguments
+ argparse 'p/pdf' 'h/html' 'e/epub' -- $argv
+ or begin
+ echo "Usage: mdas [-p|--pdf] [-h|--html] [-e|--epub]" >&2
+ echo "At least one format flag must be specified." >&2
+ popd
+ return 1
+ end
+
+ # Check if at least one format is specified
+ if not set -q _flag_pdf; and not set -q _flag_html; and not set -q _flag_epub
+ echo "Error: At least one format flag (-p, -h, or -e) must be specified." >&2
+ popd
+ return 1
+ end
+
+ read -z CONTENT
+ set FILENAME (echo "$CONTENT" | llm -f - -t 'srht:~amolith/filename')
+ set TITLE (llm -c "Give me that same file name but now in conversation case. For example, 'Port-out PIN implementation spec', but without quotes. The first letter should be capitalized, proper nouns capitalized, and most everything else lowercased.")
+
+ # remove path traversal, special chars, limit length
+ set FILENAME (echo "$FILENAME" | sed 's/[^a-zA-Z0-9._-]/_/g' | sed 's/\.\.//g' | cut -c1-200)
+ # remove potentially dangerous chars but keep spaces
+ set TITLE (echo "$TITLE" | sed 's/[<>&"'\''`]//g' | sed 's/\$//g' | cut -c1-200)
+
+ set date "$(date +%Y-%m-%d)"
+ set header "---
+title: $TITLE
+date: $date
+mainfont: Atkinson Hyperlegible Next
+sansfont: Atkinson Hyperlegible Next
+monofont: 0xProto
+---"
+
+ set CONTENT "$header
+
+$CONTENT"
+
+ echo $CONTENT > "$FILENAME.md"
+
+ if not prettier -w --parser markdown --no-editorconfig --no-config "$FILENAME.md"
+ echo "Error: prettier failed" >&2
+ set exit_status 1
+ else
+ echo "$FILENAME.md"
+ end
+
+ # Convert to HTML if requested
+ if test $exit_status -eq 0; and set -q _flag_html
+ if not pandoc --from markdown --to html -so "$FILENAME.html" "$FILENAME.md"
+ echo "Error: HTML conversion failed" >&2
+ set exit_status 1
+ else
+ echo "$FILENAME.html"
+ end
+ end
+
+ # Convert to PDF if requested
+ if test $exit_status -eq 0; and set -q _flag_pdf
+ if not pandoc --pdf-engine=xelatex --from markdown --to pdf --epub-title-page=false -o "$FILENAME.pdf" "$FILENAME.md"
+ echo "Error: PDF conversion failed" >&2
+ set exit_status 1
+ else
+ echo "$FILENAME.pdf"
+ end
+ end
+
+ # Convert to EPUB if requested
+ if test $exit_status -eq 0; and set -q _flag_epub
+ if not pandoc --from markdown --to epub -o "$FILENAME.epub" "$FILENAME.md"
+ echo "Error: EPUB conversion failed" >&2
+ set exit_status 1
+ else
+ echo "$FILENAME.epub"
+ end
+ end
+
+ popd
+
+
+
+ return $exit_status
+end