GithubHelp home page GithubHelp logo

Comments (6)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 3, 2024
Pages which load code blocks dynamically using, e.g. jQuery, could really 
benefit
from this (though i would recommend changing the class name to something less 
likely
to conflict with client code, such as "google-code-prettified").

Original comment by [email protected] on 21 Feb 2009 at 11:46

from google-code-prettify.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 3, 2024
Quote: "Google Prettify supports another API, prettyPrintOne(), which allows 
you to pass in a string to be 
prettified. "
http://www.codingthewheel.com/archives/syntax-highlighting-stackoverflow-google-
prettify

With this information I implemented the following in jQuery.

var my_html = '<html><head></head><body class="testing"><p id="hello">Hello 
World</p></body></html>';
$('#code').append(<pre class="prettyprint"></pre>');
$('#code > pre:last').text(my_html).html(prettyPrintOne($('#code > 
pre:last').html()));
// note: .text() calls the DOM method .createTextNode(), which replaces special 
characters with their HTML 
entity equivalents (such as <  for <).


Original comment by [email protected] on 25 May 2010 at 7:05

from google-code-prettify.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 3, 2024
In reference to comment #2, This is a solution for most, but not all cases. I 
have to agree with comment #1 about a non-conflicting CSS class. An example 
case where #2 would be ineffictive at the least, involves getting back the 
following snippet of HTML:

<div class='something'>blah blah blah</div><pre><code 
class='prettyprint'>SomeCode</code></pre><span>Some more crap</span>

Not that it couldn't be done with #2's version, but it becomes more difficult. 
It would be far easier if prettyprint could be run multiple times.

Original comment by [email protected] on 22 Apr 2012 at 10:06

from google-code-prettify.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 3, 2024
I actually fixed this but did not notice that this duplicate bug persisted.

Original comment by [email protected] on 23 Apr 2012 at 4:18

  • Changed state: Duplicate

from google-code-prettify.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 3, 2024
Fixed at http://code.google.com/p/google-code-prettify/source/detail?r=204#

Original comment by [email protected] on 23 Apr 2012 at 4:19

from google-code-prettify.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 3, 2024
Simple fix remove class "prettyprinted" from the tag before calling 
prettyPrint()

Original comment by [email protected] on 4 Jan 2014 at 10:48

from google-code-prettify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.