aboutsummaryrefslogtreecommitdiffstats
path: root/docs/extensions
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2014-08-29 16:02:48 -0400
committerWaylan Limberg <waylan.limberg@icloud.com>2014-08-29 16:02:48 -0400
commite11a15531b5bd2d3ca2636e624ac377471b294e0 (patch)
tree0dda9df57d8843f765513072af2f7902f811734c /docs/extensions
parent8aa89a389ae1a7cdafa516be84532b26ed3c565d (diff)
downloadmarkdown-e11a15531b5bd2d3ca2636e624ac377471b294e0.tar.gz
markdown-e11a15531b5bd2d3ca2636e624ac377471b294e0.tar.bz2
markdown-e11a15531b5bd2d3ca2636e624ac377471b294e0.zip
Code exampeles in extension docs now show best practices.
This is in anticipation of #335. The reference and extension api docs still need to be updated, but that will happen with change in the code.
Diffstat (limited to 'docs/extensions')
-rw-r--r--docs/extensions/header_id.txt5
-rw-r--r--docs/extensions/wikilinks.txt22
2 files changed, 14 insertions, 13 deletions
diff --git a/docs/extensions/header_id.txt b/docs/extensions/header_id.txt
index 71d65f4..2881c50 100644
--- a/docs/extensions/header_id.txt
+++ b/docs/extensions/header_id.txt
@@ -55,7 +55,8 @@ The following options are provided to configure the output:
>>> text = '''
... #Some Header
... ## Next Level'''
- >>> html = markdown.markdown(text, extensions=['headerid(level=3)'])
+ >>> from markdown.extensions.headerid import HeaderIdExtension
+ >>> html = markdown.markdown(text, extensions=[HeaderIdExtension(level=3)])
>>> print html
<h3 id="some_header">Some Header</h3>
<h4 id="next_level">Next Level</h4>'
@@ -72,7 +73,7 @@ The following options are provided to configure the output:
... # Some Header
... # Header with ID # { #foo }'''
>>> html = markdown.markdown(text,
- extensions=['attr_list', 'headerid(forceid=False)'])
+ extensions=['attr_list', HeaderIdExtension(forceid=False)])
>>> print html
<h1>Some Header</h1>
<h1 id="foo">Header with ID</h1>
diff --git a/docs/extensions/wikilinks.txt b/docs/extensions/wikilinks.txt
index 4c31eac..b52e0d0 100644
--- a/docs/extensions/wikilinks.txt
+++ b/docs/extensions/wikilinks.txt
@@ -77,8 +77,9 @@ The following options are provided to change the default behavior:
For an example, let us suppose links should always point to the subdirectory
`/wiki/` and end with `.html`
- >>> html = markdown.markdown(text,
- ... ['markdown.extensions.wikilinks(base_url=/wiki/,end_url=.html)']
+ >>> from markdown.extensions.wikilinks import WikiLinkExtension
+ >>> html = markdown.markdown(text,
+ ... extensions=[WikiLinkExtension(base_url='/wiki/', end_url='.html')]
... )
The above would result in the following link for `[[WikiLink]]`.
@@ -89,19 +90,18 @@ If you want to do more that just alter the base and/or end of the URL, you
could also pass in a callable which must accept three arguments (``label``,
``base``, and ``end``). The callable must return the URL in it's entirety.
- def my_url_builder(label, base, end):
- # do stuff
- return url
-
- md = markdown.Markdown(
- extensions=['markdown.extensions.wikilinks],
- extension_configs={'markdown.extensions.wikilinks' : [('build_url', my_url_builder)]}
- )
+ >>> def my_url_builder(label, base, end):
+ ... # do stuff
+ ... return url
+ ...
+ >>> html = markdown.markdown(text,
+ ... extensions=[WikiLinkExtension(build_url=my_url_builder)],
+ ... )
The option is also provided to change or remove the class attribute.
>>> html = markdown.markdown(text,
- ... ['markdown.extensions.wikilinks(html_class=myclass)']
+ ... extensions=[WikiLinkExtension(html_class='myclass')]
... )
Would cause all wikilinks to be assigned to the class `myclass`.