aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Chambers <David.Chambers.05@gmail.com>2011-01-22 15:36:32 +1100
committerDavid Chambers <David.Chambers.05@gmail.com>2011-01-22 15:36:32 +1100
commit9fa60ed5f06d58270c0e6804fb39a50b69bedeab (patch)
tree929a2481a3bc80ba860d5d0257b6a7d9f5a57cc4
parent708e2cbee48f80c25ff0f6a94de8b6bcbe116567 (diff)
downloadmarkdown-9fa60ed5f06d58270c0e6804fb39a50b69bedeab.tar.gz
markdown-9fa60ed5f06d58270c0e6804fb39a50b69bedeab.tar.bz2
markdown-9fa60ed5f06d58270c0e6804fb39a50b69bedeab.zip
Made the HeaderId extension's word separator configurable to allow, for
example, hyphens to be used rather than underscores.
-rw-r--r--markdown/extensions/headerid.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/markdown/extensions/headerid.py b/markdown/extensions/headerid.py
index e7e8670..5e9793e 100644
--- a/markdown/extensions/headerid.py
+++ b/markdown/extensions/headerid.py
@@ -157,7 +157,7 @@ class HeaderIdProcessor(markdown.blockprocessors.BlockProcessor):
def _create_id(self, header):
""" Return ID from Header text. """
h = ''
- for c in header.lower().replace(' ', '_'):
+ for c in header.lower().replace(' ', self.config['separator'][0]):
if c in ID_CHARS:
h += c
elif c not in punctuation:
@@ -170,7 +170,8 @@ class HeaderIdExtension (markdown.Extension):
# set defaults
self.config = {
'level' : ['1', 'Base level for headers.'],
- 'forceid' : ['True', 'Force all headers to have an id.']
+ 'forceid' : ['True', 'Force all headers to have an id.'],
+ 'separator' : ['_', 'Word separator.'],
}
for key, value in configs: