How to escape the \ xc2 character or in my code snippets?

I just started a blog and I use the SyntaxHighlighter Evolved Wordpress plugin to highlight the syntax of my snippets.

I just finished writing a Pythonic post and wanted to check out my code snippets before posting.

If you double-click the code inside my snippets, the plugin will stop highlighting the code, allowing you to select it as plain text. However, if I copy and paste Python code from my snippets, it includes \xc2 or   chracters in. This leads to what Python says about coding:

SyntaxError: non-ASCII character '\ xc2' in ex2.py on line 3, but no encoding declared; See http://www.python.org/peps/pep-0263.html for more details.

I don’t really want to declare encodings for every single Python fragment that I write - and I don’t even know if this will solve the problem.

The best solution, of course, would be to force my plugin not to use   in the text version. Or that?

Does anyone have any ideas on how I can get around this problem?

+6
source share
3 answers

Oh, got it. Just a little missed the source of the plugin, fixed this problem for me ...

If you decorate the syntaxhighlighter3/scripts/shCore.js , you will see that there is a configuration variable that includes:

 space: " " 

All I had to do was change it to space: " " and repack.

+2
source

NBSP in any case is not considered a pass for indentation, so you should see what the user preselects the script does and mimics it.

0
source

I ran into this problem when python code was copied from skype. Since I use vim for editing, I went ahead and found it all by doing the following:

 :hls /<space> 

This shows where these odd-space characters are not because they are not highlighted.
Yan is one of the characters that will store it in case 0.
Use the substitute command and use <ctrl-R> <0> to insert this character into the command line.

 :%s/<ctrl-R><0>/ /g 

It will look like

 :%s/ / /g 

but at startup it will fix the problem.

0
source

Source: https://habr.com/ru/post/911985/


All Articles