<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: &#8220;prettyPrint&#8221; for JavaScript</title>
	<atom:link href="http://james.padolsey.com/javascript/prettyprint-for-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://james.padolsey.com/javascript/prettyprint-for-javascript/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 29 Aug 2010 12:37:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Nuri Akman</title>
		<link>http://james.padolsey.com/javascript/prettyprint-for-javascript/comment-page-1/#comment-15428</link>
		<dc:creator>Nuri Akman</dc:creator>
		<pubDate>Wed, 01 Jul 2009 13:55:01 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=881#comment-15428</guid>
		<description>Nice work! very useful! Great! Great!</description>
		<content:encoded><![CDATA[<p>Nice work! very useful! Great! Great!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elijah Grey</title>
		<link>http://james.padolsey.com/javascript/prettyprint-for-javascript/comment-page-1/#comment-13862</link>
		<dc:creator>Elijah Grey</dc:creator>
		<pubDate>Mon, 08 Jun 2009 22:47:10 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=881#comment-13862</guid>
		<description>I forgot to mention, but I think that when prettyPrint detects a function using implicit returns, it should prepend &quot;return &quot; to the body, as a normal function with a body of &lt;code&gt;1&lt;/code&gt; is the same as a function without a body at all. For example, in SpiderMonkey, &lt;code&gt;(function(){1}).toString() === (function(){}).toString()&lt;/code&gt;.</description>
		<content:encoded><![CDATA[<p>I forgot to mention, but I think that when prettyPrint detects a function using implicit returns, it should prepend &#8220;return &#8221; to the body, as a normal function with a body of <code>1</code> is the same as a function without a body at all. For example, in SpiderMonkey, <code>(function(){1}).toString() === (function(){}).toString()</code>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elijah Grey</title>
		<link>http://james.padolsey.com/javascript/prettyprint-for-javascript/comment-page-1/#comment-13860</link>
		<dc:creator>Elijah Grey</dc:creator>
		<pubDate>Mon, 08 Jun 2009 22:32:45 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=881#comment-13860</guid>
		<description>James, JavaScript and ECMAScript are not the same thing. My code is valid &lt;em&gt;JavaScript&lt;/em&gt;, not ECMAScript. JavaScript is just what SpiderMonkey and Rhino implement, as it&#039;s owned by Mozilla. ECMAScript is a standard based on Mozilla&#039;s JavaScript. Object destructuring in part of JavaScript 1.7 and implicit returns are part of JavaScript 1.8. &lt;abbr title=&quot;As far as I know&quot;&gt;Afaik&lt;/abbr&gt;, Opera supports basic object destructuring so things like &lt;code&gt;[a, b] = [b, a]&lt;/code&gt; work but not advanced stuff.

If you want to see some destructuring documentation (it&#039;s pretty lacking though), refer to &lt;a href=&quot;https://developer.mozilla.org/en/New_in_javascript_1.7&quot; rel=&quot;nofollow&quot;&gt;New in JavaScript 1.7&lt;/a&gt; on MDC.

I also have another bug report:
prettyPrint throw errors when it is passed E4X XML objects. Unlike the other stuff I have mentioned, E4X actually is part of an Ecma standard (specifically, &lt;a href=&quot;http://www.ecma-international.org/publications/standards/Ecma-357.htm&quot; rel=&quot;nofollow&quot;&gt;ECMA-357&lt;/a&gt;). Stuff like &lt;code&gt;prettyPrint(&lt;foo&gt;&lt;bar/&gt;&lt;baz/&gt;&lt;/foo&gt;)&lt;/code&gt; should work after you fix the bug. This can be easily fixed by using the native &lt;code&gt;prettyPrinting&lt;/code&gt; in E4X using &lt;code&gt;XML.prettyPrinting&lt;/code&gt;, &lt;code&gt;XML.prettyIndent&lt;/code&gt;, and &lt;code&gt;XML.prototype.function::toXMLString&lt;/code&gt;. It would involve temporarily changing the two prettyPrinting preferences temporarily and reverting them if needed.

An alternative option for if you don&#039;t want to support JavaScript: You could just fix only the last bug I mentioned and just rename this library to &lt;q&gt;prettyPrint for ECMAScript&lt;/q&gt;.</description>
		<content:encoded><![CDATA[<p>James, JavaScript and ECMAScript are not the same thing. My code is valid <em>JavaScript</em>, not ECMAScript. JavaScript is just what SpiderMonkey and Rhino implement, as it&#8217;s owned by Mozilla. ECMAScript is a standard based on Mozilla&#8217;s JavaScript. Object destructuring in part of JavaScript 1.7 and implicit returns are part of JavaScript 1.8. <abbr title="As far as I know">Afaik</abbr>, Opera supports basic object destructuring so things like <code>[a, b] = [b, a]</code> work but not advanced stuff.</p>
<p>If you want to see some destructuring documentation (it&#8217;s pretty lacking though), refer to <a href="https://developer.mozilla.org/en/New_in_javascript_1.7">New in JavaScript 1.7</a> on MDC.</p>
<p>I also have another bug report:<br />
prettyPrint throw errors when it is passed E4X XML objects. Unlike the other stuff I have mentioned, E4X actually is part of an Ecma standard (specifically, <a href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMA-357</a>). Stuff like <code>prettyPrint(&lt;foo&gt;&lt;bar/&gt;&lt;baz/&gt;&lt;/foo&gt;)</code> should work after you fix the bug. This can be easily fixed by using the native <code>prettyPrinting</code> in E4X using <code>XML.prettyPrinting</code>, <code>XML.prettyIndent</code>, and <code>XML.prototype.function::toXMLString</code>. It would involve temporarily changing the two prettyPrinting preferences temporarily and reverting them if needed.</p>
<p>An alternative option for if you don&#8217;t want to support JavaScript: You could just fix only the last bug I mentioned and just rename this library to <q>prettyPrint for ECMAScript</q>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/prettyprint-for-javascript/comment-page-1/#comment-13803</link>
		<dc:creator>James</dc:creator>
		<pubDate>Sun, 07 Jun 2009 12:07:40 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=881#comment-13803</guid>
		<description>@Elijah, please forgive my ignorance but is that even &quot;real&quot; JavaScript? Glancing at the Rhino book and the ECMAScript specification I don&#039;t see any mention of nested types as arguments in function definitions. I&#039;ve never seen anything like &lt;code&gt;function([a, b], {”(”:c, d}) { return a+b+c+d }&lt;/code&gt; in the wild... Could you link to some documentation or perhaps a specification detailing this?

As for your first issue (&lt;code&gt;function() 1&lt;/code&gt;), I&#039;ve fixed this as best I can.

Btw, you can force a function to be printed as an object like so:

&lt;pre lang=&quot;javascript&quot;&gt;
prettyPrint( myFunction, { forceObject: true } );
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>@Elijah, please forgive my ignorance but is that even &#8220;real&#8221; JavaScript? Glancing at the Rhino book and the ECMAScript specification I don&#8217;t see any mention of nested types as arguments in function definitions. I&#8217;ve never seen anything like <code>function([a, b], {”(”:c, d}) { return a+b+c+d }</code> in the wild&#8230; Could you link to some documentation or perhaps a specification detailing this?</p>
<p>As for your first issue (<code>function() 1</code>), I&#8217;ve fixed this as best I can.</p>
<p>Btw, you can force a function to be printed as an object like so:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">prettyPrint<span class="br0">&#40;</span> myFunction<span class="sy0">,</span> <span class="br0">&#123;</span> forceObject<span class="sy0">:</span> <span class="kw2">true</span> <span class="br0">&#125;</span> <span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Berny Cantos</title>
		<link>http://james.padolsey.com/javascript/prettyprint-for-javascript/comment-page-1/#comment-13789</link>
		<dc:creator>Berny Cantos</dc:creator>
		<pubDate>Sun, 07 Jun 2009 07:45:46 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=881#comment-13789</guid>
		<description>Awesome! This script goes directly to my debugger toolbox.
A tool like this is a must in a coder&#039;s daily routine, thanks!</description>
		<content:encoded><![CDATA[<p>Awesome! This script goes directly to my debugger toolbox.<br />
A tool like this is a must in a coder&#8217;s daily routine, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Schulman</title>
		<link>http://james.padolsey.com/javascript/prettyprint-for-javascript/comment-page-1/#comment-13768</link>
		<dc:creator>Eric Schulman</dc:creator>
		<pubDate>Sat, 06 Jun 2009 21:37:59 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=881#comment-13768</guid>
		<description>Thanks James, great job!</description>
		<content:encoded><![CDATA[<p>Thanks James, great job!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elijah Grey</title>
		<link>http://james.padolsey.com/javascript/prettyprint-for-javascript/comment-page-1/#comment-13767</link>
		<dc:creator>Elijah Grey</dc:creator>
		<pubDate>Sat, 06 Jun 2009 20:33:22 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=881#comment-13767</guid>
		<description>prettyPrint throws errors if the function body is not wrapped in curly braces. Please fix this. For example, &lt;code&gt;prettyPrint(function() 1)&lt;/code&gt; won&#039;t work.

Also, the whole thing gets messed up when there is are any parenthesis in the arguments. The arguments are also removed from their destructuring context. For example, &lt;code&gt;prettyPrint(function([a, b], {&quot;(&quot;:c, d}) { return a+b+c+d })&lt;/code&gt; puts &lt;code&gt;a, b, c&lt;/code&gt; in the arguments cell and &lt;code&gt;c}) { return a + b + c;&lt;/code&gt; in the body cell. If I remove the &lt;code&gt;{ return &lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;, it puts nothing in the arguments cell and &lt;code&gt;&#039;)&#039;: b}) b + 1;&lt;/code&gt; in the body cell. If the &lt;code&gt;&quot;(&quot;:c&lt;/code&gt; argument is replaced with &lt;code&gt;&quot;)&quot;:c&lt;/code&gt;, then prettyPrint thinks the arguments are &lt;code&gt;a, b,&lt;/code&gt;, including that extra comma.

Arguments can be very complex, so if there is any destructuring, it should be shown just like any object being passed to prettyPrint.</description>
		<content:encoded><![CDATA[<p>prettyPrint throws errors if the function body is not wrapped in curly braces. Please fix this. For example, <code>prettyPrint(function() 1)</code> won&#8217;t work.</p>
<p>Also, the whole thing gets messed up when there is are any parenthesis in the arguments. The arguments are also removed from their destructuring context. For example, <code>prettyPrint(function([a, b], {"(":c, d}) { return a+b+c+d })</code> puts <code>a, b, c</code> in the arguments cell and <code>c}) { return a + b + c;</code> in the body cell. If I remove the <code>{ return </code> and <code>}</code>, it puts nothing in the arguments cell and <code>')': b}) b + 1;</code> in the body cell. If the <code>"(":c</code> argument is replaced with <code>")":c</code>, then prettyPrint thinks the arguments are <code>a, b,</code>, including that extra comma.</p>
<p>Arguments can be very complex, so if there is any destructuring, it should be shown just like any object being passed to prettyPrint.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Donovan</title>
		<link>http://james.padolsey.com/javascript/prettyprint-for-javascript/comment-page-1/#comment-13758</link>
		<dc:creator>Donovan</dc:creator>
		<pubDate>Sat, 06 Jun 2009 17:11:28 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=881#comment-13758</guid>
		<description>Cool.  I did this a while ago, but not pretty. I found it useful to include flags for &#039;hasOwnProperty&#039; and &#039;keys only&#039; (variable names)

It&#039;s really helped.</description>
		<content:encoded><![CDATA[<p>Cool.  I did this a while ago, but not pretty. I found it useful to include flags for &#8216;hasOwnProperty&#8217; and &#8216;keys only&#8217; (variable names)</p>
<p>It&#8217;s really helped.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/prettyprint-for-javascript/comment-page-1/#comment-13757</link>
		<dc:creator>James</dc:creator>
		<pubDate>Sat, 06 Jun 2009 16:43:38 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=881#comment-13757</guid>
		<description>Thanks for the comments! :)


@Sebastian &amp; @Mert, The editor is &lt;a href=&quot;http://www.e-texteditor.com/&quot; rel=&quot;nofollow&quot;&gt;E-textEditor&lt;/a&gt;. The theme is &quot;iPlastic&quot;.

@Mandrake, Are you using Chrome v.2? Older versions (&lt;2) of Chrome don&#039;t support &lt;code&gt;canvas.toDataURL&lt;/code&gt;; if this is the case then it should work now, please try it and let me know. (I would test it myself but my version of Chrome is too new)</description>
		<content:encoded><![CDATA[<p>Thanks for the comments! <img src='http://james.padolsey.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>@Sebastian &#038; @Mert, The editor is <a href="http://www.e-texteditor.com/">E-textEditor</a>. The theme is &#8220;iPlastic&#8221;.</p>
<p>@Mandrake, Are you using Chrome v.2? Older versions (&lt;2) of Chrome don't support <code>canvas.toDataURL</code>; if this is the case then it should work now, please try it and let me know. (I would test it myself but my version of Chrome is too new)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maverick</title>
		<link>http://james.padolsey.com/javascript/prettyprint-for-javascript/comment-page-1/#comment-13756</link>
		<dc:creator>Maverick</dc:creator>
		<pubDate>Sat, 06 Jun 2009 16:13:19 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=881#comment-13756</guid>
		<description>seems to be a very useful thing.

thanks for that</description>
		<content:encoded><![CDATA[<p>seems to be a very useful thing.</p>
<p>thanks for that</p>
]]></content:encoded>
	</item>
</channel>
</rss>
