I make substantial use of prettify-symbols in my programming buffers. A snippet of some of my python symbols:

(add-hook 'python-mode-hook
        (lambda ()
          (mapc (lambda (pair) (push pair prettify-symbols-alist))
                '(("for" .      ?∀)
                  ("in" .       ?∊)
                  ("not in" .   ?∉)
                  ("return" .  ?⟼)))))

This works fine for all cases except (html) exporting.

Pretty symbols from source code, or even directly from org-mode text, will not transfer over after exporting.


1 Answer 1


The code below was too long to post as a comment, so I'm posting an answer even though it doesn't work. I thought it might be of some help. The problem I encountered was that prettify-symbols-alist was empty.

(defun ess/org-pretty-symbols-to-html (backend)
  (when (equal backend 'html)
    (goto-char (point-max))
    (while (ignore-errors (org-babel-previous-src-block))
       (lambda (x)
         (goto-char (point-max))
         (while (re-search-backward (car x) nil t)
           (replace-match (cdr x) nil t)))

(add-hook 'org-export-before-parsing-hook 'ess/org-pretty-symbols-to-html)
  • 1
    The doc for org-export-before-parsing-hook says it is run on a copy of the original buffer. Since prettify-symbols-alist is buffer local, this may be the cause of the problem.
    – JeanPierre
    Commented Feb 3, 2017 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.