https://github.com/python/cpython/commit/3b013fc2086a49b6ef4a82eb199c64577a3d7236
commit: 3b013fc2086a49b6ef4a82eb199c64577a3d7236
branch: 3.13
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: AA-Turner <9087854+aa-tur...@users.noreply.github.com>
date: 2024-07-23T12:48:23Z
summary:

[3.13] GH-121970: Remove ``escape4chm`` (GH-122065) (#122167)

GH-121970: Remove ``escape4chm`` (GH-122065)
(cherry picked from commit 53e9e7de6359845f118431c05e2f14a96e03b757)

Co-authored-by: Adam Turner <9087854+aa-tur...@users.noreply.github.com>

files:
D Doc/tools/extensions/escape4chm.py
M Doc/.ruff.toml
M Doc/conf.py

diff --git a/Doc/.ruff.toml b/Doc/.ruff.toml
index 24f1c4f2ff6801..111ce03b91df38 100644
--- a/Doc/.ruff.toml
+++ b/Doc/.ruff.toml
@@ -5,7 +5,6 @@ line-length = 79
 extend-exclude = [
     "includes/*",
     # Temporary exclusions:
-    "tools/extensions/escape4chm.py",
     "tools/extensions/pyspecific.py",
 ]
 
diff --git a/Doc/conf.py b/Doc/conf.py
index 17e98e1a01ed21..4841b69e380085 100644
--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -21,7 +21,6 @@
 
 extensions = [
     'c_annotations',
-    'escape4chm',
     'glossary_search',
     'lexers',
     'pyspecific',
diff --git a/Doc/tools/extensions/escape4chm.py 
b/Doc/tools/extensions/escape4chm.py
deleted file mode 100644
index 89970975b9032b..00000000000000
--- a/Doc/tools/extensions/escape4chm.py
+++ /dev/null
@@ -1,58 +0,0 @@
-"""
-Escape the `body` part of .chm source file to 7-bit ASCII, to fix visual
-effect on some MBCS Windows systems.
-
-https://bugs.python.org/issue32174
-"""
-
-import pathlib
-import re
-from html.entities import codepoint2name
-
-from sphinx.util.logging import getLogger
-
-# escape the characters which codepoint > 0x7F
-def _process(string):
-    def escape(matchobj):
-        codepoint = ord(matchobj.group(0))
-
-        name = codepoint2name.get(codepoint)
-        if name is None:
-            return '&#%d;' % codepoint
-        else:
-            return '&%s;' % name
-
-    return re.sub(r'[^\x00-\x7F]', escape, string)
-
-def escape_for_chm(app, pagename, templatename, context, doctree):
-    # only works for .chm output
-    if getattr(app.builder, 'name', '') != 'htmlhelp':
-        return
-
-    # escape the `body` part to 7-bit ASCII
-    body = context.get('body')
-    if body is not None:
-        context['body'] = _process(body)
-
-def fixup_keywords(app, exception):
-    # only works for .chm output
-    if getattr(app.builder, 'name', '') != 'htmlhelp' or exception:
-        return
-
-    getLogger(__name__).info('fixing HTML escapes in keywords file...')
-    outdir = pathlib.Path(app.builder.outdir)
-    outname = app.builder.config.htmlhelp_basename
-    with open(outdir / (outname + '.hhk'), 'rb') as f:
-        index = f.read()
-    with open(outdir / (outname + '.hhk'), 'wb') as f:
-        f.write(index.replace(b'&#x27;', b'&#39;'))
-
-def setup(app):
-    # `html-page-context` event emitted when the HTML builder has
-    # created a context dictionary to render a template with.
-    app.connect('html-page-context', escape_for_chm)
-    # `build-finished` event emitted when all the files have been
-    # output.
-    app.connect('build-finished', fixup_keywords)
-
-    return {'version': '1.0', 'parallel_read_safe': True}

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to