From 9fa60ed5f06d58270c0e6804fb39a50b69bedeab Mon Sep 17 00:00:00 2001 From: David Chambers Date: Sat, 22 Jan 2011 15:36:32 +1100 Subject: Made the HeaderId extension's word separator configurable to allow, for example, hyphens to be used rather than underscores. --- markdown/extensions/headerid.py | 5 +++-- 1 file 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: -- cgit v1.2.3