Skip to content

Commit

Permalink
Merge pull request #100 from davcam/markdownPreview
Browse files Browse the repository at this point in the history
contrib: add a simple markdown preview script
  • Loading branch information
sminez authored Mar 6, 2025
2 parents 8ae8351 + 36f2f7a commit f70de21
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions data/contrib/sh/markdown-preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# A simple ad helper script to preview markdown in ad using pandoc and w3m

. "$HOME/.ad/lib/ad.sh"

requireAd

processMarkdown() {
clearBuffer "$1"
bufRead "$2" body | pandoc | w3m -T text/html 2>&1 | bufWrite "$1" body
curToBof "$1"
markClean "$1"
}

currentId="$(currentBufferId)"
adCtl "open-in-new-window ./+markdown-preview"
id="$(adIndex | grep "+markdown-preview" | cut -f1)"
focusBuffer "$currentId"
processMarkdown "$id" "$currentId"

0 comments on commit f70de21

Please sign in to comment.