I'm looking for a way to include code as part of a paragraph in DokuWiki like I can by adding backtick escapes in StackOverflow like _so_
. Simply adding <code>bla</code>
puts code on it's own line.
Asked
Active
Viewed 1.4k times
40

Alan Turing
- 12,223
- 16
- 74
- 116
2 Answers
91
You probably want to use ''%%here is code%%''
. This formats it in monospace (''
) and prevents any interpretion of possible wiki markup (%%
).

Andreas Gohr
- 4,617
- 5
- 28
- 45
-
1This should be the accepted answer, because without it characters can get encoded, such as quotes in to smart quotes, which is a nightmare when you want to copy and paste. – LeonardChallis Feb 03 '15 at 14:51
-
1surely a plugin could be written that maps `\`foo\`` to `''%%foo%%''`? – user3791372 Mar 10 '17 at 00:02
17
I was able to find an answer to my own question. Add quotes around the in-text code ''like this''
. Simple, short, and works great.

Alan Turing
- 12,223
- 16
- 74
- 116
-
2This answer is _wrong_, because just `''monospace''` quoted text is still interpreted as having DokuWiki formatting, and you could get `--` in your code replaced with `–`. Andreas Gohr answer, above, _is correct_. – catpnosis Oct 11 '15 at 22:21
-
well, really, the question never specified that it needed to be safe, this actually answers the question perfectly. Given that Gohr's answer comes so many hours after and is such a minor change it should have just been a suggestion comment to improve this answer – Hashbrown Apr 01 '16 at 00:47