Skip to content



If you ever have to stop and try to remember, Can I escape this char? or Will a backslash escape this?, you are not alone. EscapeAll makes \ escape everything making such questions moot. Now instead of questioning or looking up what can be escaped, you can expect that \ will escape the character following it. So if you need a literal \, just escape it: \\. Keep in mind this will not escape things in code blocks of any kind.

\W\e\ \c\a\n\ \e\s\c\a\p\e
\e\v\e\r\y\t\h\i\n\g\!\ \

We can escape everything! 

There are two special escapes among all of these escapes though: escaping "space" characters and escaping "newline" characters. If nbsp is enabled, an escaped space will be converted into a non-breaking space: &nbsp;. If hardbreak is enabled, an escaped newline will be converted to a hard break <br>. The advantage of hardbreak is that you can visually see the hard break opposed to Markdown's default method of two spaces at the end of a line.

So in short, EscapeAll escapes all inline characters.

Q & A

So all ASCII characters?

It escapes everything.

What about Unicode?

It escapes everything!

What about…


The EscapeAll extension can be included in Python Markdown by using the following:

import markdown
md = markdown.Markdown(extensions=['pymdownx.escapeall'])


Option Type Default Description
hardbreak bool False Escaped newlines will be hard breaks: <br>.
nbsp bool False Escaped spaces will be non-breaking spaces: &nbsp;.