First of all: This is Emacs. It's not a bug, it's a setting!
Secondly, @glucas is correct in saying that you need to modify org-emphasis-regexp-components
to get what you want. However, I'd like to suggest two modifications to his (@Malabarba's) code and provide a bit more context:
You don't need to copy the entire value of org-emphasis-regexp-components
to your init-file to modify a single component. For your use case the following is sufficient:
(setcar (nthcdr 2 org-emphasis-regexp-components) " \t\r\n,\"")
You don't have to modify org-emphasis-regexp-components
before loading org-mode
via (require 'org)
. Just add the following line after your modifications:
(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
More context
In case you want to customize other aspects of how emphasis markup works in org-mode
, know this:
The value of org-emphasis-regexp-components
is a list with five entries.
The first entry controls which characters are allowed to immediately precede markup characters. If you want to be able to have something like why=hello=
render correctly, you'll need to modify this entry.
(setcar org-emphasis-regexp-components "...")
The second entry controls which characters are allowed to immediately follow markup characters. If you want to be able to have something like =hello=there
render correctly, you'll need to modify this entry.
(setcar (nthcdr 1 org-emphasis-regexp-components) "...")
The third entry specifies the characters that are not allowed as border characters, i.e., characters that immediately follow an opening markup character or precede a closing markup character. You'll need to modify this to make things like ='hello'=
render correctly.
(setcar (nthcdr 2 org-emphasis-regexp-components) "...")
The fourth entry lists characters that are allowed in the body of your marked up string, i.e., characters that appear between the border characters. You'll rarely need to modify this; by default, any character is allowed as a body character.
(setcar (nthcdr 3 org-emphasis-regexp-components) "...")
The fifth entry specifies how many newlines are allowed inside a marked up expression. By default, org-mode
allows a single newline. So if you want to be able to add markup to text that spans more than two consecutive lines, you'll need to modify this entry.
(setcar (nthcdr 4 org-emphasis-regexp-components) N)
... where N
is the number of newlines you want to allow.
Related posts
People seem to run into this issue fairly frequently. Aside from the post you mentioned, there are at least two more questions on StackOverflow that deal with very similar issues: