22
votes

In org-mode, I want to give inline code with equals signs and quotation marks:

<div class="foo">

The way I would normally do this in org-mode is

=<div class="foo">=

When I export this to HTML, it gets rendered like this:

<div class"foo">=

What is the right way to do this inline (rather than just creating a source block)?

3

3 Answers

13
votes

You could use verbatim markers, ~, instead:

~<div class="foo">~
3
votes

The problem is that the equals sign after 'class' is interpreted as the closing code section delimiter. You can prevent this by inserting a space before the equals sign, like this:

=<div class = "foo">=
0
votes

I wanted org-mode's source code to appear correctly in Github's parser. But, just as =:echo "hello"= would not appear correctly in Emacs, it also did not appear correctly in Github. However, I tried other characters with C-x 8 RET, and the LEFT DOUBLE QUOTATION MARK and RIGHT DOUBLE QUOTATION MARK work. That is,

=:echo “hello“=

appear successfully as

:echo “hello“

Unfortunately, I don't think they will actually work if copy-and-pasted into all environments. Vim gives E15: Invalid expression: “hello“. But then, how often do we paste commands into Vim's command line. Well, okay, there is :@".