Skip to content

Instantly share code, notes, and snippets.

@caiorss
Forked from 23Skidoo/haddock-escape.el
Created February 15, 2017 00:14
Show Gist options
  • Save caiorss/0169b296114ece5433a60331218ce290 to your computer and use it in GitHub Desktop.
Save caiorss/0169b296114ece5433a60331218ce290 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