Last active
November 8, 2025 21:13
-
-
Save holocronweaver/4f18acf4659efc8c4750d328038b8092 to your computer and use it in GitHub Desktop.
Yank/Paste Markdown in Emacs Org-Mode Syntax
This file contains hidden or 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
| (defun hw-yank-markdown-as-org () | |
| "Yank markdown from clipboard/kill-ring and insert as org-mode syntax. | |
| Converts via pandoc while preserving long lines for visual-line-mode." | |
| (interactive) | |
| (let* ((markdown (current-kill 0)) | |
| (org-text (with-temp-buffer | |
| (insert markdown) | |
| (shell-command-on-region | |
| (point-min) | |
| (point-max) | |
| "pandoc -f markdown -t org --wrap=preserve" | |
| t t "*pandoc-error*") | |
| ;; Remove CUSTOM_ID property drawers | |
| (goto-char (point-min)) | |
| (while (re-search-forward | |
| ":PROPERTIES:\n:CUSTOM_ID: .*\n:END:\n" | |
| nil t) | |
| (replace-match "")) | |
| (buffer-string)))) | |
| (insert org-text))) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is especially useful when copying markdown output from LLMs.
May be worth adding a more generalized version to https://github.com/tecosaur/org-pandoc-import if it is ever supported again.