From 70c81659eca814bb037b93c95996210d192e5ca5 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Wed, 18 Mar 2009 23:29:40 -0400 Subject: Added documentation for Extra Extension and all the extentions it supports. Still need to do non-extra extensions. --- docs/extensions/HeaderId.txt | 104 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 docs/extensions/HeaderId.txt (limited to 'docs/extensions/HeaderId.txt') diff --git a/docs/extensions/HeaderId.txt b/docs/extensions/HeaderId.txt new file mode 100644 index 0000000..efd1eb8 --- /dev/null +++ b/docs/extensions/HeaderId.txt @@ -0,0 +1,104 @@ +HeaderId +======== + +Summary +------- + +An extension to Python-Markdown that adds an 'id' attribute to HTML header +elements (h1-h6) in markdown's output. + +This extension is included in the standard Markdown library. + +Syntax +------ + +The basic syntax follows [PHP Markdown Extra][]'s implementation: + +[PHP Markdown Extra]: http://michelf.com/projects/php-markdown/extra/#header-id + + Header 1 {#header1} + ======== + + ## Header 2 ## {#header2} + +will result in the following HTML: + +

Header 1

+ +

Header 2

+ +However, there is much more that this extension does. + +By default, all headers will automatically have unique "id" attributes +generated based upon the text of the header (See below to turn this off). +Note this example in which all three headers would have the same "id": + + #Header + #Another Header {#header} + #Header + +Results in: + +

Header

+

Another Header

+

Third Header

+ +Configuring the Output +---------------------- + +The HeaderId extension has two configuration settings: + +* **level**: Base level for headers. + + Default: `1` + +* **forceid**: Force all headers to have an id. + + Default: `True` + +The `level` setting allows you to automatically adjust the header levels to fit +within the hierarchy of your html templates. For example, the markdown text for +this page should not contain any headers higher than level 3 (`

`). +Therefore, do the following: + + >>> text = ''' + ... #Some Header + ... ## Next Level''' + >>> html = markdown.markdown(text, ['headerid(level=3)']) + >>> print html +

Some Header

+

Next Level

' + +The `forceid` setting turns on or off the automatically generated ids for +headers that do not have one explicitly defined. + + >>> text = ''' + ... # Some Header + ... # Header with ID # { #foo }''' + >>> html = markdown.markdown(text, ['headerid(forceid=False)']) + >>> print html +

Some Header

+

Header with ID

+ +Using with Meta-Data +-------------------- + +The HeaderId Extension also supports the [[Meta-Data]] Extension. Please see the documentation for that extension for specifics. The supported meta-data keywords are: + +* `header_level` +* `header_forceid` + +When used, the meta-data will override the settings provided through the +`extension_configs` interface. + +This document: + + header_level: 2 + header_forceid: Off + + # A Header + + +Will result in the following output: + +

A Header

-- cgit v1.2.3