#93 Replace with role :sup: does not work with language_code: fr


Here is my original posting to docutils-user mailing list and David Goodger reply:

My posting:

I've tried the following replacements:

.. |Na+| replace:: Na\ :sup:`+`

Le |Na+| est l'ion sodium.

.. |K+| replace:: K\ :sup:`+`

Le |K+| est l'ion potassium

every thing works fine if I leave the language_code to en, but obviously this is french so that I change my docutils.conf to language_code: fr and then I obtain the following error:

test.txt:5: (ERROR/3) Error in "replace" directive: may contain a single paragraph only.

test.txt:5: (WARNING/2) Substitution definition "Na+" empty or invalid.

.. |Na+| replace:: Na\ :sup:`+`

test.txt:7: (ERROR/3) Undefined substitution referenced: "Na+".

It does not work for the first replacement |Na+| but works as expected for the second one |K+|. I must admit that I don't understand.

David Goodger's reply:

I don't understand why the first replacement gives an error while the second one doesn't, either. But I found the root cause: Docutils isn't finding the role "sup", because it expects the French "exp" or
"exposant". If you're going to be using the French variant of Docutils, you should be using the French directive & role names too:

.. |Na+| remplace:: Na\ :exp:`+`

Le |Na+| est l'ion sodium.

.. |K+| remplace:: K\ :exp:`+`

Le |K+| est l'ion potassium

This works fine; no errors. For a "dictionary" of equivalencies, see http://docutils.sourceforge.net/docutils/parsers/rst/languages/fr.py . I don't know if these are documented somewhere else (they ought to be).

I don't understand, yet, why there's an error at all. There shouldn't be. The English directive names & role names should be fallback defaults. But I don't have time to solve it now.

Please file a bug on SourceForge so this doesn't get lost. Please include:

"A secondary bug is that an error in the "replace" directive isn't propagating through to the substitution definition error reporting."


  • David Goodger
    David Goodger

    • status: open --> closed-duplicate
  • David Goodger
    David Goodger

    Logged In: YES
    Originator: NO

    closed as duplicate of #1830380