prettify

Using Google Prettify to display HTML

拈花ヽ惹草 提交于 2019-12-06 23:21:50
问题 for Google Prettify to display HTML code sample properly, you should replace all the < with < and all the > with > . How do you automate that process using JavaScript only ? 回答1: If you put your code inside an <xmp> element, you don't need to escape HTML special characters as shown in the tests <h1>HTML using XMP</h1> <xmp class="prettyprint" id="htmlXmp" ><html> <head> <title>Fibonacci number</title> </head> <body> <noscript> <dl> <dt>Fibonacci numbers</dt> <dd>1</dd> <dd>1</dd> <dd>2</dd>

emacs align-regexp with spaces instead of tabs

你离开我真会死。 提交于 2019-12-05 06:03:52
I use M-x align-regexp in emacs to prettify my Perl code, but by default it is using tabs instead of spaces, which is something one should not do according to Perl critic. Is there a way to change the behaviour of align-regexp so that it fills in with the right amount of spaces instead of tabs? Gordon Gustafson In general you should avoid using advice, but since align.el directly reads the value of indent-tabs-mode , it's probably the best way: (defadvice align-regexp (around align-regexp-with-spaces activate) (let ((indent-tabs-mode nil)) ad-do-it)) Here was my original version: (defadvice

Using Google Prettify to display HTML

与世无争的帅哥 提交于 2019-12-05 03:52:34
for Google Prettify to display HTML code sample properly, you should replace all the < with < and all the > with > . How do you automate that process using JavaScript only ? If you put your code inside an <xmp> element, you don't need to escape HTML special characters as shown in the tests <h1>HTML using XMP</h1> <xmp class="prettyprint" id="htmlXmp" ><html> <head> <title>Fibonacci number</title> </head> <body> <noscript> <dl> <dt>Fibonacci numbers</dt> <dd>1</dd> <dd>1</dd> <dd>2</dd> <dd>3</dd> <dd>5</dd> <dd>8</dd> … </dl> </noscript> <script type="text/javascript"><!-- function fib(n) {

prettyPrint() only has an effect once. (google-prettify)

喜夏-厌秋 提交于 2019-12-04 19:28:07
I have this JavaScript (with jQuery): var g_files_added, socket, cookie, database = null; var file_contents = []; function viewFile(key, filename) { $('#title-filename').text(filename); $('.prettyprint').text(file_contents[key]); $('#viewFileModal').modal('show'); } $(document).ready(function() { $(document).on('shown', '#viewFileModal', function(event) { prettyPrint(); }); }); // Variables have been set in code not shown, irrelevant to problem. // prettyPrint() is called everytime the #viewFileModal is shown, // but its effect is only felt once. So prettyPrint() is invoked every time the

JavaScript (stored inside assets) not working inside WebView in ICS (Ice Cream Sandwich)

北战南征 提交于 2019-12-04 13:06:48
Similar Problem : JavaScript doesn't work on ICS I'm working on an Android app that displays some code samples to the user. So, I'm using google-code-prettify in a WebView for syntax highlighting. But, the problem is, the js does not work on ICS (Ice Cream Sandwich) alone. It works perfectly on all other Android versions (2.2+) except 4.0.x . This is the code that I'm using. WebView webView = (WebView) findViewById(R.id.webViewSample); webView.getSettings().setJavaScriptEnabled(true); webView.setWebChromeClient(new WebChromeClient()); webView.loadUrl("file:///android_asset/code_snippets/sample

Is there a pretty printer for python data?

蓝咒 提交于 2019-12-03 23:01:17
Working with python interactively, it's sometimes necessary to display a result which is some arbitrarily complex data structure (like lists with embedded lists, etc.) The default way to display them is just one massive linear dump which just wraps over and over and you have to parse carefully to read it. Is there something that will take any python object and display it in a more rational manner. e.g. [0, 1, [a, b, c], 2, 3, 4] instead of: [0, 1, [a, b, c], 2, 3, 4] I know that's not a very good example, but I think you get the idea. from pprint import pprint a = [0, 1, ['a', 'b', 'c'], 2, 3,

Syntax highlighting on twitter bootstrap

十年热恋 提交于 2019-12-03 15:37:48
问题 I am trying to highlight some syntax using Google prettify but so far, its not working. <link href="prettify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="prettify.js"></script> <body onload="prettyPrint()" bgcolor="white"> <pre class="prettyprint"> <code class="language-css"> // Some source code class Foo { public int Bar { get; set; } } </code> </pre> Is there a solution to make this work without messing too much with the pre tag already in bootstrap?. 回答1:

format xml, pretty print

谁说胖子不能爱 提交于 2019-12-03 14:13:27
I know of two ways to "pretty print", or format, xml: shell tools Hack 38 Pretty-Print XML Using a Generic Identity Stylesheet and Xalan what other free (as in beer) formatters are there? (aside from using javascript) Well, the identity transform you linked to is portable to any XSLT processor (Saxon, msxml, etc). Additionally, you could look at xmllint which is part of the LibXML2 toolkit. The --format option allows you to pretty print the input. Similar functionality exists in XMLStarlet (which uses LibXML2 under the hood iirc). xmlstarlet fo is what I use for pretty printing. Xmlstarlet has

How to combine WMD and prettify, like Stack Overflow?

有些话、适合烂在心里 提交于 2019-12-03 13:23:07
Prettify needs class="prettyprint" to be add to <pre> or <code> . How to let WMD do this? Take a look at the PageDown Markdown editor... AFAIK, WMD is dead, but PageDown is a fork based on the WMD source. It's an active project based on the work done in WMD. That takes care of the Markdown editor. To get syntax highlighting working you'll also need to download source from the Google-Code-Prettify project. Combine the demo.html, demo.css, prettify.js, prettify.css into the same folder. Modify the imports accordingly: <link rel="stylesheet" href="demo.css" /> <link rel="stylesheet" href=

Syntax highlighting on twitter bootstrap

懵懂的女人 提交于 2019-12-03 01:55:07
I am trying to highlight some syntax using Google prettify but so far, its not working. <link href="prettify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="prettify.js"></script> <body onload="prettyPrint()" bgcolor="white"> <pre class="prettyprint"> <code class="language-css"> // Some source code class Foo { public int Bar { get; set; } } </code> </pre> Is there a solution to make this work without messing too much with the pre tag already in bootstrap?. EDIT: for twitter bootstrap 2.0.x, it works fine with 2.1.x Use the those 2 files instead of using the method