From 1cb2af06431fa09cf32b74d6d7aab9bfbd722293 Mon Sep 17 00:00:00 2001 From: milde Date: Sun, 19 Nov 2023 09:44:17 +0000 Subject: [PATCH] More smartquotes optimizations. Simplify regexps (we don't need to consider HTML character entities when transforming a Docutils document tree). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@9480 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/HISTORY.txt | 5 ++++ docutils/docutils/utils/smartquotes.py | 36 +++++++++++------------ docutils/test/test_transforms/test_smartquotes.py | 4 +-- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index 450373e7d..073a4406c 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -71,6 +71,11 @@ Changes since 0.20.1 - Update to version `1.4 `__. Fixes feature-requests:#95 (license is now ZPL 2.1). +* docutils/utils/smartquotes.py + + - Pre-compile regexps once, not with every call of `educateQuotes()` + (patch #206 by Chris Sewell). Simplify regexps. + * docutils/writers/latex2e/__init__.py - Fix placement of hyperlink target (label) for tables (bug #440). diff --git a/docutils/docutils/utils/smartquotes.py b/docutils/docutils/utils/smartquotes.py index 7b2bc39b0..dc8beb17d 100755 --- a/docutils/docutils/utils/smartquotes.py +++ b/docutils/docutils/utils/smartquotes.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # :Id: $Id$ -# :Copyright: © 2010 Günter Milde, +# :Copyright: © 2010-2023 Günter Milde, # original `SmartyPants`_: © 2003 John Gruber # smartypants.py: © 2004, 2007 Chad Miller # :Maintainer: docutils-develop@lists.sourceforge.net @@ -149,19 +149,13 @@ ASCII straight quotes, plain dashes, and plain dots, but your published posts (and final HTML output) will appear with smart quotes, em-dashes, and proper ellipses. -SmartyPants does not modify characters within ``
``, ````, ````,
-```` or ``