Commits

David Chambers committed bde64be

Updated Showdown's annotated source.

Comments (0)

Files changed (4)

showdown/abbreviations/index.html

+<!DOCTYPE html>  <html> <head>   <title>abbreviations.coffee</title>   <meta http-equiv="content-type" content="text/html; charset=UTF-8">   <link rel="stylesheet" media="all" href="docco.css" /> </head> <body>   <div id="container">     <div id="background"></div>            <div id="jump_to">         Jump To &hellip;         <div id="jump_wrapper">           <div id="jump_page">                                           <a class="source" href="abbreviations.html">                 abbreviations.coffee               </a>                                           <a class="source" href="datetimes.html">                 datetimes.coffee               </a>                                           <a class="source" href="showdown.html">                 showdown.coffee               </a>                        </div>         </div>       </div>          <table cellpadding="0" cellspacing="0">       <thead>         <tr>           <th class="docs">             <h1>               abbreviations.coffee             </h1>           </th>           <th class="code">           </th>         </tr>       </thead>       <tbody>                               <tr id="section-1">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-1">&#182;</a>               </div>                            </td>             <td class="code">               <div class="highlight"><pre><span class="nv">re = </span><span class="err">///</span>
+  <span class="err">\</span><span class="nx">n</span><span class="o">?</span>           <span class="c1"># optional line break</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="c1"># up to three spaces at the beginning of a line</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="c1"># abbreviation, between &quot;*[&quot; and &quot;]&quot;</span>
+  <span class="err">\</span><span class="nx">x20</span><span class="o">?:</span><span class="err">\</span><span class="nx">x20</span><span class="o">?</span>   <span class="c1"># colon (preceding space and following space both optional)</span>
+  <span class="p">(.</span><span class="o">*?</span><span class="p">)</span>         <span class="c1"># full word or phrase being abbreviated</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="nx">$</span>   <span class="c1"># any number of spaces and/or tabs</span>
+<span class="err">///gm</span>
+
+<span class="nv">Showdown = </span><span class="p">(</span><span class="nx">exports</span> <span class="o">?</span> <span class="k">this</span><span class="p">).</span><span class="nx">Showdown</span>
+
+<span class="nv">Text = </span><span class="nx">Showdown</span><span class="p">.</span><span class="nx">Text</span><span class="p">()</span>
+
+<span class="nv">safe = </span><span class="nf">(text) -&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="nx">encodeAmpsAndAngles</span><span class="p">()</span>
+
+<span class="nv">wrap = </span><span class="nf">(abbr, full) -&gt;</span>
+  <span class="k">if</span> <span class="nx">full</span>
+    <span class="nv">full = </span><span class="nx">safe</span><span class="p">(</span><span class="nx">full</span><span class="p">).</span><span class="nx">quot</span><span class="p">().</span><span class="nx">replace</span> <span class="sr">/&gt;/g</span><span class="p">,</span> <span class="s1">&#39;&amp;gt;&#39;</span>
+    <span class="s2">&quot;&lt;abbr title=\&quot;#{full}\&quot;&gt;#{safe abbr}&lt;/abbr&gt;&quot;</span>
+  <span class="k">else</span>
+    <span class="s2">&quot;&lt;abbr&gt;#{safe abbr}&lt;/abbr&gt;&quot;</span>
+
+<span class="nv">stripAbbrDefs = </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-2">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-2">&#182;</a>               </div>               <p>While a hash is the logical structure in which to store data of this
+nature, order must be preserved as it may be significant.</p>
+
+<p>Consider the case in which both "HTML" and "HTML 4" are declared to
+be abbreviations. To ensure that occurrences of "HTML 4" are always
+replaced with <code>&lt;abbr&gt;HTML 4&lt;/abbr&gt;</code> rather than <code>&lt;abbr&gt;HTML&lt;/abbr&gt; 4</code>,
+we sort abbreviations by length. We must preserve declaration order
+<em>within</em> each bucket in order to -- for example -- correctly convert
+"1st Lt Gen" in a document which declares both "1st Lt" and "Lt Gen"
+to be abbreviations.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">buckets = </span><span class="p">[]</span>
+  <span class="nv">abbrsHash = </span><span class="p">{}</span>
+  <span class="nx">@replace</span> <span class="nx">re</span><span class="p">,</span> <span class="nf">(_, abbr, full) -&gt;</span>
+    <span class="k">if</span> <span class="nx">abbr</span> <span class="o">not</span> <span class="k">of</span> <span class="nx">abbrsHash</span>
+      <span class="p">(</span><span class="nx">buckets</span><span class="p">[</span><span class="nx">abbr</span><span class="p">.</span><span class="nx">length</span><span class="p">]</span> <span class="o">or=</span> <span class="p">[]).</span><span class="nx">push</span> <span class="nx">abbr</span>
+      <span class="nx">abbrsHash</span><span class="p">[</span><span class="nx">abbr</span><span class="p">]</span> <span class="o">=</span> <span class="nx">full</span>
+    <span class="s1">&#39;&#39;</span> <span class="c1"># strip the line</span>
+
+  <span class="nv">abbrsList = </span><span class="p">[]</span>
+  <span class="nv">abbrsList = </span><span class="nx">bucket</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">abbrsList</span> <span class="k">for</span> <span class="nx">bucket</span> <span class="k">in</span> <span class="nx">buckets</span> <span class="k">when</span> <span class="nx">bucket</span>
+
+  <span class="p">[</span><span class="nx">abbrsList</span><span class="p">,</span> <span class="nx">abbrsHash</span><span class="p">]</span>
+
+<span class="nv">wrapAbbrs = </span><span class="nf">([abbrsList, abbrsHash]) -&gt;</span>
+  <span class="k">for</span> <span class="nx">abbr</span> <span class="k">in</span> <span class="nx">abbrsList</span>
+    <span class="nv">full = </span><span class="nx">abbrsHash</span><span class="p">[</span><span class="nx">abbr</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>Look for abbreviations between a ">" (or the start of the string) and
+a "&lt;" (or the end of the string), ensuring that we haven't <em>already</em>
+wrapped this text (so as to avoid <code>&lt;abbr&gt;&lt;abbr&gt;HTML&lt;/abbr&gt; 4&lt;/abbr&gt;</code>).</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@replace</span> <span class="sr">/[^&lt;&gt;]+(?=&lt;(?!\/abbr&gt;)|$)/g</span><span class="p">,</span> <span class="nf">(head) -&gt;</span>
+      <span class="nv">tail = </span><span class="s1">&#39;&#39;</span>
+      <span class="k">while</span> <span class="o">~</span> <span class="nv">index = </span><span class="nx">head</span><span class="p">.</span><span class="nx">lastIndexOf</span> <span class="nx">abbr</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>Copy the portion of <code>head</code> from the beginning of the last match
+to the end of the string.</p>             </td>             <td class="code">               <div class="highlight"><pre>        <span class="nv">substr = </span><span class="nx">head</span><span class="p">.</span><span class="nx">substr</span> <span class="nx">index</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>Wrap the abbreviation if it is bookended by word boundaries.</p>             </td>             <td class="code">               <div class="highlight"><pre>        <span class="k">if</span> <span class="o">not</span> <span class="sr">/\w/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">head</span><span class="p">.</span><span class="nx">charAt</span> <span class="nx">index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">and</span>
+           <span class="o">not</span> <span class="sr">/\w/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">head</span><span class="p">.</span><span class="nx">charAt</span> <span class="nx">index</span> <span class="o">+</span> <span class="nx">abbr</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span>
+          <span class="nv">substr = </span><span class="nx">substr</span><span class="p">.</span><span class="nx">replace</span> <span class="nx">abbr</span><span class="p">,</span> <span class="nx">wrap</span> <span class="nx">abbr</span><span class="p">,</span> <span class="nx">full</span>
+        <span class="nv">tail = </span><span class="nx">substr</span> <span class="o">+</span> <span class="nx">tail</span>
+        <span class="nv">head = </span><span class="nx">head</span><span class="p">.</span><span class="nx">substr</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">index</span>
+      <span class="nx">head</span> <span class="o">+</span> <span class="nx">tail</span>
+  <span class="k">return</span>
+
+<span class="nx">Showdown</span><span class="p">.</span><span class="nx">register</span> <span class="s1">&#39;abbreviations&#39;</span><span class="p">,</span> <span class="nx">stripAbbrDefs</span><span class="p">,</span> <span class="nx">wrapAbbrs</span>
+
+</pre></div>             </td>           </tr>                </tbody>     </table>   </div> </body> </html> 

showdown/datetimes/index.html

+<!DOCTYPE html>  <html> <head>   <title>datetimes.coffee</title>   <meta http-equiv="content-type" content="text/html; charset=UTF-8">   <link rel="stylesheet" media="all" href="docco.css" /> </head> <body>   <div id="container">     <div id="background"></div>            <div id="jump_to">         Jump To &hellip;         <div id="jump_wrapper">           <div id="jump_page">                                           <a class="source" href="abbreviations.html">                 abbreviations.coffee               </a>                                           <a class="source" href="datetimes.html">                 datetimes.coffee               </a>                                           <a class="source" href="showdown.html">                 showdown.coffee               </a>                        </div>         </div>       </div>          <table cellpadding="0" cellspacing="0">       <thead>         <tr>           <th class="docs">             <h1>               datetimes.coffee             </h1>           </th>           <th class="code">           </th>         </tr>       </thead>       <tbody>                               <tr id="section-1">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-1">&#182;</a>               </div>                            </td>             <td class="code">               <div class="highlight"><pre><span class="nv">re = </span><span class="err">///</span>
+  <span class="err">\</span><span class="nx">n</span><span class="o">?</span>           <span class="c1"># optional line break</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="c1"># up to three spaces at the beginning of a line</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="c1"># [1] date and/or time text, between &quot;*[&quot; and &quot;]&quot;</span>
+  <span class="err">\</span><span class="nx">x20</span><span class="o">?:</span><span class="err">\</span><span class="nx">x20</span><span class="o">?</span>   <span class="c1"># colon (preceding space and following space both optional)</span>
+
+  <span class="p">(</span>                             <span class="c1"># [2] date</span>
+    <span class="err">\</span><span class="nx">d</span><span class="p">{</span><span class="mi">4</span><span class="p">}</span>                       <span class="c1"># year</span>
+  <span class="o">-</span> <span class="p">(</span><span class="o">?:</span><span class="mi">0</span><span class="p">[</span><span class="mi">1</span><span class="o">-</span><span class="mi">9</span><span class="p">]</span><span class="o">|</span><span class="mi">1</span><span class="p">[</span><span class="mi">012</span><span class="p">])</span>           <span class="c1"># month</span>
+  <span class="o">-</span> <span class="p">(</span><span class="o">?:</span><span class="mi">0</span><span class="p">[</span><span class="mi">1</span><span class="o">-</span><span class="mi">9</span><span class="p">]</span><span class="o">|</span><span class="p">[</span><span class="mi">12</span><span class="p">]</span><span class="err">\</span><span class="nx">d</span><span class="o">|</span><span class="mi">3</span><span class="p">[</span><span class="mi">01</span><span class="p">])</span>     <span class="c1"># date</span>
+  <span class="p">)</span>
+  <span class="p">(</span><span class="o">?:</span>                           <span class="c1"># time and time zone offset?</span>
+    <span class="err">\</span><span class="nx">x20</span>
+    <span class="p">(</span>                           <span class="c1"># [3] time</span>
+      <span class="p">(</span><span class="o">?:</span><span class="p">[</span><span class="mi">01</span><span class="p">]</span><span class="err">\</span><span class="nx">d</span><span class="o">|</span><span class="mi">2</span><span class="p">[</span><span class="mi">0</span><span class="o">-</span><span class="mi">3</span><span class="p">])</span><span class="o">:</span><span class="p">[</span><span class="mi">0</span><span class="o">-</span><span class="mi">5</span><span class="p">]</span><span class="err">\</span><span class="nx">d</span> <span class="c1"># hours:minutes</span>
+      <span class="p">(</span><span class="o">?::</span><span class="p">[</span><span class="mi">0</span><span class="o">-</span><span class="mi">5</span><span class="p">]</span><span class="err">\</span><span class="nx">d</span><span class="p">(</span><span class="o">?:</span><span class="err">\</span><span class="p">.</span><span class="err">\</span><span class="nx">d</span><span class="o">+</span><span class="p">)</span><span class="o">?</span><span class="p">)</span><span class="o">?</span>   <span class="c1"># seconds?</span>
+    <span class="p">)</span>
+    <span class="err">\</span><span class="nx">x20</span>
+    <span class="p">(</span><span class="o">?:</span>                         <span class="c1"># time zone offset</span>
+      <span class="p">(</span><span class="nx">GMT</span><span class="o">|</span><span class="nx">UTC</span><span class="p">)</span>                 <span class="c1"># [4] UTC</span>
+    <span class="o">|</span> <span class="p">([</span><span class="o">+-</span><span class="p">])</span>                    <span class="c1"># [5] sign</span>
+      <span class="p">((</span><span class="o">?:</span><span class="mi">0</span><span class="o">|</span><span class="mi">1</span><span class="p">)</span><span class="o">?</span><span class="err">\</span><span class="nx">d</span><span class="o">|</span><span class="mi">2</span><span class="p">[</span><span class="mi">0</span><span class="o">-</span><span class="mi">3</span><span class="p">])</span>       <span class="c1"># [6] hours</span>
+      <span class="p">(</span><span class="o">?::</span><span class="p">([</span><span class="mi">0</span><span class="o">-</span><span class="mi">5</span><span class="p">]</span><span class="err">\</span><span class="nx">d</span><span class="p">))</span><span class="o">?</span>           <span class="c1"># [7] minutes?</span>
+    <span class="p">)</span>
+  <span class="p">)</span><span class="o">?</span>
+  <span class="p">(</span><span class="err">\</span><span class="nx">x20pubdate</span><span class="p">)</span><span class="o">?</span>                <span class="c1"># [8] pubdate?</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="nx">$</span>
+<span class="err">///gm</span>
+
+<span class="nv">Showdown = </span><span class="p">(</span><span class="nx">exports</span> <span class="o">?</span> <span class="k">this</span><span class="p">).</span><span class="nx">Showdown</span>
+
+<span class="nv">Text = </span><span class="nx">Showdown</span><span class="p">.</span><span class="nx">Text</span><span class="p">()</span>
+
+<span class="nv">wrap = </span><span class="nf">(text, datetime, pubdate) -&gt;</span>
+  <span class="nv">output = </span><span class="s2">&quot;&lt;time datetime=\&quot;#{datetime}&quot;</span>
+  <span class="nx">output</span> <span class="o">+=</span> <span class="s1">&#39;&quot; pubdate=&quot;pubdate&#39;</span> <span class="k">if</span> <span class="nx">pubdate</span>
+  <span class="nx">output</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;#{new Text(text).encodeAmpsAndAngles()}&lt;/time&gt;&quot;</span>
+
+<span class="nv">stripTimeDefs = </span><span class="o">-&gt;</span>
+  <span class="nv">buckets = </span><span class="p">[]</span>
+  <span class="nv">timesHash = </span><span class="p">{}</span>
+  <span class="nx">@replace</span> <span class="nx">re</span><span class="p">,</span> <span class="nf">(_, text, date, time, utc, sign, hours, minutes, pubdate) -&gt;</span>
+    <span class="k">if</span> <span class="nx">text</span> <span class="o">not</span> <span class="k">of</span> <span class="nx">timesHash</span>
+      <span class="p">(</span><span class="nx">buckets</span><span class="p">[</span><span class="nx">text</span><span class="p">.</span><span class="nx">length</span><span class="p">]</span> <span class="o">or=</span> <span class="p">[]).</span><span class="nx">push</span> <span class="nx">text</span>
+      <span class="nv">datetime = </span><span class="nx">date</span>
+      <span class="k">if</span> <span class="nx">utc</span>
+        <span class="nv">sign = </span><span class="s1">&#39;+&#39;</span>
+        <span class="nv">hours = </span><span class="s1">&#39;00&#39;</span>
+      <span class="k">if</span> <span class="nx">sign</span>
+        <span class="nv">hours = </span><span class="s2">&quot;0#{hours}&quot;</span> <span class="k">if</span> <span class="nx">hours</span><span class="p">.</span><span class="nx">length</span> <span class="o">is</span> <span class="mi">1</span>
+        <span class="nx">datetime</span> <span class="o">+=</span> <span class="s2">&quot;T#{time}#{sign}#{hours}:#{minutes||&#39;00&#39;}&quot;</span>
+      <span class="nx">timesHash</span><span class="p">[</span><span class="nx">text</span><span class="p">]</span> <span class="o">=</span> <span class="nx">wrap</span> <span class="nx">text</span><span class="p">,</span> <span class="nx">datetime</span><span class="p">,</span> <span class="nx">pubdate</span>
+    <span class="s1">&#39;&#39;</span> <span class="c1"># strip the line</span>
+
+  <span class="nv">timesList = </span><span class="p">[]</span>
+  <span class="nv">timesList = </span><span class="nx">bucket</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">timesList</span> <span class="k">for</span> <span class="nx">bucket</span> <span class="k">in</span> <span class="nx">buckets</span> <span class="k">when</span> <span class="nx">bucket</span>
+
+  <span class="p">[</span><span class="nx">timesList</span><span class="p">,</span> <span class="nx">timesHash</span><span class="p">]</span>
+
+<span class="nv">wrapTimes = </span><span class="nf">([timesList, timesHash]) -&gt;</span>
+  <span class="k">for</span> <span class="nx">text</span> <span class="k">in</span> <span class="nx">timesList</span>
+    <span class="nx">@replace</span> <span class="sr">/[^&lt;&gt;]+(?=&lt;(?!\/time&gt;)|$)/g</span><span class="p">,</span> <span class="nf">(head) -&gt;</span>
+      <span class="nv">tail = </span><span class="s1">&#39;&#39;</span>
+      <span class="k">while</span> <span class="o">~</span> <span class="nv">index = </span><span class="nx">head</span><span class="p">.</span><span class="nx">lastIndexOf</span> <span class="nx">text</span></pre></div>             </td>           </tr>                               <tr id="section-2">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-2">&#182;</a>               </div>               <p>Copy the portion of <code>head</code> from the beginning of the last match
+to the end of the string.</p>             </td>             <td class="code">               <div class="highlight"><pre>        <span class="nv">substr = </span><span class="nx">head</span><span class="p">.</span><span class="nx">substr</span> <span class="nx">index</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>Wrap the text if it is bookended by word boundaries.</p>             </td>             <td class="code">               <div class="highlight"><pre>        <span class="k">if</span> <span class="o">not</span> <span class="sr">/\w/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">head</span><span class="p">.</span><span class="nx">charAt</span> <span class="nx">index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">and</span>
+           <span class="o">not</span> <span class="sr">/\w/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">head</span><span class="p">.</span><span class="nx">charAt</span> <span class="nx">index</span> <span class="o">+</span> <span class="nx">text</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span>
+          <span class="nv">substr = </span><span class="nx">substr</span><span class="p">.</span><span class="nx">replace</span> <span class="nx">text</span><span class="p">,</span> <span class="nx">timesHash</span><span class="p">[</span><span class="nx">text</span><span class="p">]</span>
+        <span class="nv">tail = </span><span class="nx">substr</span> <span class="o">+</span> <span class="nx">tail</span>
+        <span class="nv">head = </span><span class="nx">head</span><span class="p">.</span><span class="nx">substr</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">index</span>
+      <span class="nx">head</span> <span class="o">+</span> <span class="nx">tail</span>
+  <span class="k">return</span>
+
+<span class="nx">Showdown</span><span class="p">.</span><span class="nx">register</span> <span class="s1">&#39;datetimes&#39;</span><span class="p">,</span> <span class="nx">stripTimeDefs</span><span class="p">,</span> <span class="nx">wrapTimes</span>
+
+</pre></div>             </td>           </tr>                </tbody>     </table>   </div> </body> </html> 
   }
     pre, tt, code {
       font-size: 12px; line-height: 18px;
-      font-family: Monaco, Consolas, "Lucida Console", monospace;
+      font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
       margin: 0; padding: 0;
     }
 
