markdownrdiscount

Are numbered headings in Markdown / Rdiscount possible?


I'm trying to produce html with section / subsection headings resembling the following:

  1. My top-level topic
    1.1 My first subtopic
    1.2 Another subtopic
          1.2.1 A sub-subtopic
  2. Another top-level topic

Are there any implementations of Markdown capable of producing these kinds of numbered section headings?


Solution

  • Yes, try Pandoc. This works for me:

    pandoc --number-sections < test.md > out.html
    

    (Source)

    Markdown to produce the numbered outline you mention in the original post looks like this:

    # My top-level topic
    
    ## My first subtopic
    
    ## Another subtopic
    
    ### A sub-subtopic
    
    ## Another top-level topic
    

    If you want deeper indenting for sub-sections, you might be able to achieve this with inline CSS. For example, placing this at the top of the above Markdown source indents the headers:

    <style type="text/css">
      h2 { margin-left: 10px; }
      h3 { margin-left: 20px; }
    </style>
    

    But say you had paragraphs of text under your headings... I don't know how to indent that to the same level as the above header.

    Update 2015-10-18: Markdeep has numbered headings (and many other fancy features). Check that out too!