Skip to content

fr typography: an elision apostrophe before inline markup renders as ” on the site — make it U+2019 in code #324

Done

Description

@mmcky

Native-editor review of the French edition found a rendering defect that the French typography pass should own (item 3 of QuantEcon/lecture-python-programming.fr#77, merged 2026-09-23).

What happens

With language: fr, docutils smartquotes converts a straight ' that ends a text node into a closing quote, and for French that is ”. So de l'[Exercice 1](factorial_exercise) renders as de l”Exercice 1. The apostrophe is followed by a link, emphasis, code or role node, so smartquotes cannot tell it is an elision. Docutils' own guidance is to write U+2019 in the source.

Scale

  • 24 live misrenders on 13 of 27 pages of the French edition: 11 before links, 10 before emphasis or strong, 1 before inline code, 1 before a role, 1 before «. Each matches a l'[, d'*, … in the source one to one.
  • The current engine (v0.29.2, claude-sonnet-5) reproduces the pattern in 7 of 9 fresh init draws of functions, oop_intro and names — partly through the guillemet rule's own d'«.
  • There is no judgement boundary (a French elision before markup is always an apostrophe), so this belongs in deterministic code, not the prompt.

Proposed change

In src/typography.ts, chain an apostrophe pass after the NBSP pass in the fr rule chain, on the same masked prose (inline code, math, links, HTML and URLs are already \u0000N\u0000 placeholders):

(?<![\p{L}\p{N}'‘’])(c|d|j|l|m|n|s|t|qu|jusqu|lorsqu|puisqu|quoiqu|quelqu|presqu)'(?=\u0000|[\[{*_«“])    flags: giu    replacement: $1’
  • The closed elision list, anchored at a word start, leaves genuine quotes ('s'*x*, 'l'[1]) and non-elided forms (Hawai'[i], O'`Reilly`) alone.
  • The straight " is deliberately not in the lookahead: in a real build d’"objets" renders as d’ » objets ».
  • In-word apostrophes are left alone: smartquotes already curls them, and converting them would add ~1,900 characters of diff noise for no visible change.

Required in the same PR:

  • src/heading-map.ts normalizeHeadingForMatch: fold [‘’] → '. A heading with an elision directly before a role is curled in the body but not in its role-stripped map value; without the fold the gating headingMapCorrect check fails and translate headingmap and sync keep rewriting each other's value. No fr heading is affected today (0 of 416), so this is defensive.
  • scripts/typography/apply.mjs: its safety-net normalize must fold the elision ’, scoped to the elision list rather than globally. Unpatched, it refuses all 13 affected files as "body changed beyond spacing". Update its "only changes whitespace" comments and report the elision count alongside the NBSP count.
  • Update the typography.ts header and docs/user/language-config.md, which should say which fr rules are code-enforced.

Tests

A prototype with 22 tests changed exactly the 24 live lines on fr main, with 0 false positives, and is idempotent; en and zh-cn are unchanged. Positive cases include de l'[Exercice 1](x), d'`AxesSubplot`, d'{ref}`appels`, l'*Étape 1*, l'**évaluation**, d'_arguments_, d'$x$, d'« apprendre », jusqu'`n`. Negative cases: plain elisions (l'exécution, aujourd'hui), 's'*gras*, 'l'[1], front matter, code cells, display math, inline code, URLs, and link text (a documented limit). Add a heading-fold test.

Sequencing

Heal the French edition with the patched apply.mjs (23 lines after fr#77) in one fr PR before the release reaches @v0. Otherwise the first sync of each affected file carries apostrophe changes in sections unrelated to its English change. There is no fr harness lane, so validate with a local apply; the E2E gate shows the other lanes unchanged.

Alternative considered: a repo-root docutils.conf with French smartquotes_locales fixes rendering without touching content (verified with jupyter-book 1.0.4.post1; a lectures/docutils.conf is silently ignored because jb build passes noconfig). But it is tied to JB1/docutils, disappears at the mystmd cutover and fixes one edition — a stopgap at most.

Evidence: QuantEcon/project-translation reports/2026-09-23-fr-round2-editor-review-disposition.md, §5 S1.

Activity

  1. added 2 commits that reference this issue on Nov 5, 2026
  2. mmcky commented on Nov 26, 2026

    @mmcky
    ContributorAuthor

    Done in both halves. The engine side, a French elision apostrophe directly before inline markup written as U+2019, is #474, released in v0.34.0 (https://github.com/QuantEcon/action-translation/releases/tag/v0.34.0). The edition side, healing lecture-python-programming.fr's existing text with the patched scripts/typography/apply.mjs, is QuantEcon/lecture-python-programming.fr#118, merged 2026-11-26 as 4c929fa before v0 moved to v0.34.0: 24 elisions in 14 lectures, checked against the dry run's counts, with a second pass changing nothing. So no later sync of an fr lecture carries apostrophe changes in sections its English change did not touch.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions