From e5e07c3746358fc70afc2e5b0344a5e7573b444a Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 19 Feb 2013 11:00:38 -0500 Subject: Ensure toc attribute is available on Markdown class. This appears to have recently been broken with the fixes in #191. This time I've added tests to prevent future breakage and added documentation to explain the behavior. --- docs/extensions/toc.txt | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'docs/extensions') diff --git a/docs/extensions/toc.txt b/docs/extensions/toc.txt index 632294b..af282c6 100644 --- a/docs/extensions/toc.txt +++ b/docs/extensions/toc.txt @@ -40,8 +40,12 @@ would generate the following output:

Header 1

Header 2

-Configuration Options ---------------------- +Usage +----- + +From the Python interpreter: + + >>> html = markdown.markdown(some_text, extensions=['toc']) The following options are provided to configure the output: @@ -54,3 +58,16 @@ The following options are provided to configure the output: * **title**: Title to insert in TOC ``
``. Defaults to ``None``. * **anchorlink**: Set to ``True`` to have the headers link to themselves. Default is ``False``. + +If a 'marker' is not found in the document, then the toc is available as an +attribute of the Markdown class. This allows one to insert the toc elsewhere +in their page template. For example: + + >>> text = ''' + # Header 1 + + ## Header 2 + ''' + >>> md = markdown.Markdown(extensions=['toc']) + >>> html = md.convert(text) + >>> render_some_template(context={'body': html, 'toc': md.toc}) -- cgit v1.2.3