lib/middleman/docsite/markdown/table_of_contents.rb
# Preprocessor to add quick links at the top of a docs page.
#
# @example
#   $TOC
#     1. [Introduction](#introduction)
#     2. [Getting Started](#getting-started)
#   $TOC
Preprocessor to add quick links at the top of a docs page.
Preprocessor to add quick links at the top of a docs page .
def table_of_contents(document, markdown)
          document.gsub(/^(?:^)\$TOC(.*?)\$TOC *(\r|\n|$)?+/msu) do
            <<~HTML
              <div class="toc">
                <h2 id="toc">Contents</h2>
                #{markdown.render(Regexp.last_match(1))}
              </div>
            HTML
          end
        end
def table_of_contents ( document , markdown ) document . gsub ( / ^(?:^) \$ TOC(.*?) \$ TOC *( \r | \n |$)?+ /msu ) do <<~HTML 
              <div class="toc">
                <h2 id="toc">Contents</h2>
                 #{ markdown . render ( Regexp . last_match ( 1 ) ) } 
              </div>
             HTML end end
Preprocessor to add quick links at the top of a docs page.
Preprocessor to add quick links at the top of a docs page .
document
<not_specific>
markdown
<not_specific>
example
$TOC 1. [Introduction](#introduction) 2. [Getting Started](#getting-started) $TOC
$TOC 1 . [ Introduction ] ( #introduction ) 2 . [ Getting Started ] ( #getting - started ) $TOC