-<!DOCTYPE html>  <html> <head>   <title>showdown.coffee</title>   <meta http-equiv="content-type" content="text/html; charset=UTF-8">   <link rel="stylesheet" media="all" href="docco.css" /> </head> <body>   <div id="container">     <div id="background"></div>          <table cellpadding="0" cellspacing="0">       <thead>         <tr>           <th class="docs">             <h1>               showdown.coffee             </h1>           </th>           <th class="code">           </th>         </tr>       </thead>       <tbody>                               <tr id="section-1">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-1">&#182;</a>               </div>               <p>CoffeeScript fork of Showdown (a JavaScript port of Markdown).</p>
+<!DOCTYPE html>  <html> <head>   <title>showdown.coffee</title>   <meta http-equiv="content-type" content="text/html; charset=UTF-8">   <link rel="stylesheet" media="all" href="docco.css" /> </head> <body>   <div id="container">     <div id="background"></div>            <div id="jump_to">         Jump To &hellip;         <div id="jump_wrapper">           <div id="jump_page">                                           <a class="source" href="abbreviations.html">                 abbreviations.coffee               </a>                                           <a class="source" href="datetimes.html">                 datetimes.coffee               </a>                                           <a class="source" href="showdown.html">                 showdown.coffee               </a>                        </div>         </div>       </div>          <table cellpadding="0" cellspacing="0">       <thead>         <tr>           <th class="docs">             <h1>               showdown.coffee             </h1>           </th>           <th class="code">           </th>         </tr>       </thead>       <tbody>                               <tr id="section-1">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-1">&#182;</a>               </div>               <p>CoffeeScript fork of Showdown (a JavaScript port of Markdown).</p>
 
 <p>Copyright (c) 2011 David Chambers.</p>
 
 <span class="nv">extensions = </span><span class="p">[]</span>
 
 <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="err">\</span><span class="nx">b</span><span class="p">[</span><span class="o">^</span><span class="err">\</span><span class="nx">r</span><span class="p">]</span><span class="o">*?</span><span class="p">.</span><span class="o">*</span>
           <span class="o">&lt;</span><span class="err">/\2&gt;</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">\</span><span class="nx">n</span><span class="o">+</span><span class="p">)</span>
