Best way to automatically number sections
contact at alanhogan.com
Thu Oct 27 12:42:14 EDT 2011
A tool like Nokogiri or libXML could be used to parse the output HTML. Then you could loop over heading elements and get busy. I'm sure the algorithm for that is self-evident -- something to the effect of, keep the last "h level" in mind, and keep a counter for each element; reset the "h2" counter every time the "h level" goes from h1 to h2, etc.
You'll also need to have an idea for how you want to handle "edge cases" (in HTML edge cases are expected) like going from h1 to h3.
Sorry that's all I have for you.
On Oct 27, 2011, at 3:14 AM, Andromac wrote:
> Hi list
> Would anyone suggest the most simple approach to automatically number sections and sub-sections ?
> I usually use more than one tool to edit my Markdown files, including Byword, Textmate, etc.
> Thanks in advance
> Christian Trotobas
> Markdown-Discuss mailing list
> Markdown-Discuss at six.pairlist.net
More information about the Markdown-Discuss