Skip to content

🐛 FIX: Localize quote rules for smartquotes extension - #1234

Open
ychampion wants to merge 1 commit into
executablebooks:masterfrom
ychampion:fix/smartquotes-locale-806
Open

ychampion wants to merge 1 commit into
executablebooks:masterfrom
ychampion:fix/smartquotes-locale-806

Conversation

@ychampion

Copy link
Copy Markdown

When "smartquotes" was enabled in myst_enable_extensions, create_md_parser enabled markdown-it-py's smartquotes rule with its hardcoded English quote set (“”‘’). During parsing, ASCII quotes were converted to English curly quotes before Sphinx's SphinxSmartQuotes or Docutils' SmartQuotes transform ran, ignoring Sphinx's language setting and Docutils' --language, --smart-quotes, and --smartquote-locales settings.

Changes

  • Add pure helpers resolve_smartquotes() and document_smartquotes() in myst_parser.parsers.mdit that resolve the 4-item (open_double, close_double, open_single, close_single) sequence using Docutils' smartchars.quotes table, BCP 47 subtag fallback (normalize_language_tag), smart_quotes="alt" (-x-altquot), and smartquotes_locales overrides without mutating global Docutils state, falling back to English typographic quotes when unset or unsupported.
  • Accept an optional keyword-only quotes override in create_md_parser() and pass document_smartquotes(document) from both MystParser.parse() (Sphinx) and Parser.parse() (standalone Docutils) whenever "smartquotes" is active (including per-file front matter and nested {include} renders).
  • Document localized quote behavior under docs/syntax/optional.md and add unit and integration tests for standalone Docutils and Sphinx builds.

Fixes #806

When `"smartquotes"` is enabled in `myst_enable_extensions`, resolve the
4-item quote sequence from the document's `language_code`, `smart_quotes`
(`alt`), and `smartquotes_locales` settings via Docutils' `smartchars.quotes`
and `normalize_language_tag` without mutating global Docutils state, falling
back to English typographic quotes when unset or unsupported.

Fixes executablebooks#806

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

smartquotes extension doesn't honor localized rules

1 participant