lxzliuxinzhu / syntaxhighlighter

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

syntaxhighlighter - duplicates code #73

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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?

Original issue reported on code.google.com by mng...@gmail.com on 15 Apr 2008 at 5:16

GoogleCodeExporter commented 8 years ago
I made a mistake in my post above.
The extra code that gets added before each pre tag looks like this:
<div class="dp-highlighter">
<div class="bar">
<div class="tools"> </div>
</div>

Original comment by mng...@gmail.com on 15 Apr 2008 at 5:21

GoogleCodeExporter commented 8 years ago
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

Original comment by wlodzimi...@gmail.com on 2 Jul 2008 at 8:20