Commits

David Chambers committed 0bdfa83

Updated Showdown's annotated source.

  • Participants
  • Parent commits e74cccc

Comments (0)

Files changed (1)

showdown/index.html

 
 <p>Showdown usage:</p>
 
-<pre><code>new Showdown().convert("Markdown *rocks*.")
+<pre><code>var showdown = new Showdown()
+showdown.convert("Markdown *rocks*.")
 --&gt; "&lt;p&gt;Markdown &lt;em&gt;rocks&lt;/em&gt;.&lt;/p&gt;"
 </code></pre>
 
 <span class="nv">blocks = </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>Used to track when we're inside an ordered or unordered list
 (see <code>Text::processListItems</code> for details).</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">level = </span><span class="mi">0</span>
 
-<span class="nv">Showdown = </span><span class="o">-&gt;</span>
+<span class="nv">extensions = </span><span class="p">[]</span>
 
-<span class="k">if</span> <span class="nb">window</span><span class="o">?</span>
-  <span class="nb">window</span><span class="p">.</span><span class="nv">Showdown = </span><span class="nx">Showdown</span> <span class="c1"># browser</span>
-<span class="k">else</span> <span class="k">if</span> <span class="nx">exports</span><span class="o">?</span>
-  <span class="nv">exports.Showdown = </span><span class="nx">Showdown</span> <span class="c1"># CommonJS</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>Converts Markdown to HTML.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">Showdown::convert = </span><span class="nf">(text) -&gt;</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>Clear the global hashes. If we don't clear these, you get conflicts from
+<span class="nv">Showdown = </span><span class="nf">(@extensions...) -&gt;</span>
+  <span class="nv">extensions = </span><span class="nx">@extensions</span>
+
+<span class="nb">window</span><span class="o">?</span><span class="p">.</span><span class="nv">Showdown = </span><span class="nx">Showdown</span> <span class="c1"># browser</span>
+<span class="nx">exports</span><span class="o">?</span><span class="p">.</span><span class="nv">Showdown = </span><span class="nx">Showdown</span> <span class="c1"># CommonJS</span>
+
+<span class="nv">Showdown.Text = </span><span class="o">-&gt;</span> <span class="nx">Text</span>
+
+<span class="nv">processors = </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>Registers an extension.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">Showdown.register = </span><span class="nf">(name, preprocessor, processor) -&gt;</span>
+  <span class="nx">processors</span><span class="p">.</span><span class="nx">push</span> <span class="p">[</span><span class="nx">name</span><span class="p">,</span> <span class="nx">preprocessor</span><span class="p">,</span> <span class="nx">processor</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>Converts Markdown to HTML.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">Showdown::convert = </span><span class="nf">(text) -&gt;</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>Clear the global hashes. If we don't clear these, you get conflicts from
 other articles when generating a page which contains more than one article
 (for example an index page that displays the N most recent articles).</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">urls = </span><span class="p">{}</span>
   <span class="nv">titles = </span><span class="p">{}</span>
   <span class="nv">blocks = </span><span class="p">[]</span>
 
-  <span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">text</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><em>attacklab:</em> Replace <code>~</code> with <code>~T</code>. This lets us use tilde as an
+  <span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">text</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><em>attacklab:</em> Replace <code>~</code> with <code>~T</code>. This lets us use tilde as an
 escape character to avoid md5 hashes. The choice of character is
-arbitrary; anything that isn't magic in Markdown will work.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/~/g</span><span class="p">,</span> <span class="s1">&#39;~T&#39;</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><em>attacklab:</em> Replace <code>$</code> with <code>~D</code>. <code>RegExp</code> interprets <code>$</code> as a
-special character when it's in a replacement string.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\$/g</span><span class="p">,</span> <span class="s1">&#39;~D&#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>               <p>Standardize line endings.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\r\n?/g</span><span class="p">,</span> <span class="s1">&#39;\n&#39;</span><span class="p">)</span>
+arbitrary; anything that isn't magic in Markdown will work.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/~/g</span><span class="p">,</span> <span class="s1">&#39;~T&#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>               <p><em>attacklab:</em> Replace <code>$</code> with <code>~D</code>. <code>RegExp</code> interprets <code>$</code> as a
+special character when it's in a replacement string.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\$/g</span><span class="p">,</span> <span class="s1">&#39;~D&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-9">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-9">&#182;</a>               </div>               <p>Standardize line endings.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\r\n?/g</span><span class="p">,</span> <span class="s1">&#39;\n&#39;</span><span class="p">)</span>
 
     <span class="p">.</span><span class="nx">detab</span><span class="p">()</span>
     <span class="p">.</span><span class="nx">trim</span><span class="p">(</span><span class="sr">/^ +$/mg</span><span class="p">)</span>
     <span class="p">.</span><span class="nx">before</span><span class="p">(</span><span class="s1">&#39;\n\n&#39;</span><span class="p">)</span>
     <span class="p">.</span><span class="nx">after</span><span class="p">(</span><span class="s1">&#39;\n\n&#39;</span><span class="p">)</span>
     <span class="p">.</span><span class="nx">hashHtmlBlocks</span><span class="p">()</span>
+    <span class="p">.</span><span class="nx">preprocess</span><span class="p">()</span>
     <span class="p">.</span><span class="nx">stripLinkDefinitions</span><span class="p">()</span>
     <span class="p">.</span><span class="nx">runBlockGamut</span><span class="p">()</span>
     <span class="p">.</span><span class="nx">unescapeSpecialChars</span><span class="p">()</span>
     <span class="err">@</span>
 
   <span class="nv">toString: </span><span class="o">-&gt;</span>
-    <span class="nx">@value</span></pre></div>             </td>           </tr>                               <tr id="section-9">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-9">&#182;</a>               </div>               <p>Strips link definitions from text and stores them in <code>urls</code> and <code>titles</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">stripLinkDefinitions: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-10">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-10">&#182;</a>               </div>               <p>Link definitions are in the form: <code>^[id]: url "optional title"</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span>
+    <span class="nx">@value</span></pre></div>             </td>           </tr>                               <tr id="section-10">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-10">&#182;</a>               </div>               <p>Performs preprocessing for each of the active extensions.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">preprocess: </span><span class="o">-&gt;</span>
+    <span class="k">for</span> <span class="p">[</span><span class="nx">name</span><span class="p">,</span> <span class="nx">preprocessor</span><span class="p">],</span> <span class="nx">index</span> <span class="k">in</span> <span class="nx">processors</span>
+      <span class="k">if</span> <span class="nx">name</span> <span class="k">in</span> <span class="nx">extensions</span>
+        <span class="nx">processors</span><span class="p">[</span><span class="nx">index</span><span class="p">][</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="nx">preprocessor</span><span class="p">.</span><span class="nx">call</span> <span class="err">@</span>
+    <span class="err">@</span></pre></div>             </td>           </tr>                               <tr id="section-11">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-11">&#182;</a>               </div>               <p>Performs further processing for each of the active extensions. Data
+returned earlier by the preprocessor is passed on to the processor.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">process: </span><span class="o">-&gt;</span>
+    <span class="k">for</span> <span class="p">[</span><span class="nx">name</span><span class="p">,</span> <span class="nx">preprocessor</span><span class="p">,</span> <span class="nx">processor</span><span class="p">,</span> <span class="nx">data</span><span class="p">]</span> <span class="k">in</span> <span class="nx">processors</span>
+      <span class="k">if</span> <span class="nx">name</span> <span class="k">in</span> <span class="nx">extensions</span>
+        <span class="nx">processor</span><span class="p">.</span><span class="nx">call</span> <span class="err">@</span><span class="p">,</span> <span class="nx">data</span>
+    <span class="err">@</span></pre></div>             </td>           </tr>                               <tr id="section-12">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-12">&#182;</a>               </div>               <p>Strips link definitions from text and stores them in <code>urls</code> and <code>titles</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">stripLinkDefinitions: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-13">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-13">&#182;</a>               </div>               <p>Link definitions are in the form: <code>^[id]: url "optional title"</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span>
       <span class="err">///</span>
       <span class="o">^</span> <span class="err">\</span><span class="nx">x20</span><span class="p">{</span><span class="mi">0</span><span class="p">,</span><span class="mi">3</span><span class="p">}</span>
         <span class="err">\</span><span class="p">[(.</span><span class="o">+</span><span class="p">)</span><span class="err">\</span><span class="p">]</span><span class="o">:</span>
         <span class="p">(</span><span class="o">?:</span><span class="err">\</span><span class="nx">n</span><span class="o">+|</span><span class="err">\</span><span class="nx">Z</span><span class="p">)</span>
       <span class="o">/</span><span class="err">//gm,</span>
       <span class="nf">(_, m1, m2, m3, m4) -&gt;</span>
-        <span class="nv">m1 = </span><span class="nx">m1</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">()</span>
-        <span class="nx">urls</span><span class="p">[</span><span class="nx">m1</span><span class="p">]</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">m2</span><span class="p">).</span><span class="nx">encodeAmpsAndAngles</span><span class="p">().</span><span class="nx">value</span> <span class="c1"># Link IDs are case-insensitive</span></pre></div>             </td>           </tr>                               <tr id="section-11">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-11">&#182;</a>               </div>               <p>Oops, found blank lines, so it's not a title.
+        <span class="nv">m1 = </span><span class="nx">m1</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">()</span> <span class="c1"># link identifiers are case-insensitive</span>
+        <span class="nx">urls</span><span class="p">[</span><span class="nx">m1</span><span class="p">]</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">m2</span><span class="p">).</span><span class="nx">encodeAmpsAndAngles</span><span class="p">().</span><span class="nx">value</span></pre></div>             </td>           </tr>                               <tr id="section-14">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-14">&#182;</a>               </div>               <p>Oops, found blank lines, so it's not a title.
 Put back the parenthetical statement we stole.</p>             </td>             <td class="code">               <div class="highlight"><pre>        <span class="k">return</span> <span class="nx">m3</span> <span class="o">+</span> <span class="nx">m4</span> <span class="k">if</span> <span class="nx">m3</span>
 
-        <span class="nx">titles</span><span class="p">[</span><span class="nx">m1</span><span class="p">]</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">m4</span><span class="p">).</span><span class="nx">quot</span><span class="p">().</span><span class="nx">value</span> <span class="k">if</span> <span class="nx">m4</span></pre></div>             </td>           </tr>                               <tr id="section-12">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-12">&#182;</a>               </div>               <p>Completely remove the definition from the text.</p>             </td>             <td class="code">               <div class="highlight"><pre>        <span class="s1">&#39;&#39;</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-13">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-13">&#182;</a>               </div>               <p>Hashifies HTML blocks.</p>
+        <span class="nx">titles</span><span class="p">[</span><span class="nx">m1</span><span class="p">]</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">m4</span><span class="p">).</span><span class="nx">quot</span><span class="p">().</span><span class="nx">value</span> <span class="k">if</span> <span class="nx">m4</span></pre></div>             </td>           </tr>                               <tr id="section-15">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-15">&#182;</a>               </div>               <p>Completely remove the definition from the text.</p>             </td>             <td class="code">               <div class="highlight"><pre>        <span class="s1">&#39;&#39;</span>
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-16">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-16">&#182;</a>               </div>               <p>Hashifies HTML blocks.</p>
 
 <p>We only want to do this for block-level HTML tags, such as headings,
 lists, and tables. That's because we still want to wrap <code>&lt;p&gt;</code>s around
 the inner nested divs must be indented.</p>
 
 <p>We need to do this before the next, more liberal match, because the next
-match will start at the first <code>&lt;div&gt;</code> and stop at the first <code>&lt;/div&gt;</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">hashHtmlBlocks: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-14">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-14">&#182;</a>               </div>               <p><em>attacklab:</em> Double up blank lines to reduce lookaround.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span><span class="sr">/\n/g</span><span class="p">,</span> <span class="s1">&#39;\n\n&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-15">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-15">&#182;</a>               </div>               <p><em>attacklab:</em> This regex can be expensive when it fails.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
+match will start at the first <code>&lt;div&gt;</code> and stop at the first <code>&lt;/div&gt;</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">hashHtmlBlocks: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-17">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-17">&#182;</a>               </div>               <p><em>attacklab:</em> Double up blank lines to reduce lookaround.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span><span class="sr">/\n/g</span><span class="p">,</span> <span class="s1">&#39;\n\n&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-18">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-18">&#182;</a>               </div>               <p><em>attacklab:</em> This regex can be expensive when it fails.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
       <span class="err">///</span>
       <span class="o">^</span> <span class="p">(</span>
           <span class="o">&lt;</span>
         <span class="p">)</span>
       <span class="o">/</span><span class="err">//gm,</span>
       <span class="nx">hashElement</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-16">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-16">&#182;</a>               </div>               <p>Now match more liberally, simply from <code>\n&lt;tag&gt;</code> to <code>&lt;/tag&gt;\n</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-19">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-19">&#182;</a>               </div>               <p>Now match more liberally, simply from <code>\n&lt;tag&gt;</code> to <code>&lt;/tag&gt;\n</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
       <span class="err">///</span>
       <span class="o">^</span> <span class="p">(</span>
           <span class="o">&lt;</span>
         <span class="p">)</span>
       <span class="o">/</span><span class="err">//gm,</span>
       <span class="nx">hashElement</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-17">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-17">&#182;</a>               </div>               <p>Special case for <code>&lt;hr /&gt;</code>. It was easier to make a special case than to
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-20">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-20">&#182;</a>               </div>               <p>Special case for <code>&lt;hr /&gt;</code>. It was easier to make a special case than to
 make the other regex more complicated.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
       <span class="sr">/(\n[ ]{0,3}(&lt;(hr)\b([^&lt;&gt;])*?\/?&gt;)[ \t]*(?=\n{2,}))/g</span><span class="p">,</span>
       <span class="nx">hashElement</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-18">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-18">&#182;</a>               </div>               <p>Special case for standalone HTML comments.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-21">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-21">&#182;</a>               </div>               <p>Special case for standalone HTML comments.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
       <span class="sr">/(\n\n[ ]{0,3}&lt;!(--[^\r]*?--\s*)+&gt;[ \t]*(?=\n{2,}))/g</span><span class="p">,</span>
       <span class="nx">hashElement</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-19">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-19">&#182;</a>               </div>               <p>PHP and ASP-style processor instructions (<code>&lt;?...?&gt;</code> and <code>&lt;%...%&gt;</code>).</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
-      <span class="sr">/(?:\n\n)([ ]{0,3}(?:&lt;([?%])[^\r]*?\2&gt;)[ \t]*(?=\n{2,}))/g</span><span class="p">,</span>
-      <span class="nx">hashElement</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-20">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-20">&#182;</a>               </div>               <p><em>attacklab:</em> Undo double lines (see comment at top of this function).</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\n\n/g</span><span class="p">,</span> <span class="s1">&#39;\n&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-21">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-21">&#182;</a>               </div>               <p>Transformations that form block-level tags such as paragraphs, headings,
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-22">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-22">&#182;</a>               </div>               <p><em>attacklab:</em> Undo double lines (see comment at top of this function).</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\n\n/g</span><span class="p">,</span> <span class="s1">&#39;\n&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-23">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-23">&#182;</a>               </div>               <p>Transformations that form block-level tags such as paragraphs, headings,
 and list items.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">runBlockGamut: </span><span class="o">-&gt;</span>
     <span class="nv">key = </span><span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="s1">&#39;&lt;hr /&gt;&#39;</span><span class="p">).</span><span class="nx">hashBlock</span><span class="p">().</span><span class="nx">value</span>
-    <span class="nx">@doHeaders</span><span class="p">()</span></pre></div>             </td>           </tr>                               <tr id="section-22">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-22">&#182;</a>               </div>               <p>Horizontal rules.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/^[ ]{0,3}([*_-])[ ]?(?:\1[ ]?){2,}[ \t]*$/gm</span><span class="p">,</span> <span class="nx">key</span><span class="p">)</span>
+    <span class="nx">@doHeaders</span><span class="p">()</span></pre></div>             </td>           </tr>                               <tr id="section-24">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-24">&#182;</a>               </div>               <p>Horizontal rules.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/^[ ]{0,3}([*_-])[ ]?(?:\1[ ]?){2,}[ \t]*$/gm</span><span class="p">,</span> <span class="nx">key</span><span class="p">)</span>
 
     <span class="p">.</span><span class="nx">doLists</span><span class="p">()</span>
     <span class="p">.</span><span class="nx">doCodeBlocks</span><span class="p">()</span>
-    <span class="p">.</span><span class="nx">doBlockQuotes</span><span class="p">()</span></pre></div>             </td>           </tr>                               <tr id="section-23">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-23">&#182;</a>               </div>               <p>We ran <code>Text::hashHtmlBlocks</code> before, in <code>Showdown::convert</code>, but that
+    <span class="p">.</span><span class="nx">doBlockQuotes</span><span class="p">()</span></pre></div>             </td>           </tr>                               <tr id="section-25">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-25">&#182;</a>               </div>               <p>We ran <code>Text::hashHtmlBlocks</code> before, in <code>Showdown::convert</code>, but that
 was to escape raw HTML in the original Markdown source. This time we're
 escaping the markup we've just created, so that we don't wrap <code>&lt;p&gt;</code> tags
 around block-level tags.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">hashHtmlBlocks</span><span class="p">()</span>
-    <span class="p">.</span><span class="nx">formParagraphs</span><span class="p">()</span></pre></div>             </td>           </tr>                               <tr id="section-24">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-24">&#182;</a>               </div>               <p>Transformations <em>within</em> block-level tags such as paragraphs, headings,
+    <span class="p">.</span><span class="nx">formParagraphs</span><span class="p">()</span></pre></div>             </td>           </tr>                               <tr id="section-26">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-26">&#182;</a>               </div>               <p>Transformations <em>within</em> block-level tags such as paragraphs, headings,
 and list items.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">runSpanGamut: </span><span class="o">-&gt;</span>
     <span class="nx">@doCodeSpans</span><span class="p">()</span>
     <span class="p">.</span><span class="nx">escapeSpecialCharsWithinTagAttributes</span><span class="p">()</span>
     <span class="p">.</span><span class="nx">doAutoLinks</span><span class="p">()</span>
     <span class="p">.</span><span class="nx">encodeAmpsAndAngles</span><span class="p">()</span>
     <span class="p">.</span><span class="nx">doItalicsAndBold</span><span class="p">()</span>
-    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/[ ]{2,}\n/g</span><span class="p">,</span> <span class="s1">&#39; &lt;br /&gt;\n&#39;</span><span class="p">)</span> <span class="c1"># do hard breaks</span></pre></div>             </td>           </tr>                               <tr id="section-25">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-25">&#182;</a>               </div>               <p>Within tags -- meaning between <code>&lt;</code> and <code>&gt;</code> -- encode <code>\</code>, <code>`</code>,
+    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/[ ]{2,}\n/g</span><span class="p">,</span> <span class="s1">&#39; &lt;br /&gt;\n&#39;</span><span class="p">)</span> <span class="c1"># do hard breaks</span>
+    <span class="p">.</span><span class="nx">process</span><span class="p">()</span></pre></div>             </td>           </tr>                               <tr id="section-27">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-27">&#182;</a>               </div>               <p>Within tags -- meaning between <code>&lt;</code> and <code>&gt;</code> -- encode <code>\</code>, <code>`</code>,
 <code>*</code>, and <code>_</code> so they don't conflict with their use in Markdown
 for code, italics and strong.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">escapeSpecialCharsWithinTagAttributes: </span><span class="o">-&gt;</span>
     <span class="nx">@replace</span><span class="p">(</span>
         <span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">match</span><span class="p">)</span>
           <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/(.)&lt;\/?code&gt;(?=.)/g</span><span class="p">,</span> <span class="s1">&#39;$1`&#39;</span><span class="p">)</span>
           <span class="p">.</span><span class="nx">escapeCharacters</span><span class="p">(</span><span class="s1">&#39;\\`*_&#39;</span><span class="p">)</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-26">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-26">&#182;</a>               </div>               <p>Turn Markdown link shortcuts into XHTML <code>&lt;a&gt;</code> tags.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">doAnchors: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-27">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-27">&#182;</a>               </div>               <p>First, handle reference-style links: <code>[link text] [id]</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span>
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-28">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-28">&#182;</a>               </div>               <p>Turn Markdown link shortcuts into XHTML <code>&lt;a&gt;</code> tags.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">doAnchors: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-29">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-29">&#182;</a>               </div>               <p>First, handle reference-style links: <code>[link text] [id]</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span>
       <span class="err">///</span>
         <span class="err">\</span><span class="p">[</span>
         <span class="p">((</span><span class="o">?:</span><span class="err">\</span><span class="p">[[</span><span class="o">^</span><span class="err">\</span><span class="p">]]</span><span class="o">*</span><span class="err">\</span><span class="p">]</span><span class="o">|</span><span class="p">[</span><span class="o">^</span><span class="err">\</span><span class="p">[</span><span class="err">\</span><span class="p">]])</span><span class="o">*</span><span class="p">)</span>
         <span class="p">()()()()</span>
       <span class="o">/</span><span class="err">//g,</span>
       <span class="nx">writeAnchorTag</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-28">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-28">&#182;</a>               </div>               <p>Next, inline-style links: <code>[link text](url "optional title")</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-30">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-30">&#182;</a>               </div>               <p>Next, inline-style links: <code>[link text](url "optional title")</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
       <span class="err">///</span>
         <span class="err">\</span><span class="p">[</span>
         <span class="p">((</span><span class="o">?:</span><span class="err">\</span><span class="p">[[</span><span class="o">^</span><span class="err">\</span><span class="p">]]</span><span class="o">*</span><span class="err">\</span><span class="p">]</span><span class="o">|</span><span class="p">[</span><span class="o">^</span><span class="err">\</span><span class="p">[</span><span class="err">\</span><span class="p">]])</span><span class="o">*</span><span class="p">)</span>
         <span class="err">\</span><span class="p">)</span>
       <span class="o">/</span><span class="err">//g,</span>
       <span class="nx">writeAnchorTag</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-29">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-29">&#182;</a>               </div>               <p>Last, handle reference-style shortcuts: <code>[link text]</code>. These must come
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-31">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-31">&#182;</a>               </div>               <p>Last, handle reference-style shortcuts: <code>[link text]</code>. These must come
 last in case you've also got <code>[link test][1]</code> or <code>[link test](/foo)</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
       <span class="sr">/\[([^\[\]]+)\]()()()()()/g</span><span class="p">,</span>
       <span class="nx">writeAnchorTag</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-30">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-30">&#182;</a>               </div>               <p>Turn Markdown image shortcuts into <code>&lt;img&gt;</code> tags.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">doImages: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-31">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-31">&#182;</a>               </div>               <p>First, handle reference-style labeled images: <code>![alt text][id]</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span>
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-32">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-32">&#182;</a>               </div>               <p>Turn Markdown image shortcuts into <code>&lt;img&gt;</code> tags.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">doImages: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-33">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-33">&#182;</a>               </div>               <p>First, handle reference-style labeled images: <code>![alt text][id]</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span>
       <span class="sr">/!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\]()()()()/g</span><span class="p">,</span>
       <span class="nx">writeImageTag</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-32">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-32">&#182;</a>               </div>               <p>Next, handle inline images: <code>![alt text](url "optional title")</code>.
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-34">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-34">&#182;</a>               </div>               <p>Next, handle inline images: <code>![alt text](url "optional title")</code>.
 Don't forget: encode <code>*</code> and <code>_</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
       <span class="err">///</span>
         <span class="o">!</span><span class="err">\</span><span class="p">[(.</span><span class="o">*?</span><span class="p">)</span><span class="err">\</span><span class="p">]</span><span class="err">\</span><span class="nx">s</span><span class="o">?</span>
       <span class="nx">writeImageTag</span>
     <span class="p">)</span>
 
-  <span class="nv">doHeaders: </span><span class="p">(</span><span class="o">-&gt;</span>
+  <span class="nv">doHeaders: </span><span class="o">-&gt;</span>
     <span class="nv">sub = </span><span class="nf">(text, tag) -&gt;</span>
       <span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">text</span><span class="p">)</span>
         <span class="p">.</span><span class="nx">runSpanGamut</span><span class="p">()</span>
-        <span class="p">.</span><span class="nx">before</span><span class="p">(</span><span class="s2">&quot;&lt;#{ tag }&gt;&quot;</span><span class="p">)</span>
-        <span class="p">.</span><span class="nx">after</span><span class="p">(</span><span class="s2">&quot;&lt;/#{ tag }&gt;&quot;</span><span class="p">)</span>
-        <span class="p">.</span><span class="nx">hashBlock</span><span class="nf">()</span>
-<span class="nf">    -&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-33">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-33">&#182;</a>               </div>               <p>Setext-style headings.</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="nx">@replace</span><span class="p">(</span>
-        <span class="sr">/^(?![ ]{0,3}-[ \t])(.+)[ \t]*\n(?:(=+)|-+)[ \t]*\n+/gm</span><span class="p">,</span>
-        <span class="nf">(_, m1, h1) -&gt;</span> <span class="nx">sub</span> <span class="nx">m1</span><span class="p">,</span> <span class="k">if</span> <span class="nx">h1</span> <span class="k">then</span> <span class="s1">&#39;h1&#39;</span> <span class="k">else</span> <span class="s1">&#39;h2&#39;</span>
-      <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-34">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-34">&#182;</a>               </div>               <p>atx-style headings.</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
-        <span class="sr">/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm</span><span class="p">,</span>
-        <span class="nf">(_, m1, m2) -&gt;</span> <span class="nx">sub</span> <span class="nx">m2</span><span class="p">,</span> <span class="s1">&#39;h&#39;</span> <span class="o">+</span> <span class="nx">m1</span><span class="p">.</span><span class="nx">length</span>
-      <span class="p">)</span>
-  <span class="p">)()</span></pre></div>             </td>           </tr>                               <tr id="section-35">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-35">&#182;</a>               </div>               <p>Form HTML ordered (numbered) and unordered (bulleted) lists.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">doLists: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-36">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-36">&#182;</a>               </div>               <p><em>attacklab:</em> Add sentinel to hack around
+        <span class="p">.</span><span class="nx">before</span><span class="p">(</span><span class="s2">&quot;&lt;#{tag}&gt;&quot;</span><span class="p">)</span>
+        <span class="p">.</span><span class="nx">after</span><span class="p">(</span><span class="s2">&quot;&lt;/#{tag}&gt;&quot;</span><span class="p">)</span>
+        <span class="p">.</span><span class="nx">hashBlock</span><span class="p">()</span></pre></div>             </td>           </tr>                               <tr id="section-35">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-35">&#182;</a>               </div>               <p>Setext-style headings.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span>
+      <span class="sr">/^(?![ ]{0,3}-[ \t])(.+)[ \t]*\n(?:(=+)|-+)[ \t]*\n+/gm</span><span class="p">,</span>
+      <span class="nf">(_, m1, h1) -&gt;</span> <span class="nx">sub</span> <span class="nx">m1</span><span class="p">,</span> <span class="k">if</span> <span class="nx">h1</span> <span class="k">then</span> <span class="s1">&#39;h1&#39;</span> <span class="k">else</span> <span class="s1">&#39;h2&#39;</span>
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-36">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-36">&#182;</a>               </div>               <p>atx-style headings.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
+      <span class="sr">/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm</span><span class="p">,</span>
+      <span class="nf">(_, m1, m2) -&gt;</span> <span class="nx">sub</span> <span class="nx">m2</span><span class="p">,</span> <span class="s1">&#39;h&#39;</span> <span class="o">+</span> <span class="nx">m1</span><span class="p">.</span><span class="nx">length</span>
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-37">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-37">&#182;</a>               </div>               <p>Form HTML ordered (numbered) and unordered (bulleted) lists.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">doLists: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-38">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-38">&#182;</a>               </div>               <p><em>attacklab:</em> Add sentinel to hack around
 <a href="https://bugs.webkit.org/show_bug.cgi?id=11231">khtml/safari bug</a>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@after</span><span class="p">(</span><span class="s1">&#39;~0&#39;</span><span class="p">)</span>
     <span class="p">.</span><span class="nx">cond</span><span class="p">(</span>
       <span class="nx">level</span><span class="p">,</span>
             <span class="p">(</span><span class="o">?:~</span><span class="mi">0</span><span class="o">|</span><span class="err">\</span><span class="nx">n</span><span class="p">{</span><span class="mi">2</span><span class="p">,}(</span><span class="o">?=</span><span class="err">\</span><span class="nx">S</span><span class="p">)(</span><span class="o">?!</span><span class="p">[</span><span class="err">\</span><span class="nx">x20</span><span class="err">\</span><span class="nx">t</span><span class="p">]</span><span class="o">*</span><span class="p">(</span><span class="o">?:</span><span class="p">[</span><span class="o">*+-</span><span class="p">]</span><span class="o">|</span><span class="err">\</span><span class="nx">d</span><span class="o">+</span><span class="p">[.])[</span><span class="err">\</span><span class="nx">x20</span><span class="err">\</span><span class="nx">t</span><span class="p">]</span><span class="o">+</span><span class="p">))</span>
           <span class="o">/</span><span class="err">//gm,</span>
           <span class="nf">(list, unordered) -&gt;</span>
-            <span class="nv">tag = </span><span class="k">if</span> <span class="nx">unordered</span> <span class="k">then</span> <span class="s1">&#39;ul&#39;</span> <span class="k">else</span> <span class="s1">&#39;ol&#39;</span></pre></div>             </td>           </tr>                               <tr id="section-37">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-37">&#182;</a>               </div>               <p>Turn double returns into triple returns, so that we can make a
-paragraph for the last item in a list, if necessary.</p>             </td>             <td class="code">               <div class="highlight"><pre>            <span class="nv">result = </span><span class="nx">processListItems</span><span class="p">(</span><span class="nx">list</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/\n{2,}/g</span><span class="p">,</span> <span class="s1">&#39;\n\n\n&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-38">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-38">&#182;</a>               </div>               <p>Trim any trailing whitespace, to put the closing <code>&lt;/ol&gt;</code>/<code>&lt;/ul&gt;</code>
+            <span class="nv">tag = </span><span class="k">if</span> <span class="nx">unordered</span> <span class="k">then</span> <span class="s1">&#39;ul&#39;</span> <span class="k">else</span> <span class="s1">&#39;ol&#39;</span></pre></div>             </td>           </tr>                               <tr id="section-39">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-39">&#182;</a>               </div>               <p>Turn double returns into triple returns, so that we can make a
+paragraph for the last item in a list, if necessary.</p>             </td>             <td class="code">               <div class="highlight"><pre>            <span class="nv">result = </span><span class="nx">processListItems</span><span class="p">(</span><span class="nx">list</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/\n{2,}/g</span><span class="p">,</span> <span class="s1">&#39;\n\n\n&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-40">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-40">&#182;</a>               </div>               <p>Trim any trailing whitespace, to put the closing <code>&lt;/ol&gt;</code>/<code>&lt;/ul&gt;</code>
 up on the preceding line, to get it past the current stupid HTML
 block parser. This is a hack to work around the terrible hack
-that is the HTML block parser.</p>             </td>             <td class="code">               <div class="highlight"><pre>            <span class="s2">&quot;&lt;#{ tag }&gt;\n#{ result.replace /\s+$/, &#39;&#39; }\n&lt;/#{ tag }&gt;\n&quot;</span>
+that is the HTML block parser.</p>             </td>             <td class="code">               <div class="highlight"><pre>            <span class="s2">&quot;&lt;#{tag}&gt;\n#{result.replace /\s+$/, &#39;&#39;}\n&lt;/#{tag}&gt;\n&quot;</span>
         <span class="p">)</span>
       <span class="o">-&gt;</span>
         <span class="nx">@replace</span><span class="p">(</span>
             <span class="p">)</span>
           <span class="o">/</span><span class="err">//g,</span>
           <span class="nf">(_, runup, list, unordered) -&gt;</span>
-            <span class="nv">tag = </span><span class="k">if</span> <span class="nx">unordered</span> <span class="k">then</span> <span class="s1">&#39;ul&#39;</span> <span class="k">else</span> <span class="s1">&#39;ol&#39;</span></pre></div>             </td>           </tr>                               <tr id="section-39">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-39">&#182;</a>               </div>               <p>Turn double returns into triple returns, so that we can make a
+            <span class="nv">tag = </span><span class="k">if</span> <span class="nx">unordered</span> <span class="k">then</span> <span class="s1">&#39;ul&#39;</span> <span class="k">else</span> <span class="s1">&#39;ol&#39;</span></pre></div>             </td>           </tr>                               <tr id="section-41">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-41">&#182;</a>               </div>               <p>Turn double returns into triple returns, so that we can make a
 paragraph for the last item in a list, if necessary.</p>             </td>             <td class="code">               <div class="highlight"><pre>            <span class="nv">list = </span><span class="nx">list</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/\n{2,}/g</span><span class="p">,</span> <span class="s1">&#39;\n\n\n&#39;</span>
 
-            <span class="s2">&quot;#{ runup }&lt;#{ tag }&gt;\n#{ processListItems list }&lt;/#{ tag }&gt;\n&quot;</span>
+            <span class="s2">&quot;#{runup}&lt;#{tag}&gt;\n#{processListItems list}&lt;/#{tag}&gt;\n&quot;</span>
         <span class="p">)</span>
     <span class="p">)</span>
-    <span class="p">.</span><span class="nx">trim</span> <span class="sr">/~0/</span> <span class="c1"># attacklab: strip sentinel</span></pre></div>             </td>           </tr>                               <tr id="section-40">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-40">&#182;</a>               </div>               <p>Process Markdown <code>&lt;pre&gt;&lt;code&gt;</code> blocks.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">doCodeBlocks: </span><span class="o">-&gt;</span>
+    <span class="p">.</span><span class="nx">trim</span> <span class="sr">/~0/</span> <span class="c1"># attacklab: strip sentinel</span></pre></div>             </td>           </tr>                               <tr id="section-42">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-42">&#182;</a>               </div>               <p>Process Markdown <code>&lt;pre&gt;&lt;code&gt;</code> blocks.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">doCodeBlocks: </span><span class="o">-&gt;</span>
     <span class="nx">@replace</span><span class="p">(</span>
       <span class="err">///</span>
         <span class="p">(</span><span class="o">?:</span><span class="err">\</span><span class="nx">n</span><span class="err">\</span><span class="nx">n</span><span class="o">|^</span><span class="p">)</span>
     <span class="p">)</span>
 
   <span class="nv">hashBlock: </span><span class="o">-&gt;</span>
-    <span class="nx">@set</span> <span class="s2">&quot;\n\n~K#{ blocks.push(@value.trim()) - 1 }K\n\n&quot;</span>
+    <span class="nx">@set</span> <span class="s2">&quot;\n\n~K#{blocks.push(@value.trim()) - 1}K\n\n&quot;</span>
 
   <span class="nv">doCodeSpans: </span><span class="o">-&gt;</span>
     <span class="nx">@replace</span><span class="p">(</span>
           <span class="p">.</span><span class="nx">encodeCode</span><span class="p">()</span>
           <span class="p">.</span><span class="nx">before</span><span class="p">(</span><span class="nx">m1</span> <span class="o">+</span> <span class="s1">&#39;&lt;code&gt;&#39;</span><span class="p">)</span>
           <span class="p">.</span><span class="nx">after</span><span class="p">(</span><span class="s1">&#39;&lt;/code&gt;&#39;</span><span class="p">)</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-41">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-41">&#182;</a>               </div>               <p>Encode/escape certain characters inside Markdown code runs. The point
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-43">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-43">&#182;</a>               </div>               <p>Encode/escape certain characters inside Markdown code runs. The point
 is that in code, these characters are literals, and lose their special
-Markdown meanings.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">encodeCode: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-42">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-42">&#182;</a>               </div>               <p>Encode all ampersands (HTML entities are
-not entities within a Markdown code span).</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span><span class="sr">/&amp;/g</span><span class="p">,</span> <span class="s1">&#39;&amp;amp;&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-43">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-43">&#182;</a>               </div>               <p>Do the angle bracket song and dance.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/&lt;/g</span><span class="p">,</span> <span class="s1">&#39;&amp;lt;&#39;</span><span class="p">)</span>
+Markdown meanings.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">encodeCode: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-44">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-44">&#182;</a>               </div>               <p>Encode all ampersands (HTML entities are
+not entities within a Markdown code span).</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span><span class="sr">/&amp;/g</span><span class="p">,</span> <span class="s1">&#39;&amp;amp;&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-45">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-45">&#182;</a>               </div>               <p>Do the angle bracket song and dance.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/&lt;/g</span><span class="p">,</span> <span class="s1">&#39;&amp;lt;&#39;</span><span class="p">)</span>
     <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/&gt;/g</span><span class="p">,</span> <span class="s1">&#39;&amp;gt;&#39;</span><span class="p">)</span>
 
     <span class="p">.</span><span class="nx">escapeCharacters</span><span class="p">(</span><span class="s1">&#39;*_{}[]\\&#39;</span><span class="p">)</span>
 
-  <span class="nv">doItalicsAndBold: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-44">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-44">&#182;</a>               </div>               <p><code>&lt;strong&gt;</code> must go first.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span>
+  <span class="nv">doItalicsAndBold: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-46">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-46">&#182;</a>               </div>               <p><code>&lt;strong&gt;</code> must go first.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span>
       <span class="sr">/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g</span><span class="p">,</span>
       <span class="s1">&#39;&lt;strong&gt;$2&lt;/strong&gt;&#39;</span>
     <span class="p">)</span>
 
   <span class="nv">formParagraphs: </span><span class="o">-&gt;</span>
     <span class="nv">grafs = </span><span class="nx">@value</span><span class="p">.</span><span class="nx">trim</span><span class="p">().</span><span class="nx">split</span> <span class="sr">/\n{2,}/g</span>
-    <span class="nv">grafsOut = </span><span class="p">[]</span></pre></div>             </td>           </tr>                               <tr id="section-45">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-45">&#182;</a>               </div>               <p>Wrap <code>&lt;p&gt;</code> tags.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="k">for</span> <span class="nx">str</span> <span class="k">in</span> <span class="nx">grafs</span>
+    <span class="nv">grafsOut = </span><span class="p">[]</span></pre></div>             </td>           </tr>                               <tr id="section-47">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-47">&#182;</a>               </div>               <p>Wrap <code>&lt;p&gt;</code> tags.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="k">for</span> <span class="nx">str</span> <span class="k">in</span> <span class="nx">grafs</span>
       <span class="k">if</span> <span class="sr">/~K\d+K/g</span><span class="p">.</span><span class="nx">test</span> <span class="nx">str</span> <span class="c1"># if this is an HTML marker, copy it</span>
         <span class="nx">grafsOut</span><span class="p">.</span><span class="nx">push</span> <span class="nx">str</span>
       <span class="k">else</span> <span class="k">if</span> <span class="sr">/\S/</span><span class="p">.</span><span class="nx">test</span> <span class="nx">str</span>
             <span class="p">.</span><span class="nx">runSpanGamut</span><span class="p">()</span>
             <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/^([ \t]*)/g</span><span class="p">,</span> <span class="s1">&#39;&lt;p&gt;&#39;</span><span class="p">)</span>
             <span class="p">.</span><span class="nx">after</span><span class="p">(</span><span class="s1">&#39;&lt;/p&gt;&#39;</span><span class="p">)</span>
-        <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-46">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-46">&#182;</a>               </div>               <p>Unhashify HTML blocks.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="k">for</span> <span class="nx">value</span><span class="p">,</span> <span class="nx">index</span> <span class="k">in</span> <span class="nx">grafsOut</span></pre></div>             </td>           </tr>                               <tr id="section-47">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-47">&#182;</a>               </div>               <p>If this is a marker for an html block...</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="k">while</span> <span class="sr">/~K(\d+)K/</span><span class="p">.</span><span class="nx">test</span> <span class="nx">grafsOut</span><span class="p">[</span><span class="nx">index</span><span class="p">]</span>
+        <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-48">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-48">&#182;</a>               </div>               <p>Unhashify HTML blocks.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="k">for</span> <span class="nx">value</span><span class="p">,</span> <span class="nx">index</span> <span class="k">in</span> <span class="nx">grafsOut</span></pre></div>             </td>           </tr>                               <tr id="section-49">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-49">&#182;</a>               </div>               <p>If this is a marker for an html block...</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="k">while</span> <span class="sr">/~K(\d+)K/</span><span class="p">.</span><span class="nx">test</span> <span class="nx">grafsOut</span><span class="p">[</span><span class="nx">index</span><span class="p">]</span>
         <span class="nx">grafsOut</span><span class="p">[</span><span class="nx">index</span><span class="p">]</span> <span class="o">=</span>
           <span class="nx">grafsOut</span><span class="p">[</span><span class="nx">index</span><span class="p">].</span><span class="nx">replace</span><span class="p">(</span>
             <span class="sr">/~K\d+K/</span><span class="p">,</span>
             <span class="nx">blocks</span><span class="p">[</span><span class="nb">RegExp</span><span class="p">.</span><span class="nx">$1</span><span class="p">].</span><span class="nx">replace</span> <span class="sr">/\$/g</span><span class="p">,</span> <span class="s1">&#39;$$$$&#39;</span>
           <span class="p">)</span>
 
-    <span class="nx">@set</span> <span class="nx">grafsOut</span><span class="p">.</span><span class="nx">join</span> <span class="s1">&#39;\n\n&#39;</span></pre></div>             </td>           </tr>                               <tr id="section-48">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-48">&#182;</a>               </div>               <p>Smart processing for ampersands and angle brackets that must be encoded.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">encodeAmpsAndAngles: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-49">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-49">&#182;</a>               </div>               <p>Ampersand-encoding based entirely on Nat Irons's
-<a href="http://bumppo.net/projects/amputator/">Amputator MT plugin</a>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span><span class="sr">/&amp;(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g</span><span class="p">,</span> <span class="s1">&#39;&amp;amp;&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-50">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-50">&#182;</a>               </div>               <p>Encode naked <code>&lt;</code>s.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/&lt;(?![a-z\/?\$!])/gi</span><span class="p">,</span> <span class="s1">&#39;&amp;lt;&#39;</span><span class="p">)</span>
+    <span class="nx">@set</span> <span class="nx">grafsOut</span><span class="p">.</span><span class="nx">join</span> <span class="s1">&#39;\n\n&#39;</span></pre></div>             </td>           </tr>                               <tr id="section-50">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-50">&#182;</a>               </div>               <p>Smart processing for ampersands and angle brackets that must be encoded.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">encodeAmpsAndAngles: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-51">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-51">&#182;</a>               </div>               <p>Ampersand-encoding based entirely on Nat Irons's
+<a href="http://bumppo.net/projects/amputator/">Amputator MT plugin</a>.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span><span class="sr">/&amp;(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g</span><span class="p">,</span> <span class="s1">&#39;&amp;amp;&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-52">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-52">&#182;</a>               </div>               <p>Encode naked <code>&lt;</code>s.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/&lt;(?![a-z\/?\$!])/gi</span><span class="p">,</span> <span class="s1">&#39;&amp;lt;&#39;</span><span class="p">)</span>
 
   <span class="nv">encodeBackslashEscapes: </span><span class="o">-&gt;</span>
     <span class="nx">@replace</span><span class="p">(</span><span class="sr">/\\(\\)/g</span><span class="p">,</span> <span class="nx">escapeCharacters_callback</span><span class="p">)</span>
     <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
       <span class="sr">/&lt;(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)&gt;/gi</span><span class="p">,</span>
       <span class="nf">(_, m1) -&gt;</span> <span class="nx">encodeEmailAddress</span> <span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">m1</span><span class="p">).</span><span class="nx">unescapeSpecialChars</span><span class="p">().</span><span class="nx">value</span>
-    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-51">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-51">&#182;</a>               </div>               <p>Swap back in all the special characters we've hidden.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">unescapeSpecialChars: </span><span class="o">-&gt;</span>
-    <span class="nx">@replace</span> <span class="sr">/~E(\d+)E/g</span><span class="p">,</span> <span class="nf">(_, m1) -&gt;</span> <span class="nb">String</span><span class="p">.</span><span class="nx">fromCharCode</span> <span class="nb">parseInt</span> <span class="nx">m1</span><span class="p">,</span> <span class="mi">10</span></pre></div>             </td>           </tr>                               <tr id="section-52">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-52">&#182;</a>               </div>               <p>Remove one level of line-leading tabs or spaces.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">outdent: </span><span class="o">-&gt;</span>
-    <span class="nx">@replace</span><span class="p">(</span><span class="sr">/^(\t|[ ]{1,4})/gm</span><span class="p">,</span> <span class="s1">&#39;~0&#39;</span><span class="p">).</span><span class="nx">trim</span> <span class="sr">/~0/g</span> <span class="c1"># attacklab: clean up hack</span></pre></div>             </td>           </tr>                               <tr id="section-53">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-53">&#182;</a>               </div>               <p><em>attacklab:</em> Completely rewritten for speed. In Perl we could fix it by
-anchoring the regexp with <code>\G</code>. In JavaScript we're less fortunate.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">detab: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-54">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-54">&#182;</a>               </div>               <p>Expand first n-1 tabs.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span><span class="sr">/\t(?=\t)/g</span><span class="p">,</span> <span class="s1">&#39;    &#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-55">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-55">&#182;</a>               </div>               <p>Replace the nth with two sentinels.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\t/g</span><span class="p">,</span> <span class="s1">&#39;~A~B&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-56">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-56">&#182;</a>               </div>               <p>Use the sentinel to anchor our regex so it doesn't explode.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
+    <span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-53">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-53">&#182;</a>               </div>               <p>Swap back in all the special characters we've hidden.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">unescapeSpecialChars: </span><span class="o">-&gt;</span>
+    <span class="nx">@replace</span> <span class="sr">/~E(\d+)E/g</span><span class="p">,</span> <span class="nf">(_, m1) -&gt;</span> <span class="nb">String</span><span class="p">.</span><span class="nx">fromCharCode</span> <span class="nb">parseInt</span> <span class="nx">m1</span><span class="p">,</span> <span class="mi">10</span></pre></div>             </td>           </tr>                               <tr id="section-54">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-54">&#182;</a>               </div>               <p>Remove one level of line-leading tabs or spaces.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">outdent: </span><span class="o">-&gt;</span>
+    <span class="nx">@replace</span><span class="p">(</span><span class="sr">/^(\t|[ ]{1,4})/gm</span><span class="p">,</span> <span class="s1">&#39;~0&#39;</span><span class="p">).</span><span class="nx">trim</span> <span class="sr">/~0/g</span> <span class="c1"># attacklab: clean up hack</span></pre></div>             </td>           </tr>                               <tr id="section-55">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-55">&#182;</a>               </div>               <p><em>attacklab:</em> Completely rewritten for speed. In Perl we could fix it by
+anchoring the regexp with <code>\G</code>. In JavaScript we're less fortunate.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">detab: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-56">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-56">&#182;</a>               </div>               <p>Expand first n-1 tabs.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span><span class="sr">/\t(?=\t)/g</span><span class="p">,</span> <span class="s1">&#39;    &#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-57">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-57">&#182;</a>               </div>               <p>Replace the nth with two sentinels.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\t/g</span><span class="p">,</span> <span class="s1">&#39;~A~B&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-58">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-58">&#182;</a>               </div>               <p>Use the sentinel to anchor our regex so it doesn't explode.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
       <span class="sr">/~B(.+?)~A/g</span><span class="p">,</span>
       <span class="nf">(_, leadingText) -&gt;</span>
         <span class="nv">numSpaces = </span><span class="mi">4</span> <span class="o">-</span> <span class="nx">leadingText</span><span class="p">.</span><span class="nx">length</span> <span class="o">%</span> <span class="mi">4</span>
     <span class="p">)</span>
     <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/~A/g</span><span class="p">,</span> <span class="s1">&#39;    &#39;</span><span class="p">).</span><span class="nx">trim</span> <span class="sr">/~B/g</span> <span class="c1"># clean up sentinels</span>
 
-  <span class="nv">escapeCharacters: </span><span class="nf">(charsToEscape) -&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-57">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-57">&#182;</a>               </div>               <p>First we have to escape the escape characters so that we can build a
+  <span class="nv">escapeCharacters: </span><span class="nf">(charsToEscape) -&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-59">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-59">&#182;</a>               </div>               <p>First we have to escape the escape characters so that we can build a
 character class out of them.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span><span class="p">(</span>
-      <span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="s2">&quot;([#{ charsToEscape.replace /[[\\\]]/g, &#39;\\$&amp;&#39; }])&quot;</span><span class="p">,</span> <span class="s1">&#39;g&#39;</span><span class="p">),</span>
+      <span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="s2">&quot;([#{charsToEscape.replace /[[\\\]]/g, &#39;\\$&amp;&#39;}])&quot;</span><span class="p">,</span> <span class="s1">&#39;g&#39;</span><span class="p">),</span>
       <span class="nx">escapeCharacters_callback</span>
     <span class="p">)</span>
 
 <span class="nv">hashElement = </span><span class="nf">(_, blockText) -&gt;</span>
-  <span class="nv">blockText = </span><span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">blockText</span><span class="p">).</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\n\n/g</span><span class="p">,</span> <span class="s1">&#39;\n&#39;</span><span class="p">).</span><span class="nx">trim</span> <span class="sr">/^\n|\n+$/g</span></pre></div>             </td>           </tr>                               <tr id="section-58">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-58">&#182;</a>               </div>               <p>Replace the element text with a marker (<code>~KxK</code> where <code>x</code> is its key).</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="s2">&quot;\n\n~K#{ blocks.push(blockText) - 1 }K\n\n&quot;</span>
+  <span class="nv">blockText = </span><span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">blockText</span><span class="p">).</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\n\n/g</span><span class="p">,</span> <span class="s1">&#39;\n&#39;</span><span class="p">).</span><span class="nx">trim</span> <span class="sr">/^\n|\n+$/g</span></pre></div>             </td>           </tr>                               <tr id="section-60">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-60">&#182;</a>               </div>               <p>Replace the element text with a marker (<code>~KxK</code> where <code>x</code> is its key).</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="s2">&quot;\n\n~K#{blocks.push(blockText) - 1}K\n\n&quot;</span>
 
 <span class="nv">writeAnchorTag = </span><span class="nf">(match, link_text, link_id, url, m5, m6, title) -&gt;</span>
   <span class="nv">link_id = </span><span class="nx">link_id</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">()</span>
 
-  <span class="k">if</span> <span class="o">not</span> <span class="nx">url</span></pre></div>             </td>           </tr>                               <tr id="section-59">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-59">&#182;</a>               </div>               <p>Lower-case and turn embedded newlines into spaces.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">link_id</span> <span class="o">or=</span> <span class="nx">link_text</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">().</span><span class="nx">trim</span> <span class="sr">/[ ]?\n/g</span>
+  <span class="k">if</span> <span class="o">not</span> <span class="nx">url</span></pre></div>             </td>           </tr>                               <tr id="section-61">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-61">&#182;</a>               </div>               <p>Lower-case and turn embedded newlines into spaces.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">link_id</span> <span class="o">or=</span> <span class="nx">link_text</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">().</span><span class="nx">trim</span> <span class="sr">/[ ]?\n/g</span>
     <span class="nv">url = </span><span class="s1">&#39;#&#39;</span> <span class="o">+</span> <span class="nx">link_id</span>
 
     <span class="k">if</span> <span class="nx">urls</span><span class="p">[</span><span class="nx">link_id</span><span class="p">]</span> <span class="o">is</span> <span class="kc">undefined</span>
-      <span class="k">if</span> <span class="sr">/\(\s*\)$/m</span><span class="p">.</span><span class="nx">test</span> <span class="nx">match</span></pre></div>             </td>           </tr>                               <tr id="section-60">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-60">&#182;</a>               </div>               <p>Special case for explicit empty url.</p>             </td>             <td class="code">               <div class="highlight"><pre>        <span class="nv">url = </span><span class="s1">&#39;&#39;</span>
+      <span class="k">if</span> <span class="sr">/\(\s*\)$/m</span><span class="p">.</span><span class="nx">test</span> <span class="nx">match</span></pre></div>             </td>           </tr>                               <tr id="section-62">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-62">&#182;</a>               </div>               <p>Special case for explicit empty url.</p>             </td>             <td class="code">               <div class="highlight"><pre>        <span class="nv">url = </span><span class="s1">&#39;&#39;</span>
       <span class="k">else</span>
         <span class="k">return</span> <span class="nx">match</span>
     <span class="k">else</span>
   <span class="nv">link_id = </span><span class="nx">link_id</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">()</span>
 
   <span class="k">if</span> <span class="nx">url</span> <span class="o">is</span> <span class="s1">&#39;&#39;</span>
-    <span class="k">if</span> <span class="nx">link_id</span> <span class="o">is</span> <span class="s1">&#39;&#39;</span></pre></div>             </td>           </tr>                               <tr id="section-61">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-61">&#182;</a>               </div>               <p>Lower-case and turn embedded newlines into spaces.</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="nv">link_id = </span><span class="nx">alt_text</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">().</span><span class="nx">replace</span> <span class="sr">/[ ]?\n/g</span><span class="p">,</span> <span class="s1">&#39; &#39;</span>
+    <span class="k">if</span> <span class="nx">link_id</span> <span class="o">is</span> <span class="s1">&#39;&#39;</span></pre></div>             </td>           </tr>                               <tr id="section-63">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-63">&#182;</a>               </div>               <p>Lower-case and turn embedded newlines into spaces.</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="nv">link_id = </span><span class="nx">alt_text</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">().</span><span class="nx">replace</span> <span class="sr">/[ ]?\n/g</span><span class="p">,</span> <span class="s1">&#39; &#39;</span>
 
     <span class="nv">url = </span><span class="s1">&#39;#&#39;</span> <span class="o">+</span> <span class="nx">link_id</span>
 
     <span class="p">.</span><span class="nx">cond</span><span class="p">(</span><span class="nx">title</span><span class="p">,</span> <span class="o">-&gt;</span>
       <span class="nx">@after</span><span class="p">(</span><span class="s1">&#39; title=&quot;&#39;</span> <span class="o">+</span> <span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">title</span><span class="p">).</span><span class="nx">quot</span><span class="p">().</span><span class="nx">escapeCharacters</span><span class="p">(</span><span class="s1">&#39;*_&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;&quot;&#39;</span><span class="p">)</span>
     <span class="p">)</span>
-    <span class="p">.</span><span class="nx">after</span><span class="p">(</span><span class="s1">&#39; /&gt;&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-62">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-62">&#182;</a>               </div>               <p>Process the contents of a single ordered or unordered list, splitting it
-into individual list items.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">processListItems = </span><span class="nf">(list_str) -&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-63">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-63">&#182;</a>               </div>               <p><code>level</code> keeps track of when we're inside a list. Each time we enter a
+    <span class="p">.</span><span class="nx">after</span><span class="p">(</span><span class="s1">&#39; /&gt;&#39;</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-64">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-64">&#182;</a>               </div>               <p>Process the contents of a single ordered or unordered list, splitting it
+into individual list items.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">processListItems = </span><span class="nf">(list_str) -&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-65">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-65">&#182;</a>               </div>               <p><code>level</code> keeps track of when we're inside a list. Each time we enter a
 list, we increment it; when we leave a list, we decrement. If it's zero,
 we're not in a list anymore.</p>
 
 
 <p>Whereas when we're inside a list (or sub-list), that line will be
 treated as the start of a sub-list.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nx">level</span><span class="o">++</span>
-  <span class="nv">list_str = </span><span class="s2">&quot;#{ list_str.replace /\n{2,}$/, &#39;\n&#39; }~0&quot;</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
+  <span class="nv">list_str = </span><span class="s2">&quot;#{list_str.replace /\n{2,}$/, &#39;\n&#39;}~0&quot;</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span>
     <span class="err">///</span>
       <span class="p">(</span><span class="err">\</span><span class="nx">n</span><span class="p">)</span><span class="o">?</span>
       <span class="p">(</span><span class="o">^</span><span class="p">[</span><span class="err">\</span><span class="nx">x20</span><span class="err">\</span><span class="nx">t</span><span class="p">]</span><span class="o">*</span><span class="p">)</span>
         <span class="p">.</span><span class="nx">after</span><span class="p">(</span><span class="s1">&#39;&lt;/li&gt;\n&#39;</span><span class="p">)</span>
   <span class="p">)</span>
   <span class="nx">level</span><span class="o">--</span>
-  <span class="nx">list_str</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/~0/g</span><span class="p">,</span> <span class="s1">&#39;&#39;</span> <span class="c1"># attacklab: strip sentinel</span></pre></div>             </td>           </tr>                               <tr id="section-64">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-64">&#182;</a>               </div>               <p><em>attacklab:</em> Why can't JavaScript speak hex?</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">char2hex = </span><span class="nf">(ch) -&gt;</span>
-  <span class="nv">dec = </span><span class="nx">ch</span><span class="p">.</span><span class="nx">charCodeAt</span> <span class="mi">0</span>
+  <span class="nx">list_str</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/~0/g</span><span class="p">,</span> <span class="s1">&#39;&#39;</span> <span class="c1"># attacklab: strip sentinel</span></pre></div>             </td>           </tr>                               <tr id="section-66">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-66">&#182;</a>               </div>               <p><em>attacklab:</em> Why can't JavaScript speak hex?</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">char2hex = </span><span class="nf">(chr) -&gt;</span>
+  <span class="nv">dec = </span><span class="nx">chr</span><span class="p">.</span><span class="nx">charCodeAt</span> <span class="mi">0</span>
   <span class="nv">hexDigits = </span><span class="s1">&#39;0123456789ABCDEF&#39;</span>
-  <span class="nx">hexDigits</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="nx">dec</span> <span class="o">&gt;&gt;</span> <span class="mi">4</span><span class="p">)</span> <span class="o">+</span> <span class="nx">hexDigits</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="nx">dec</span> <span class="o">&amp;</span> <span class="mi">15</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-65">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-65">&#182;</a>               </div>               <p>Each character of the address is encoded as either a decimal or hex entity,
+  <span class="nx">hexDigits</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="nx">dec</span> <span class="o">&gt;&gt;</span> <span class="mi">4</span><span class="p">)</span> <span class="o">+</span> <span class="nx">hexDigits</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="nx">dec</span> <span class="o">&amp;</span> <span class="mi">15</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-67">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-67">&#182;</a>               </div>               <p>Each character of the address is encoded as either a decimal or hex entity,
 in the hopes of foiling most address harvesting spam bots.</p>
 
 <p>For example:</p>
 <p>Based on a filter by Matthew Wickline, posted to the BBEdit-Talk
 mailing list.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">encodeEmailAddress = </span><span class="nf">(addr) -&gt;</span>
   <span class="nv">encode = </span><span class="p">[</span>
-    <span class="nf">(ch) -&gt;</span> <span class="s2">&quot;&amp;##{ ch.charCodeAt 0 };&quot;</span>
-    <span class="nf">(ch) -&gt;</span> <span class="s2">&quot;&amp;#x#{ char2hex ch };&quot;</span>
+    <span class="nf">(chr) -&gt;</span> <span class="s2">&quot;&amp;##{chr.charCodeAt 0};&quot;</span>
+    <span class="nf">(chr) -&gt;</span> <span class="s2">&quot;&amp;#x#{char2hex chr};&quot;</span>
   <span class="p">]</span>
-  <span class="nv">addr = </span><span class="s2">&quot;mailto:#{ addr }&quot;</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/./g</span><span class="p">,</span> <span class="nf">(ch) -&gt;</span>
-    <span class="k">switch</span> <span class="nx">ch</span></pre></div>             </td>           </tr>                               <tr id="section-66">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-66">&#182;</a>               </div>               <p>Leave ":" alone (to spot <code>mailto:</code> later).</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="k">when</span> <span class="s1">&#39;:&#39;</span> <span class="k">then</span> <span class="nx">ch</span></pre></div>             </td>           </tr>                               <tr id="section-67">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-67">&#182;</a>               </div>               <p>This <em>must</em> be encoded. I insist.</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="k">when</span> <span class="s1">&#39;@&#39;</span> <span class="k">then</span> <span class="nx">encode</span><span class="p">[</span><span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span><span class="o">*</span><span class="mi">2</span><span class="p">]</span> <span class="nx">ch</span></pre></div>             </td>           </tr>                               <tr id="section-68">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-68">&#182;</a>               </div>               <p>Roughly 10% raw, 45% dec, 45% hex.</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="k">else</span>
+  <span class="nv">addr = </span><span class="s2">&quot;mailto:#{addr}&quot;</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/./g</span><span class="p">,</span> <span class="nf">(chr) -&gt;</span>
+    <span class="k">switch</span> <span class="nx">chr</span></pre></div>             </td>           </tr>                               <tr id="section-68">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-68">&#182;</a>               </div>               <p>Leave ":" alone (to spot <code>mailto:</code> later).</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="k">when</span> <span class="s1">&#39;:&#39;</span> <span class="k">then</span> <span class="nx">chr</span></pre></div>             </td>           </tr>                               <tr id="section-69">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-69">&#182;</a>               </div>               <p>This <em>must</em> be encoded. I insist.</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="k">when</span> <span class="s1">&#39;@&#39;</span> <span class="k">then</span> <span class="nx">encode</span><span class="p">[</span><span class="o">+</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span> <span class="o">&gt;</span> <span class="mf">0.5</span><span class="p">)]</span> <span class="nx">chr</span></pre></div>             </td>           </tr>                               <tr id="section-70">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-70">&#182;</a>               </div>               <p>Roughly 10% raw, 45% dec, 45% hex.</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="k">else</span>
         <span class="nv">r = </span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span>
-        <span class="k">if</span> <span class="nx">r</span> <span class="o">&gt;</span> <span class="mf">0.9</span> <span class="k">then</span> <span class="nx">ch</span> <span class="k">else</span> <span class="k">if</span> <span class="nx">r</span> <span class="o">&gt;</span> <span class="mf">0.45</span> <span class="k">then</span> <span class="nx">encode</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="nx">ch</span> <span class="k">else</span> <span class="nx">encode</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="nx">ch</span>
+        <span class="k">if</span> <span class="nx">r</span> <span class="o">&gt;</span> <span class="mf">0.9</span> <span class="k">then</span> <span class="nx">chr</span> <span class="k">else</span> <span class="nx">encode</span><span class="p">[</span><span class="o">+</span><span class="p">(</span><span class="nx">r</span> <span class="o">&gt;</span> <span class="mf">0.45</span><span class="p">)]</span> <span class="nx">chr</span>
   <span class="p">)</span>
-  <span class="s2">&quot;&lt;a href=\&quot;#{ addr }\&quot;&gt;#{ addr.replace /.+:/, &#39;&#39; }&lt;/a&gt;&quot;</span>
+  <span class="s2">&quot;&lt;a href=\&quot;#{addr}\&quot;&gt;#{addr.replace /.+:/, &#39;&#39;}&lt;/a&gt;&quot;</span>
 
-<span class="nv">escapeCharacters_callback = </span><span class="nf">(_, m1) -&gt;</span>
-  <span class="s2">&quot;~E#{ m1.charCodeAt 0 }E&quot;</span>
+<span class="nv">escapeCharacters_callback = </span><span class="nf">(_, chr) -&gt;</span>
+  <span class="s2">&quot;~E#{chr.charCodeAt 0}E&quot;</span>
 
 </pre></div>             </td>           </tr>                </tbody>     </table>   </div> </body> </html>