urlencode special characters like 'é' in documentation link anchors (#976)

This commit is contained in:
Colton G. Rushton
2022-07-21 20:48:28 -03:00
committed by GitHub
parent d9dbc13701
commit 78d93a6246
3 changed files with 20 additions and 18 deletions

View File

@@ -12,6 +12,7 @@ Headings must start with "##" signs to be detected.
import sys
import re
from collections import namedtuple
from urllib.parse import quote
toc_name = 'Contents'
valid_toc_headings = {'## TOC', '##TOC'}
@@ -27,6 +28,7 @@ def name_to_anchor(name):
anchor = re.sub(punctuation_regexp, '', anchor) # remove punctuation
anchor = anchor.replace(' ', '-') # replace spaces with dash
anchor = re.sub(specialchar_regexp, '', anchor) # remove misc special chars
anchor = quote(anchor) # url encode
return anchor
def get_toc_index(lines):