baleezo / google-code-prettify

Automatically exported from code.google.com/p/google-code-prettify
Apache License 2.0
0 stars 0 forks source link

Double Line Numbers. The prettyPrint method does not check if the element has already been prettified #261

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a an element with code to prettify and specify to add line numbers
2. Call pretty print twice. For us, this happens because some of our page 
content is fetched via ajax that triggered by user interaction. The returned 
markup can contain code samples so we have to call prettyPrint on page load for 
existing content and again after every ajax call for code samples in the 
response.

What is the expected output? 
We would expect that addition line numbers would not appear.

What do you see instead?
A nested ordered list with multiple line number columns.

This:

1. example() { // some code goes here }

Becomes this after the second call to prettyPrint():

1. 1. example() { // some code goes here }

Original issue reported on code.google.com by mmur...@compilr.com on 9 Jan 2013 at 4:41

GoogleCodeExporter commented 8 years ago
Which version of prettyprint are you using?  I can't repeat using 
http://google-code-prettify.googlecode.com/svn/trunk/tests/prettify_test_2.html#
issue261

Original comment by mikesamuel@gmail.com on 4 Feb 2013 at 10:18

GoogleCodeExporter commented 8 years ago
I am using "prettify-small-1-Jun-2011.tar.bz2" with bootstrap.css theme.
This issue arises when you run prettyPrint(); more then once on a single page.

Find file attached, which shows output of running prettyPrint() 5 times.

Original comment by t2mah...@gmail.com on 5 Feb 2013 at 2:03

Attachments:

GoogleCodeExporter commented 8 years ago
I can't reproduce the problem with

<!DOCTYPE HTML>
<html><head>
<title></title>
<link 
href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" 
type="text/css" rel="stylesheet" />
<script type="text/javascript" 
src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></scr
ipt>
</head>

<body>
<pre class="prettyprint linenums">class HelloWorld {
    public static void main(String[] args)
    {
        System.out.println("Hello <html> World!");
    }
}</pre>

<script>
prettyPrint();
prettyPrint();
prettyPrint();
prettyPrint();
prettyPrint();
</script>
</body></html>

Please provide a snippet of HTML that demos the problem.

Original comment by mikesamuel@gmail.com on 7 Feb 2013 at 10:34

GoogleCodeExporter commented 8 years ago
Ok, got it. The problem is with:

http://google-code-prettify.googlecode.com/svn/branches/release-1-Jun-2011/src/p
rettify.js

which is not yet up-to-date.

./svn/trunk/src/prettify.js is fine; no duplicate line number issue.

Original comment by t2mah...@gmail.com on 8 Feb 2013 at 1:05

GoogleCodeExporter commented 8 years ago
Sorry for the delayed response. Just confirming that it is 
http://google-code-prettify.googlecode.com/svn/branches/release-1-Jun-2011/src/p
rettify.js version which will repoduce the issue.

Original comment by mmur...@compilr.com on 8 Feb 2013 at 1:49

GoogleCodeExporter commented 8 years ago
The latest release should include a fix for this issue.

Original comment by mikesamuel@gmail.com on 27 Feb 2013 at 2:19