Export to GitHub

syntaxhighlighter - issue #73

syntaxhighlighter - duplicates code


Posted on Apr 15, 2008 by Massive Bear

I am using syntaxhighlighter and editing my pages using fckeditor. When I create the page and assign some code the following tag <pre name="code" class="html"> then the code displays as expected and formatted. hen I go back and edit that page then the code is duplicated and inserted into the page.

So if i initially save something like this in my page:

<pre name="code" class="html"> test code test code <pre>

I see the expected output. If I then go back and edit the page and save it. I then get a double entry that looks like this:

<pre name="code" class="html"> test code test code <pre> <pre style="display: none;" name="code" class="html"> test code test code</pre>

Also extra html is added before each pre tag as follows: <div class="dp-highlighter"> <div class="bar"> <div class="tools">&nbsp;</div> </div> <ol start="1" class="dp-xml"> <li class="alt"><span><span>hfdhdfh&nbsp;</span><span class="tag">&lt;</span><span class="tag-name">preface</span><span class="tag">&gt;</span><span>&nbsp;egeyeyeyeyery&nbsp;</span><span class="tag">&lt;/</span><span class="tag-name">preface</span><span class="tag">&gt;</span><span>&nbsp;hfdh&nbsp;fdhfd&nbsp;hdfh&nbsp;dfhfdhfdhdfhdf&nbsp;&nbsp;</span></span></li> </ol> </div>

Any fix for this?

Comment #1

Posted on Apr 15, 2008 by Massive Bear

I made a mistake in my post above. The extra code that gets added before each pre tag looks like this:

 

Comment #2

Posted on Jul 2, 2008 by Swift Cat

One solution to this problem is to use removeChild() instead of display:none.

To resolve it, add the following line in shCore.js (after the line #703):

element.parentNode.insertBefore(highlighter.div, element); element.parentNode.removeChild(element);

Using this method one can eliminate the problem of duplicated codes when CSS if off.

best regards, gajdaw

Status: New

Labels:
Type-Defect Priority-Medium