Easily escape HTML for a WordPress post

Here’s a one-liner for converting angle brackets and other characters that need escaping. This will work on any system that has Python installed. Run this command:

python -c 'import cgi; import sys; print cgi.escape(sys.stdin.read())' | pbcopy

Once you hit enter on the command above, paste the content to convert and after pasting hit enter followed by ctrl+d.

If you’re not on OS X, remove the pipe to pbcopy. If you are on OS X, your converted text is now in your clipboard!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s