8

I need to be able to have a table entry that looks like this

| ~Comonad~   | ~copoint~ | ~F[A]~ | | ~A~ |
| ~Semigroup~ | ~|+|~     |        | |     |

but org-mode insists on treating the pipes in |+| as columns.

I am aware that I can use vert as per https://stackoverflow.com/questions/11876048 and http://orgmode.org/manual/Special-symbols.html#Special-symbols but this doesn't work when it's in a code block.

What to do? I'm not keen on the UTF-8 pipe hack.

1 Answer 1

3

You could use a custom export filter (see http://orgmode.org/manual/Advanced-configuration.html) for replacing \vert in code blocks during export.

For example, for exporting to html, put this in your .emacs:

(require 'ox)
(defun my-code-filter-replace-pipes (text backend info)
  (when (org-export-derived-backend-p backend 'html)
    (replace-regexp-in-string "\\\\vert" "|" text)))
(add-to-list 'org-export-filter-code-functions 'my-code-filter-replace-pipes)

With this, ~\vert+\vert~ exports correctly to <code>|+|</code> in a table cell. If you use a different export backend, you have to adapt the arguments of replace-regexp-in-string.

You could make the code more sophisticated by reading the appropriate replacement for each backend from org-entities and org-entities-user.

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.