So I a bit investigated to support pretty print in blogger.
Following is the way I found:
- open template HTML edit
add following code just before </head>
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
- Blogger Template Designer->Adbanced->Add CSS
Add following codes:pre { overflow: auto; width: 580px; white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Explorer 5.5+ */ } /* https://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css */ .prettyprint { background: #EEE; }
- when you want to embed code, use HTML view, and put code snippets in:
<pre class="prettyprint lang-dart">Code!</pre>
http://google-code-prettify.googlecode.com/svn/trunk/README.html
http://google-code-prettify.googlecode.com/svn/trunk/styles/index.html
But there is an issue for <, >. they will be recognized as special characters(by html parser?), and enclosed parts are not shown. So if we have these characters, we need to replace them with <, > respectively(i.e, in Code).
This should be handled by run_prettify.js though.
No comments:
Post a Comment