Fork me on GitHub

annotations.js

by David Capello

Show snippets of your favorite language converting comments to pretty annotations.

From this:

var str = "Hi people";
// Prints "people"
console.log(str.slice(3, 9));
                       //^ The second argument is the end, not length

to this:

var str = "Hi people";
// Prints "people"
console.log(str.slice(3, 9));
                       //^ The second argument is the end, not length

Test your code



Download

Get annotations.js, it needs prettify.

Install

<html>
  <head>
    ...
    <link href="prettify.css" rel="stylesheet">
    <link href="annotations.css" rel="stylesheet">
  </head>
  <body>
    <pre class="prettyprint">
      ...
    </pre>

    <script src="prettify.js" type="text/javascript"></script>
    <script src="annotations.js" type="text/javascript"></script>
    <!-- Prettify your code and then your annotations -->
    <script type="text/javascript">
      PR.prettyPrint();
      prettyAnnotations();
    </script>
  </body>
</html>