diff options
author | David Chambers <David.Chambers.05@gmail.com> | 2011-01-22 15:36:32 +1100 |
---|---|---|
committer | David Chambers <David.Chambers.05@gmail.com> | 2011-01-22 15:36:32 +1100 |
commit | 9fa60ed5f06d58270c0e6804fb39a50b69bedeab (patch) | |
tree | 929a2481a3bc80ba860d5d0257b6a7d9f5a57cc4 | |
parent | 708e2cbee48f80c25ff0f6a94de8b6bcbe116567 (diff) | |
download | markdown-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.py | 5 |
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: |