Comments (6)
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.
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.
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.
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.
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.
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)
- Perl syntax highlighting does not recognize POD and highlights quotes in comments
- Bash "$#" treated as comment HOT 1
- Integration for Presentation
- Patch for /trunk/src/lang-css.js
- "><img src=x onerror=prompt(1);> HOT 2
- Feature request: AspectJ syntax highlighting.
- gzip disabled
- Patch for /trunk/js-modules/run_prettify.js
- Patch for /trunk/src/lang-vb.js
- Line numbers carry over in clipboard using IE 11.
- Patch for /trunk/src/awkirin.css
- Problem with backslash in VB
- FLOW_CONTROL_KEYWORDS should not contain `do`
- Syntax Highlighting for Rebol (and Red) programming languages
- Patch for /trunk/styles/sons-of-obsidian.css
- Syntax highlight for Robot Framework syntax
- Patch for /trunk/src/prettify.css HOT 1
- Inconsist TCL Syntax higlighter
- Patch for /trunk/src/lang-sql.js
- Patch for /trunk/styles/sons-of-obsidian.css
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-code-prettify.