-          <span class="err">\</span><span class="nx">n</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-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="sr">/(\n[ ]{0,3}(&lt;(hr)\b([^&lt;&gt;])*?\/?&gt;)[ \t]*(?=\n\n))/g</span><span class="p">,</span>
       <span class="nx">hashElement</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="sr">/(\n\n[ ]{0,3}&lt;!(--[^\r]*?--\s*)+&gt;[ \t]*(?=\n\n))/g</span><span class="p">,</span>
       <span class="nx">hashElement</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><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="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="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="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">\</span><span class="nx">r</span><span class="p">]</span><span class="o">+?</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="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="err">\</span><span class="nx">n</span><span class="o">+</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-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>
+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="nx">list</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/\n\n+/g</span><span class="p">,</span> <span class="s1">&#39;\n\n\n&#39;</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>
               <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="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="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">\</span><span class="nx">r</span><span class="p">]</span><span class="o">+?</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="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="err">\</span><span class="nx">n</span><span class="o">+</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="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-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>
+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\n+/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="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(@trim().value) - 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="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-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="nv">grafs = </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">@trim</span><span class="p">().</span><span class="nx">value</span><span class="p">.</span><span class="nx">split</span> <span class="sr">/\n\n+/g</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="nx">grafs</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="nx">grafsOut</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span>
+        <span class="nx">grafs</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span>
           <span class="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">str</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">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">replace</span><span class="p">(</span><span class="sr">/^[ \t]*/</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-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="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">grafs</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">grafs</span><span class="p">[</span><span class="nx">index</span><span class="p">]</span>
+        <span class="nx">grafs</span><span class="p">[</span><span class="nx">index</span><span class="p">]</span> <span class="o">=</span>
+          <span class="nx">grafs</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-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
+    <span class="nx">@set</span> <span class="nx">grafs</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="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-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">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">trim</span><span class="p">().</span><span class="nx">replace</span> <span class="sr">/\n\n/g</span><span class="p">,</span> <span class="s1">&#39;\n&#39;</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>
 
 <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\n+$/, &#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="k">new</span> <span class="nx">Text</span><span class="p">(</span><span class="nx">item</span><span class="p">)</span>
         <span class="p">.</span><span class="nx">outdent</span><span class="p">()</span>
         <span class="p">.</span><span class="nx">cond</span><span class="p">(</span>
-          <span class="nx">leading_line</span> <span class="o">or</span> <span class="sr">/\n{2,}/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">item</span><span class="p">),</span>
+          <span class="nx">leading_line</span> <span class="o">or</span> <span class="sr">/\n\n/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">item</span><span class="p">),</span>
           <span class="o">-&gt;</span> <span class="nx">@runBlockGamut</span><span class="nf">()</span>
 <span class="nf">          -&gt;</span> <span class="nx">@doLists</span><span class="p">().</span><span class="nx">trim</span><span class="p">(</span><span class="sr">/\n$/</span><span class="p">).</span><span class="nx">runSpanGamut</span><span class="p">()</span> <span class="c1"># recursion for sub-lists</span>
         <span class="p">)</span>