Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, pick your favorite Javascript based Pretty Print/Beautifier. I prefer the one at <a href="http://jsbeautifier.org/" rel="nofollow noreferrer"><a href="http://jsbeautifier.org/" rel="nofollow noreferrer">http://jsbeautifier.org/</a></a>, because it's what I found first. Downloads its file <a href="https://github.com/beautify-web/js-beautify/blob/master/js/lib/beautify.js" rel="nofollow noreferrer">https://github.com/beautify-web/js-beautify/blob/master/js/lib/beautify.js</a></p> <p>Second, download and install The Mozilla group's Java based Javascript engine, <a href="https://www.mozilla.org/rhino/" rel="nofollow noreferrer">Rhino</a>. "Install" is a little bit misleading; Download the zip file, extract everything, place js.jar in your Java classpath (or Library/Java/Extensions on OS X). You can then run scripts with an invocation similar to this </p> <pre><code>java -cp js.jar org.mozilla.javascript.tools.shell.Main name-of-script.js </code></pre> <p>Use the Pretty Print/Beautifier from step 1 to write a small shell script that will read in your javascript file and run it through the Pretty Print/Beautifier from step one. For example</p> <pre><code>//original code (function() { ... js_beautify code ... }()); //new code print(global.js_beautify(readFile(arguments[0]))); </code></pre> <p>Rhino gives javascript a few extra useful functions that don't necessarily make sense in a browser context, but do in a console context. The function print does what you'd expect, and prints out a string. The function readFile accepts a file path string as an argument and returns the contents of that file. </p> <p>You'd invoke the above something like </p> <pre><code>java -cp js.jar org.mozilla.javascript.tools.shell.Main beautify.js file-to-pp.js </code></pre> <p>You can mix and match Java and Javascript in your Rhino run scripts, so if you know a little Java it shouldn't be too hard to get this running with text-streams as well.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload