Skip to content

Instantly share code, notes, and snippets.

@nethope
nethope / copy md, paste formatted.md
Created January 11, 2023 15:33
copy markdown, paste formatted text

Goal: copy markdown, do something to interpret markdown, then have formatted text on the clipboard to paste

  • Unix/X11: xclip -selection clipboard -out | pandoc --standalone --from markdown --to html | xclip -selection clipboard -t text/html
  • macOS: pbpaste | textutil -stdin -format html -convert rtf -stdout | pbcopy
  • Windows/Powershell: Get-Clipboard | pandoc --standalone --from markdown --to html | Set-Clipboard -AsHtml

Since pandoc will assume from markdown to html, and --standalone has a short flag, pandoc -s in the middle should be equivalent (but verify for yourself).

On Unix, install pandoc and xclip. While the Unix command was only tested on Linux, it should also work on BSD since both xclip and pandoc are in Ports.

# based on http://unix.stackexchange.com/questions/225217/what-hash-algorithms-can-i-use-in-preseeds-passwd-user-password-crypted-entry
mkpasswd -m sha-512 -S $(pwgen -yns 24 1 | tr -cd [:alnum:] | awk '{ print substr($0,1,16) }')

Keybase proof

I hereby claim:

  • I am nethope on github.
  • I am nethope (https://keybase.io/nethope) on keybase.
  • I have a public key whose fingerprint is D954 F960 54C4 0EE3 DF5A FB71 8AE1 EC1C 1B1B CED9

To claim this, I am signing this object: