From ee6e7d8d71300a0332de4abc2ad5b03cd6e74e9c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Mar 2026 02:41:28 +0000 Subject: [PATCH] TXT Output: Fix asciiize option not applying to generated inline TOC Fixes #3051 --- src/calibre/ebooks/txt/txtml.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/calibre/ebooks/txt/txtml.py b/src/calibre/ebooks/txt/txtml.py index 12506c1b33..73bdeb8a81 100644 --- a/src/calibre/ebooks/txt/txtml.py +++ b/src/calibre/ebooks/txt/txtml.py @@ -97,7 +97,13 @@ class TXTMLizer: if getattr(self.opts, 'inline_toc', None): self.log.debug('Generating table of contents...') toc.append('{}\n\n'.format(_('Table of Contents:'))) + unihandecoder = None + if getattr(self.opts, 'asciiize', False): + from calibre.utils.localization import get_udc + unihandecoder = get_udc() for item in self.toc_titles: + if unihandecoder is not None: + item = unihandecoder.decode(item) toc.append(f'* {item}\n\n') return ''.join(toc)