Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Regenerate annotated source code.

  • Loading branch information...
commit ab2e36fe8d9717cbca543efdad93a03c6a161f2f 1 parent 18b0ad0
David Björklund authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 index.html
View
9 index.html
@@ -1,10 +1,13 @@
<!DOCTYPE html> <html> <head> <title>css2json.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> css2json.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>css2json transform CSS to JSON.</p>
-<p>css2json is a <a href="http://www.opensource.org/licenses/mit-license.php">open source</>
+<p>css2json is a <a href="http://www.opensource.org/licenses/mit-license.php">open source</a>
library for <a href="http://nodejs.org">Node.js</a> (with browser
compability planned) hosted on <a href="https://github.com/kesla/css2json">github</a>
- and written by <a href="http://davidbjorklund.se">David Björklund</a>.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>The annotated source code is below.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Require <a href="http://documentcloud.github.com/underscore/">underscore</a> mainly for
-some sweet chaining.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">_</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;underscore&#39;</span><span class="p">).</span><span class="nx">_</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Main (only) method that parses a string with css to a json-object.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">exports</span><span class="p">.</span><span class="nx">parse</span> <span class="o">=</span> <span class="nx">parse</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">css</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Initialize the return value <em>json</em>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">var</span> <span class="nx">json</span> <span class="o">=</span> <span class="p">{};</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Each rule gets parsed and then removed from <em>css</em> until all rules have been
+ and written by <a href="http://davidbjorklund.se">David Björklund</a>.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Require <a href="http://documentcloud.github.com/underscore/">underscore</a>
+for some utilities and browser support.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">_</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;underscore&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Main (only) method that parses a string with css to a json-object.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">exports</span><span class="p">.</span><span class="nx">parse</span> <span class="o">=</span> <span class="nx">parse</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">css</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Remove all comments from the css-file</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">while</span><span class="p">((</span><span class="nx">open</span> <span class="o">=</span> <span class="nx">css</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s2">&quot;/*&quot;</span><span class="p">))</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span> <span class="o">&amp;&amp;</span>
+ <span class="p">(</span><span class="nx">close</span> <span class="o">=</span> <span class="nx">css</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s2">&quot;*/&quot;</span><span class="p">))</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">css</span> <span class="o">=</span> <span class="nx">css</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nx">open</span><span class="p">)</span> <span class="o">+</span> <span class="nx">css</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="nx">close</span> <span class="o">+</span> <span class="mi">2</span><span class="p">);</span>
+ <span class="p">}</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Initialize the return value <em>json</em>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">var</span> <span class="nx">json</span> <span class="o">=</span> <span class="p">{};</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Each rule gets parsed and then removed from <em>css</em> until all rules have been
parsed.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">while</span><span class="p">(</span><span class="nx">css</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Save the index of the first left bracket and first right bracket.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">var</span> <span class="nx">lbracket</span> <span class="o">=</span> <span class="nx">css</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;{&#39;</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">rbracket</span> <span class="o">=</span> <span class="nx">css</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;}&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <h2>Part 1: The declarations</h2>
Please sign in to comment.
Something went wrong with that request. Please try again.