waylan/Python-Markdown — Issue #54: toc extension patch
Author: thread13
Created: 2011-11-20 08:54:30+00:00
State: open

A quick hack to support non-ascii headings :

=== diff -u toc.py.new toc.py.old >>> ===

--- toc.py.new 2011-11-20 18:54:52.000000000 +1100
+++ toc.py.old 2011-11-20 18:22:17.000000000 +1100
@@ -76,7 +76,7 @@
# Do not override pre-existing ids
if not "id" in c.attrib:
id = self.config["slugify"][0](c.text)
- if ( id == '' ) or ( id in used_ids ):
+ if id in used_ids:
ctr = 1
while "%s_%d" % (id, ctr) in used_ids:
ctr += 1

=== <<< ===

Basically the slugify() method makes an empty slug for non-ascii headings, so we name them as "_%d" % (heading_occurence) then .