X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=in%2Fplugins%2Ftoc.md;h=413929fdfe30af2c600196fe6f90ee30afc6cdef;hb=02f430a0056b38a9ec7cab22578ccda64a54f316;hp=44d8410677a44579576eac2ea4b9808efef4b6ab;hpb=90a2bb05a30cba4e00c85a4a698a73bf492fd8f5;p=webber.git
diff --git a/in/plugins/toc.md b/in/plugins/toc.md
index 44d8410..413929f 100644
--- a/in/plugins/toc.md
+++ b/in/plugins/toc.md
@@ -2,6 +2,7 @@ title: Generate table of contents
linktitle: toc.py
parent: Plugins
ctime: 2010-06-23
+change: make get_toc() work like get_recently()
This plugin analyzes the HTML header statements (h1, h2, h3 ...) and
generates a table of contents based on this information.
@@ -19,34 +20,51 @@ very short anyway.
If not specified, this defaults to 30.
-= Usage example =
+= Internal representation =
-with this HTML:
+Given this HTML ...
Calling macros
Example
- Defining macros
+ Defining macros
-the table-of-contents will be like this:
-
+... the plugin populates the variable "`_toc`" like this:
+
+ _toc = [
+ (2, "Calling macros", "calling_macros"),
+ (3, "Example", "example"),
+ (2, "Defining macros", "defining_macros"),
+ ]
+
+... where the first item is the level (h1, h2, etc). The
+second item is the headline and the last element is a so-called
+[[slug|http://en.wikipedia.org/wiki/Slug_(web_publishing)]], used for
+local anchors.
+
-While doing this, it also modifies the HTML file contents to look like this:
+= Generation of a table-of-contents =
- Calling macros
- Example
- Defining macros
+This again is done via a suitable [[template_mako]]. The template uses
+the function "`get_toc()`" and returns (level, headline, slug) tuples.
-== Accessing the TOC ==
+* "`level`" is the indendation level, starting with 0. You can use
+ this for CSS "`id=`" or "`class`" attributes
+* "`headline`" is the headline (the text inside ..)
+* "`slug`" is the
+ [[slug|http://en.wikipedia.org/wiki/Slug_(web_publishing)]] that can
+ be used for link creation
-Use "`${get_toc()}`" in your [[template|template_mako]] to access
-the generated HTML.
+== Example template ==
+
+Here's a sample [[Mako template|template_mako]] excerpt that converts
+this into a HTML:
+
+
== Example CSS ==
@@ -67,3 +85,6 @@ liking, e.g. with this:
width: 100%;
text-align: right;
}
+
+ .toc1 { padding-left: 1em; }
+ .toc2 { padding-left: 2em; }