From 0a162fa8da21154011a2c890bb82fd0ce96ebf16 Mon Sep 17 00:00:00 2001 From: khanxmetu Date: Sat, 28 Sep 2024 01:18:54 +0300 Subject: [PATCH] i18n: disable default smartquotes for `zh_CN` and `zh_TW` (#12875) --- CHANGES.rst | 1 + sphinx/config.py | 2 +- tests/test_markup/test_smartquotes.py | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 3d5d3913326..1a7482024bf 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,6 +17,7 @@ Incompatible changes Code-blokcs are unchanged as FreeMono is now loaded with ``Scale=0.9``. An adjustement to existing projects is needed only if they used a custom :ref:`fontpkg` configuration and did not set :ref:`fvset`. +* #12875: Disable smartquotes for languages: ``zh_CN`` and ``zh_TW`` by default. Deprecated ---------- diff --git a/sphinx/config.py b/sphinx/config.py index bae92140d59..0fd2102e732 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -271,7 +271,7 @@ class Config: 'smartquotes': _Opt(True, 'env', ()), 'smartquotes_action': _Opt('qDe', 'env', ()), 'smartquotes_excludes': _Opt( - {'languages': ['ja'], 'builders': ['man', 'text']}, 'env', ()), + {'languages': ['ja', 'zh_CN', 'zh_TW'], 'builders': ['man', 'text']}, 'env', ()), 'option_emphasise_placeholders': _Opt(False, 'env', ()), } diff --git a/tests/test_markup/test_smartquotes.py b/tests/test_markup/test_smartquotes.py index e9ee9f3c7ac..b57a8a81017 100644 --- a/tests/test_markup/test_smartquotes.py +++ b/tests/test_markup/test_smartquotes.py @@ -86,6 +86,32 @@ def test_ja_html_builder(app): assert '

-- "Sphinx" is a tool that makes it easy ...

' in content +@pytest.mark.sphinx( + 'html', + testroot='smartquotes', + freshenv=True, + confoverrides={'language': 'zh_CN'}, +) +def test_zh_cn_html_builder(app): + app.build() + + content = (app.outdir / 'index.html').read_text(encoding='utf8') + assert '

-- "Sphinx" is a tool that makes it easy ...

' in content + + +@pytest.mark.sphinx( + 'html', + testroot='smartquotes', + freshenv=True, + confoverrides={'language': 'zh_TW'}, +) +def test_zh_tw_html_builder(app): + app.build() + + content = (app.outdir / 'index.html').read_text(encoding='utf8') + assert '

-- "Sphinx" is a tool that makes it easy ...

' in content + + @pytest.mark.sphinx( 'html', testroot='smartquotes',