cocacola90 / syntaxhighlighter

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

Enhancements for Ajax integration and better Safari and IE formatting #28

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
1. Enhancements for Ajax
When using any Ajax inline editing tool, like
http://www.appelsiini.net/projects/jeditable, there is a need to reformat
the code listing. In the current version of SH, a second call to
HighglightAll() will duplicate all code listings in the page, so there
should be a way to prevent that. 

Attached is a fix for it. 

2. Better Safari and IE formatting
IE and Safari does not handle long line listings as Firefox does (please
see the attached image for reference). The problem lies on the replace of
blank spaces by  , which leaves no room for line breaking. A
solution for this is to left some blank spaces instead of replace all of
them by the respective html entity (this works because *one* space is
always correctly formatted). 

Attached is a fix for it. 

Original issue reported on code.google.com by rafaelst...@gmail.com on 27 Aug 2007 at 3:44

Attachments:

GoogleCodeExporter commented 8 years ago
Here's an updated version of the patch, that fixes a IE problem with white space
handling. 

Original comment by rafaelst...@gmail.com on 2 Sep 2007 at 5:40

Attachments:

GoogleCodeExporter commented 8 years ago
Well, well, well.. After playing with it under IE6, IE7, Safari 2 and Firefox 
2, it
appears that all this mess can simply be fixed by just replacing the original 
call to 

str = str.replace(/ /g, ' ');

by

str = str.replace(/  /g, '  ');

Much simpler :D. 

Original comment by rafaelst...@gmail.com on 10 Sep 2007 at 1:54

GoogleCodeExporter commented 8 years ago
Hi, using the str.replace method seemed to work really well at first sight but 
I just
noticed a problem. In IE some important whitespaces between keywords and 
following
chars gets lost! I noticed this in a javascript block where:

var varName

became

varvarName

I've now noticed this happening in both js and html blocks

I'm going to try the original solution and see how well that works :D

Original comment by ccodl...@gmail.com on 15 Feb 2008 at 7:32

GoogleCodeExporter commented 8 years ago
Ok, both solutions seem to have the same issue in IE! Works well in FF, Safari 
and Opera.

Example here: http://www.webdesignpro.co.uk/example.php

Original comment by ccodl...@gmail.com on 16 Feb 2008 at 2:48

GoogleCodeExporter commented 8 years ago
My solution:

first replace

      str = str.replace(/ /g, ' ');

with

      str = str.replace(/ /g, '  ');

This solves the issue of word wrapping but creates 2 spaces in every place that 
there
should be one. To overcome this I loop through all the code divs and replace the
double spaces with single ones, I do this after the highlighter script has been 
called:

var r = document.getElementsByTagName('div');
for (var i=0; i<r.length; i++) {
    if (r[i].className=='dp-highlighter'){
        r[i].innerHTML = r[i].innerHTML.replace(/  /g, ' ');
    }
}

This fixes things in FF and IE but for some reason the double spaces remain in 
Opera
and Safari(pc). Best solution I can find though.

Hope this helps someone :)

* note. The issues I've mentioned in the last few post have all been related to
implementing syntax highlighter with textareas not pres.

Original comment by ccodl...@gmail.com on 16 Feb 2008 at 5:52

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Have you guys came up with a full fix yet or decided on something else?

Original comment by alex.gor...@gmail.com on 9 Oct 2008 at 1:25