Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

marionette-client

Package Overview
Dependencies
Maintainers
11
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marionette-client

Marionette Javascript Client

  • 1.8.1
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-84.13%
Maintainers
11
Weekly downloads
 
Created
Source
Javascript code prettifier
<link href="src/prettify.css" type="text/css" rel="stylesheet" />

<script src="src/prettify.js" type="text/javascript"></script>

<style type="text/css">
  body { margin-left: .5in }
  h1, h2, h3, h4, .footer { margin-left: -.4in; }
</style>
Languages : CH

Javascript code prettifier

<h2>Setup</h2>
<ol>
  <li><a href="http://code.google.com/p/google-code-prettify/downloads/list">Download</a> a distribution
  <li>Include the script and stylesheets in your document
    (you will need to make sure the css and js file are on your server, and
     adjust the paths in the <tt>script</tt> and <tt>link</tt> tag)
    <pre class="prettyprint">

<link href="prettify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="prettify.js"></script>

  • Add onload="prettyPrint()" to your document's body tag.
  • Modify the stylesheet to get the coloring you prefer
  • <h2>Usage</h2>
    <p>Put code snippets in
    <tt>&lt;pre class="prettyprint"&gt;...&lt;/pre&gt;</tt>
    or <tt>&lt;code class="prettyprint"&gt;...&lt;/code&gt;</tt>
    and it will automatically be pretty printed.
    
    <table summary="code examples">
      <tr>
        <th>The original
        <th>Prettier
      <tr>
        <td><pre style="border: 1px solid #888;padding: 2px"
             ><a name="voila1"></a>class Voila {
    

    public: // Voila static const string VOILA = "Voila";

    // will not interfere with embedded tags. }

        <td><pre class="prettyprint"><a name="voila2"></a>class Voila {
    

    public: // Voila static const string VOILA = "Voila";

    // will not interfere with embedded tags. }

    <h2>FAQ</h2>
    <h3 id="langs">Which languages does it work for?</h3>
    <p>The comments in <tt>prettify.js</tt> are authoritative but the lexer
    should work on a number of languages including C and friends,
    Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles.
    It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl
    and Ruby, but, because of commenting conventions, doesn't work on
    Smalltalk, or CAML-like languages.</p>
    
    <p>LISPy languages are supported via an extension:
    <a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-lisp.js"
     ><code>lang-lisp.js</code></a>.</p>
    <p>And similarly for
    <a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-css.js"
     ><code>CSS</code></a>,
    <a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-hs.js"
     ><code>Haskell</code></a>,
    <a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-lua.js"
     ><code>Lua</code></a>,
    <a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-ml.js"
     ><code>OCAML, SML, F#</code></a>,
    <a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-vb.js"
     ><code>Visual Basic</code></a>,
    <a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-sql.js"
     ><code>SQL</code></a>,
    <a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-proto.js"
     ><code>Protocol Buffers</code></a>, and
    <a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-wiki.js"
     ><code>WikiText</code></a>..
    
    <p>If you'd like to add an extension for your favorite language, please
    look at <tt>src/lang-lisp.js</tt> and file an
    <a href="http://code.google.com/p/google-code-prettify/issues/list"
     >issue</a> including your language extension, and a testcase.</p>
    
    <h3>How do I specify which language my code is in?</h3>
    <p>You don't need to specify the language since <code>prettyprint()</code>
    will guess.  You can specify a language by specifying the language extension
    along with the <code>prettyprint</code> class like so:</p>
    <pre class="prettyprint lang-html"
    

    <pre class="prettyprint lang-html"> The lang-* class specifies the language file extensions. File extensions supported by default include "bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html", "java", "js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh", "xhtml", "xml", "xsl". </pre>

    <h3>It doesn't work on <tt>&lt;obfuscated code sample&gt;</tt>?</h3>
    <p>Yes.  Prettifying obfuscated code is like putting lipstick on a pig
    &mdash; i.e. outside the scope of this tool.</p>
    
    <h3>Which browsers does it work with?</h3>
    <p>It's been tested with IE 6, Firefox 1.5 &amp; 2, and Safari 2.0.4.
    Look at <a href="tests/prettify_test.html">the test page</a> to see if it
    works in your browser.</p>
    
    <h3>What's changed?</h3>
    <p>See the <a href="CHANGES.html">change log</a></p>
    
    <h3>Why doesn't Prettyprinting of strings work on WordPress?</h3>
    <p>Apparently wordpress does "smart quoting" which changes close quotes.
    This causes end quotes to not match up with open quotes.
    <p>This breaks prettifying as well as copying and pasting of code samples.
    See
    <a href="http://wordpress.org/support/topic/125038"
    >WordPress's help center</a> for info on how to stop smart quoting of code
    snippets.</p>
    
    <h3 id="linenums">How do I put line numbers in my code?</h3>
    <p>You can use the <code>linenums</code> class to turn on line
    numbering.  If your code doesn't start at line number 1, you can
    add a colon and a line number to the end of that class as in
    <code>linenums:52</code>.
    
    <p>For example
    
    <pre class="prettyprint linenums:4"
    >// This is line 4.
    foo();
    bar();
    baz();
    boo();
    far();
    faz();
    <pre>
    produces
    
    // This is line 4.
    foo();
    bar();
    baz();
    boo();
    far();
    faz();
    
    <h3>How do I prevent a portion of markup from being marked as code?</h3>
    <p>You can use the <code>nocode</code> class to identify a span of markup
    that is not code.
    
    <pre class=prettyprint>
    int x = foo();  /* This is a comment  <span class="nocode">This is not code</span>
      Continuation of comment */
    int y = bar();
    </pre>

    produces

    int x = foo();  /* This is a comment  This is not code
      Continuation of comment */
    int y = bar();
    
    <p>For a more complete example see the issue22
    <a href="tests/prettify_test.html#issue22">testcase</a>.</p>
    
    <h3>I get an error message "a is not a function" or "opt_whenDone is not a function"</h3>
    <p>If you are calling <code>prettyPrint</code> via an event handler, wrap it in a function.
    Instead of doing
    <blockquote>
      <code class="prettyprint lang-js"
       >addEventListener('load', prettyPrint, false);</code>
    </blockquote>
    wrap it in a closure like
    <blockquote>
      <code class="prettyprint lang-js"
       >addEventListener('load', function (event) { prettyPrint() }, false);</code>
    </blockquote>
    so that the browser does not pass an event object to <code>prettyPrint</code> which
    will confuse it.
    
    <br><br><br>
    
    <div class="footer">
    

    Last modified: Wed Jul 19 13:56:00 PST 2010

    </div>
    

    FAQs

    Package last updated on 03 Sep 2015

    Did you know?

    Socket

    Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

    Install

    Related posts

    SocketSocket SOC 2 Logo

    Product

    • Package Alerts
    • Integrations
    • Docs
    • Pricing
    • FAQ
    • Roadmap
    • Changelog

    Packages

    npm

    Stay in touch

    Get open source security insights delivered straight into your inbox.


    • Terms
    • Privacy
    • Security

    Made with ⚡️ by Socket Inc