Last active
March 20, 2020 14:30
-
-
Save PurpleBooth/9a504ef30f16c72d81e7e87ff82d76cd to your computer and use it in GitHub Desktop.
Using Pandoc as a (github flavoured) Markdown formatter with wrapping support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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