From: Holger Schurig Date: Thu, 24 Jun 2010 06:58:34 +0000 (+0200) Subject: toc.py: more comments X-Git-Url: https://oss.titaniummirror.com/gitweb?p=webber.git;a=commitdiff_plain;h=be8c91275e22ac75d90aef2fa5f825c1d35c3492 toc.py: more comments --- diff --git a/plugins/toc.py b/plugins/toc.py index e379a42..5873e53 100644 --- a/plugins/toc.py +++ b/plugins/toc.py @@ -7,7 +7,6 @@ reHeader = re.compile(r'(.*)', re.IGNORECASE | re.MULTILINE) toc = [] labels = {} - toc_min_lines = 30 @@ -19,7 +18,12 @@ def checkconfig(params): def slugify(text, separator): - """Based on http://snipplr.com/view/26266/create-slugs-in-python/""" + """ + This function converts a normal text string into a string, that + can be safely used for HTML links and anchors. + + Based on http://snipplr.com/view/26266/create-slugs-in-python/ + """ ret = "" for c in text.lower(): @@ -52,6 +56,15 @@ def repl(m): m.group(3), label, m.group(1)) + """ + Function used for re.sub() to find all header elements (h1, h2, ...). + Data from those elements (level, headline) are stored in the global + array `toc`. + + This function also modifies the text by adding a anchor to the + header. + """ + @set_hook("linkify")