lxzliuxinzhu / syntaxhighlighter

Automatically exported from code.google.com/p/syntaxhighlighter
GNU General Public License v3.0
0 stars 0 forks source link

Python syntaxhighlighting fails on Safari (Mac + Win) #52

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. type some python code
2. setup syntaxhighlighter
3. go see in Safari

What is the expected output? What do you see instead?
Yo'd expect highlighted code, as is in Firefox and IE, but it doesn't in Safari

What version of the product are you using? On what operating system?
Both windows and Mac

Please provide any additional information below.
The problem is in the string regular expressions, I copied
dp.sh.RegexLib.DoubleQuotedString and dp.sh.RegexLib.SingleQuotedString
from the php file instead and it seems to work, not sure if its right or not.

Original issue reported on code.google.com by guyon.mo...@gmail.com on 25 Jan 2008 at 10:39

GoogleCodeExporter commented 8 years ago
I tried shBrushPython.js written by Gheorghe Milas and it worked.

https://svn.enthought.com/enthought/browser/trunk/enthought.chaco2_3.0/enthought
/chaco2/doc/scipy_tuto
rial/Scripts/shBrushPython.js?rev=13597&format=txt

Original comment by lionxia...@gmail.com on 29 Apr 2008 at 5:00

GoogleCodeExporter commented 8 years ago
Agreed, Python brush is 100% broken in all WebKit browsers.  The issue is:
SyntaxError: Invalid regular expression: nothing to repeat
file:///C:/Documents%20and%20Settings/fraser/Desktop/html/dp.SyntaxHighlighter/j
s/shBrushPython.js
(line 15)
It is line 10 in the compressed version and line 15 in the uncompressed 
version.  The
offending line is:
        { regex: new RegExp("'(?!')*(?:\\.|(\\\\\\')|[^\\''\\n\\r])*'", 'gm'), css:
'string' },
Doesn't matter what the Python input is.

Original comment by neil.fra...@gmail.com on 14 Aug 2008 at 5:37

GoogleCodeExporter commented 8 years ago
Confirming that the alternative shBrushPython.js in comment 1 works great.

As for the bug in the original regex, it boils down to RegExp("(?!x)*y") which 
is a
negative look-ahead assertion.  But neither I nor WebKit can figure out what 
the * is
for.  Deleting the * solves the problem and makes Python render fine.

Original comment by neil.fra...@gmail.com on 14 Aug 2008 at 5:57

GoogleCodeExporter commented 8 years ago
Thanks, Neil, for figuring it out.  I ran into the problem with Safari 3 and 
removed
the * in shBrushPython.js.  (This is from the current RAR downloads, 1.5.1, I 
think.)
 Works like a charm now.

Original comment by billk...@gmail.com on 18 Aug 2008 at 9:07

GoogleCodeExporter commented 8 years ago
fixed in the trunk

Original comment by alex.gor...@gmail.com on 9 Oct 2008 at 12:43