Skip to content

Instantly share code, notes, and snippets.

@PurpleBooth

PurpleBooth/gfmfmt.fish

Last active Mar 20, 2020
Embed
What would you like to do?
Using Pandoc as a (github flavoured) Markdown formatter with wrapping support
#!/usr/bin/env fish
# You can do something similar in fish too
function gfmfmt
for I in $argv
set -lx TEMPORARY_FILE (mktemp -d)"/"(basename "$I")
pandoc --from=gfm --to=gfm --wrap=auto "$I" > "$TEMPORARY_FILE"
mv "$TEMPORARY_FILE" "$I"
end
end
gfmfmt something.md somethingelese.md
#!/usr/bin/env bash
# This will work in ZSH & Bash too
# I have this in my .zshrc and .bashrc
function gfmfmt() {
for I in "$@"; do
TEMPORARY_FILE="$(mktemp -d)/$(basename "$I")"
pandoc --from=gfm --to=gfm --wrap=auto "$I" >"$TEMPORARY_FILE"
mv "$TEMPORARY_FILE" "$I"
done
}
## Use it like
gfmfmt something.md somethingelese.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment