title: Appending paragraph numbers to table of contents headings
body: <p>I've got a bit of a problem here that I can't seem to solve for the life of me.</p>
  
  <p>I have a page of text structured like so:</p>
  
  <pre><code>&lt;h2&gt;Main heading&lt;/h2&gt;
  
  &lt;p&gt;
  &lt;span class="paranum"&gt;1&lt;/span&gt;
  Nam a dapibus felis, id adipiscing libero. 
  Aliquam volutpat vel metus at molestie. Curabitur gravida sed justo at feugiat. 
  In ut pellentesque lorem. Nunc mollis, libero a vestibulum pharetra, neque enim 
  lacinia odio, ut dignissim nisl lectus vitae nisl. Curabitur ac erat nibh. 
  Suspendisse posuere vitae metus at semper. Aliquam vitae tellus id nulla porttitor
   pellentesque at nec elit. Sed nec arcu quis est eleifend gravida.&lt;/p&gt;
  
  &lt;p&gt;
  &lt;span class="paranum"&gt;2&lt;/span&gt;
  Nam a dapibus felis, id adipiscing libero. Aliquam
  volutpat vel metus at molestie. Curabitur gravida sed justo at feugiat. In ut 
  pellentesque lorem. Nunc mollis, libero a vestibulum pharetra, neque enim lacinia odio,
  ut dignissim nisl lectus vitae nisl. Curabitur ac erat nibh. Suspendisse posuere vitae
  metus at semper. Aliquam vitae tellus id nulla porttitor pellentesque at nec elit. 
  Sed nec arcu quis est eleifend gravida.&lt;/p&gt;
  </code></pre>
  
  <p>At the top of my page, I have a table of contents, generated at runtime by the CMS:</p>
  
  <pre><code>&lt;ul class="table-of-contents"&gt;
      &lt;li&gt;&lt;a href="#heading1"&gt;Heading 1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#mainheading"&gt;Main heading&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#aheading"&gt;A heading&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Using <code>JavaScript</code> or <code>jQuery</code> (or any other method people could suggest!) I need to find a way of grabbing the paragraph numbers (defined by the class <code>paranum</code>) found underneath the headings on the page, and displaying them inline with the table of contents, like so:</p>
  
  <p><img src="https://i.stack.imgur.com/Sxnfy.jpg" alt="Table of contents"></p>
  
  <p>Any help is massively appreciated!</p>