Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toc extension patch #54

Closed
thread13 opened this issue Nov 20, 2011 · 2 comments
Closed

toc extension patch #54

thread13 opened this issue Nov 20, 2011 · 2 comments

Comments

@thread13
Copy link

A quick hack to support non-ascii headings :

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

   --- toc.py.old   2011-11-20 20:03:03.000000000 +1100
   +++ toc.py   2011-11-20 20:04:22.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 in used_ids:
   +                    if ( id == '' ) or ( 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 .

@waylan
Copy link
Member

waylan commented Nov 20, 2011

As the code has changed drastically here, your patch will not apply to the current code. In fact, we are now running unicodedata.normalize() on headers in our slugify() function to support non-ascii headers. Therefore, your patch should be unnecessary.

@waylan waylan closed this as completed Nov 20, 2011
@thread13
Copy link
Author

Indeed, the patch does not apply any more.

But I am happy to report that the problem (making empty slugs for non-ascii headings) was successfully moved with the code to a new location; as I can not reopen this bug, I will file a new one instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants