diff --git a/reporting/md-toc b/reporting/md-toc index d0d2ca3..2b385ea 100755 --- a/reporting/md-toc +++ b/reporting/md-toc @@ -15,6 +15,7 @@ def get_opts(): ) parser.add_argument("-n", help="Number TOC", action="store_true") parser.add_argument("-l", help="TOC as links", action="store_true") + parser.add_argument("-f", help="Flat list, i.e. not bulleted list. Good if your headers contain section numbers.", action="store_true") parser.add_argument( "-a", help="Print whole Markdown, with TOC included.", action="store_true" ) @@ -37,7 +38,9 @@ def main(): fp = open(opts.markdown, "rt") markdown = fp.read().splitlines() - bullet = "-" + + bullet = "" if opts.f else "- " + postspace = " " if opts.f else "" counters = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] lastlev = 0 re_anchor = re.compile("[^0-9a-z-]") @@ -58,9 +61,10 @@ def main(): counters[pad] += 1 lastlev = pad if opts.n: - bullet = "{:d}.".format(counters[pad]) - - entries.append("{}{} {}".format(pad * " ", bullet, title)) + bullet = "{:d}. ".format(counters[pad]) + if opts.f: + pad = 0 + entries.append("{}{}{}{}".format(pad * " ", bullet, title, postspace)) if row == MARKERSTART: marker_found = True if marker_found and not marker_end_found: