Skip to content

Instantly share code, notes, and snippets.

@23Skidoo
Last active February 15, 2017 00:14
Show Gist options
  • Save 23Skidoo/9fe883af5fa605704826 to your computer and use it in GitHub Desktop.
Save 23Skidoo/9fe883af5fa605704826 to your computer and use it in GitHub Desktop.
An Elisp function for escaping special characters in Haddock's @ code blocks
; See http://www.haskell.org/haddock/doc/html/ch03s08.html#idp1371070500
; and http://www.haskell.org/haddock/doc/html/ch03s08.html#idp1371060908
;
; Examples:
; \, /, ', `, ", @, < ===> \\, \/, \', \`, \", \@, \<
; foo `fmap` bar "/a/b" ===> foo \`fmap\` bar \"\/a\/b\"
(defun haddock-escape (start end)
"Escape symbols that have special meaning in Haddock comments."
(interactive "r")
(replace-regexp "\\([^\\\\]?\\)\\(`\\|'\\|\\\"\\|@\\|<\\|/\\|\\\\\\)" "\\1\\\\\\2" nil start end))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment